I have Android Studio library project which has it's own Gradle dependencies:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
}
The problem is with those two external libraries (retrofit & converter-gson). Result of this library project is .aar file. But when I use this .aar file in a separate project I get unresolved class error:
java.lang.NoClassDefFoundError: Failed resolution of: Lretrofit/Retrofit$Builder;
Is there a way to include those gradle dependencies from my library project into the final .aar file?
I tried this answer but it didn't work for me.
EDIT: My whole build.gradle file from library project.
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
}
EDIT 2: This is the part of the build.gradle script in my app project which uses the library which was generated before as an .aar file.
3 versions and none of them work (none of them download automatically dependencies form the library)
(note, I am adding this .aar file into the lib folder of my app project and adding the flatDir instruction into it's gradle.build). I am not doing File->New->NewModule->ImportExistingJAR/AAR
repositories {
flatDir {
dirs 'libs'
}
}
1.
compile(name:'mylibrary-release', ext:'aar')
2.
compile(name:'mylibrary-release', ext:'aar') {
transitive = true
}
3.
compile(':mylibrary-release@aar') {
transitive = true
}