简体   繁体   English

使用Gradle,Android Studio,ADT构建依赖项

[英]Build dependencies with gradle, Android Studio, ADT

I am developing Android app with gradle project. 我正在使用gradle项目开发Android应用程序。 My teammates use ADT, and I do Android Studio and I would like to try my best not to force limiting IDE for others. 我的队友使用ADT,而我使用的是Android Studio,我想尽我所能,不要强行限制其他人使用IDE。

As far as I know, ADT needs to have local dependencies (.jar or local lib). 据我所知,ADT需要具有本地依赖项(.jar或本地lib)。
Also if I have main project and local library which contains same local jar files, it cannot build with gradle due to "IllegalArgumentException: already added". 另外,如果我有主项目和包含相同本地jar文件的本地库,则由于“ IllegalArgumentException:已添加”而无法使用gradle进行构建。

Settings below works fine with gradle and Android Studio but not for ADT, support v13 is not found. 以下设置可在gradle和Android Studio上正常运行,但不适用于ADT,找不到支持v13。

Is there any way to make build works for gradle, Android Studio and ADT ? 有什么方法可以使gradle,Android Studio和ADT的构建工作?

Please let me know if you need more information. 如果您需要更多信息,请告诉我。

My project setting looks like 我的项目设置看起来像

settings.gradle settings.gradle

include: ':MyProj'
include: ':libs:PagerSlidingTabStrip'

build.gradle (MyProj's) build.gradle(MyProj)

.....
dependencies {
    compile 'com.android.support:support-v13:13.0.+'
    compile project(':libs:PagerSlidingTabStrip')
}
.....

build.gradle (PagerSlidingTabStrip's) build.gradle(PagerSlidingTabStrip的)

.....
dependencies {
    compile 'com.android.support:support-v13:13.0.+'
}
.....

You will have to do the following: 您将必须执行以下操作:

  • Make an Eclipse project for MyProject and libs/PagerSlidingTabStrip 为MyProject和libs / PagerSlidingTabStrip创建一个Eclipse项目
  • In MyProj, create a libs folder and dump in it both support-v13 and support-v4. 在MyProj中,创建一个libs文件夹并将其转储到support-v13和support-v4。

Do NOT change build.gradle to dep on the content of libs/ or you'll have a duplicate class file issue. 不要更改的build.gradle到DEP对库的内容/或你就会有一个重复的类文件的问题。

This is manageable if you have only one lib project and few dependencies. 如果您只有一个lib项目并且几乎没有依赖项,则这是可管理的。 If your setup become more complex it'll become impossible to manage (hopefully by then we have Gradle support in Eclipse) 如果您的设置变得更加复杂,将变得无法管理(希望届时我们将在Eclipse中提供Gradle支持)

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

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