简体   繁体   English

Android Studio:根据第三方库的来源制作应用程序

[英]Android Studio: make application depending on sources of third-party library

I got in troubles when trying to put dependncies on my project on third-party library. 尝试对第三方库上的项目施加依赖时遇到麻烦。 I tried to depend on the same lib from maven, but version in maven is not up-to-date, however downloaded package has latest changes. 我试图依赖于来自maven的同一个库,但是maven中的版本不是最新的,但是下载的软件包具有最新更改。

Downloaded folder has only 'src', 'pom' and '.gitignore' in it. 下载的文件夹中仅包含“ src”,“ pom”和“ .gitignore”。 When I try to import project into Android Studio and then put dependencies, I can't because Android Studio only wants Gradle or Eclipse project to be imported. 当我尝试将项目导入Android Studio并放入依赖项时,我不能这样做,因为Android Studio只希望导入Gradle或Eclipse项目。 I tried to create at least IntelliJ project from existing sources, however after I still cannot set dependencies as Android Studio requires just Gradle or Eclipse project. 我尝试至少从现有资源创建IntelliJ项目,但是在我仍然无法设置依赖项之后,因为Android Studio仅需要Gradle或Eclipse项目。 Can you help me with that dependencies issue? 您可以帮我解决相关性问题吗? Thanks. 谢谢。

Three options here: 这里有三个选择:

  1. In general you should depend on a compiled binary. 通常,您应该依赖于已编译的二进制文件。 The best would be to find it in one of the repositories (eg jcenter or maven central) and then declare it in your gradle build. 最好的办法是在其中一个存储库(例如jcenter或maven central)中找到它,然后在gradle构建中声明它。
  2. If this dependency does not exist in any repository, but available to download in another format (maybe a zip file with jar files inside or something), you can put the jar file into the lib folder of your project. 如果此依赖关系在任何存储库中都不存在,但可以以另一种格式下载(可能是内部包含jar文件的zip文件等),则可以将jar文件放入项目的lib文件夹中。
  3. As a last resort you can check out the sources, build it with Maven (you have to have Maven installed and included in your path) by running mvn install . 作为最后的选择,您可以运行mvn install ,检查源代码,并使用Maven进行构建(必须安装Maven并将其包含在路径中)。 After you done that (assuming the project is built successfully), you can put the jar from the build folder into your lib folder, or add maven plugin to your build.gradle that will find the jar file automatically in your local machine cache. 完成此操作后(假设项目已成功构建),可以将jar文件从build文件夹放到lib文件夹中,或将maven插件添加到build.gradle ,该插件将在本地计算机缓存中自动找到jar文件。

In any of the later two cases, you're more than welcome to ask the developer to publish its project binaries to Bintray. 在后两种情况中的任何一种情况下,都非常欢迎您要求开发人员将其项目二进制文件发布到Bintray。 That will allow the right usage (#1) to all the rest of the users. 这将允许所有其他用户正确使用(#1)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM