Gradle for Eclipse - Android
Back to Android page
Support library
While with gradle-based build system adding support library is as simple as adding
compile 'com.android.support:appcompat-v7:19.0.+'
inside app’s build.gradle
dependencies block,
for Eclipse with ADT it should be as referenced project listed in project.properties
.
E:\Android\sdk
below is example location specified in you ANDROID_HOME
environment variable.
sdk\extras\android\support\v7\appcompat
contains template for “appcompat_v7” (
Contrary to m2repository extras\android\support
contains only one revision of the library.
So when you upgrade SDK, added “appcompat_v7” project will be copied from newer template.
Support library revision conflicts
-
If you have
android-support-v4.jar
inlibs
folder check that in yourdependencies
blockfileTree
hasexclude
:compile fileTree(dir: ‘libs’, include: ‘.jar’, exclude: ‘android-support-.jar’)
-
Some gradle dependencies may have transitive dependency on support library of other revision (e.g. rev 19 while you using rev 21). Check with
gradle -q dependencies
and add{ exclude module: 'support-v4'}
, for examplecompile(‘com.company:superlib:1.0.0’) { exclude module: ‘support-v4’}
See Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat
Other option is to to use resolutionStrategy
at root build.gradle
ref
allprojects {
configurations.all((Closure) {
resolutionStrategy {
force 'com.android.support:support-v4:21.0.2' // your version of support library
}
})
}
Adding sources
for Eclipse
E:\Android\sdk\extras\android\support\v7\appcompat\libs
add android-support-v4.jar.properties
src=E:\Android\sdk\extras\android\support\v4\src
and android-support-v7-appcompat.jar.properties
src=E:\Android\sources\platform_frameworks_support\v7\appcompat\src
While v4 lib sources should be once you get “Extra / Android Support Library” via SDK Manager, for v7 sources you should (from e.g. e:\Android\sources folder )
git clone https://github.com/android/platform_frameworks_support.git
For Gradle usage get “Extra / Android Support Repository”.
.aar files appear e.g. in E:\Android\sdk\extras\android\m2repository\com\android\support
but again without sources.
for Android Studio
Inside app/build.gradle
apply plugin: 'idea'
idea {
module{
sourceDirs += file("E:\\Android\\sdk\\extras\\android\\support\\v4\\src\\")
sourceDirs += file("E:\\Android\\sources\\platform_frameworks_support\\v7\\appcompat\\src")
}
}