【问题标题】:difference between compile vs compile tree vs compile Files?编译与编译树与编译文件之间的区别?
【发布时间】:2013-12-18 10:48:12
【问题描述】:

我试图将我的项目集成到 android studio 中。但是在添加依赖项时我有点困惑。我不知道哪个好用。我试过编译文件树和编译文件。它不适合我。我找到了一些方法。谁能告诉我哪一个适合添加库(jar 文件只像 admob)。

            compile fileTree(dir: 'libs', include: '*.jar')
         compile 'com.android.support:appcompat-v7:+'
       compile project(":libraries:libraryname")
         compile files('libs/libraryname.jar')

【问题讨论】:

    标签: android dependencies gradle android-studio build.gradle


    【解决方案1】:

    谁能告诉我哪一个适合添加库(jar 文件只像 admob)。

    如果库在 Maven 或 Ivy 存储库(如 Maven Central)中作为工件可用,请将存储库添加到您的 repositories 块(例如,mavenCentral()),然后使用 compile 'com.android.support:appcompat-v7:+',将引用的字符串替换为识别您想要的工件的那个。

    如果该库不能作为工件提供,请将 JAR 放在适当的目录中(例如,libs/ 在项目级别)并使用compile fileTree(dir: 'libs', include: '*.jar')

    compile project(":libraries:libraryname") 用于子项目,您可能没有。

    compile files('libs/libraryname.jar') 有效,但compile fileTree(dir: 'libs', include: '*.jar') 更灵活,因为您不必为每个 JAR 更改您的 build.gradle 文件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-12-09
      • 2016-02-06
      • 1970-01-01
      • 1970-01-01
      • 2020-06-25
      相关资源
      最近更新 更多