I'm developing an app that uses GoogleAPIClient to (obviously) get the user current location in background.
For this task I use IntentService with WakefulBroadcastReceiver (to get the location every hour). Everything was working fine on development environment but when deployed in Play Store some devices are getting this error:
Fatal Exception: java.lang.NoClassDefFoundError: com/google/android/gms/internal/zzsa
at com.google.android.gms.common.api.GoogleApiClient$Builder.<init>(Unknown Source)
at tellerina.com.br.vivara.services.MyService.onHandleIntent(MyService.java:37)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.os.HandlerThread.run(HandlerThread.java:61)
I have searched the internet for answers but I didn't find anything. Here's the point where the exception appears:
mGoogleApiClient = new GoogleApiClient.Builder(MyApplication.getContext())
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API)
.build();
Thanks a lot!
EDIT
app build.gradle
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.21.2'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "app.package"
minSdkVersion 14
targetSdkVersion 22
versionCode 9
versionName "1.5.2"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
javaMaxHeapSize "4g"
}
}
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile fileTree(dir: 'libs', include: ['*.so'])
compile(project(':volley')) {
exclude module: 'support-v4'
}
compile files('libs/commons-codec-1.9.jar')
compile('com.navercorp.volleyextensions:volley-views:2.0.+') {
exclude module: 'library'
}
compile('com.crashlytics.sdk.android:crashlytics:2.5.5#aar') {
transitive = true;
}
compile 'com.android.support:appcompat-v7:23+'
compile 'com.android.support:cardview-v7:23+'
compile 'com.android.support:recyclerview-v7:23+'
compile 'com.google.code.gson:gson:2.3.1'
compile 'io.card:android-sdk:5.1.1'
compile 'com.github.ksoichiro:androidpagecontrol:0.1.1'
compile 'me.relex:circleindicator:1.1.5#aar'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.easing:library:1.0.1#aar'
compile 'com.daimajia.androidanimations:library:1.1.3#aar'
compile 'com.facebook.android:facebook-android-sdk:4.5.0'
compile 'br.com.jansenfelipe:androidmask:1.0.1'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.android.support:multidex:1.0.0'
compile 'com.android.support:design:23+'
compile 'com.squareup.picasso:picasso:2.5.2'
}
apply plugin: 'com.google.gms.google-services'
Root project build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'com.google.gms:google-services:+'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
EDIT 2
Using Fabric, now I can see that all of users affected by this problem is using Android 4.x. Maybe the distribution of Play Services is bugged, I don't know. But it's decreasing the number of devices with this error.
You are getting
Fatal Exception: java.lang.NoClassDefFoundError:
com/google/android/gms/internal/zzsa
at com.google.android.gms.common.api.GoogleApiClient$Builder.(Unknown
Source)
NoClassDefFoundError in Java comes when Java Virtual Machine is not able to find a particular class at runtime which was available during compile time.
OLD
dependencies {
// classpath 'com.android.tools.build:gradle:1.5.0'
// classpath 'com.google.gms:google-services:+' //(Avoid Calling "+")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
GoogleApiClient is used with a variety of static methods. Some of
these methods require that GoogleApiClient be connected, some will
queue up calls before GoogleApiClient is connected;
mGoogleApiClient = new GoogleApiClient.Builder(this)
You should try with your build.gradle
Top-level build file where you can add configuration options common to
all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-beta2'
classpath 'com.google.gms:google-services:2.0.0-beta2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Advice
you can call
compile 'com.android.support:appcompat-v7:23.1.1' instead of
v7:23+
Then Clean-Rebuild-Restart-Sync Your Project .Hope this helps .
Edit
The Android build system consists of an Android plugin for Gradle.
Gradle is an advanced build toolkit that manages dependencies and
allows you to define custom build logic. Android Studio uses a Gradle
wrapper to fully integrate the Android plugin for Gradle. The Android
plugin for Gradle also runs independent of Android Studio.
A plugin is simply any class that implements the Plugin interface. Gradle provides the core plugins as part of its distribution so simply applying the plugin as above is all you need to do.
with beta2 and alpha-5 gradle dosen't show error. But without "apply
plugin: 'services'" and 'classpath' it's not generated
gcm_defaultSenderId for GCM
You can check Get an Instance ID
You should use apply plugin .
This is clearly a proguard configuration error of gms (Google Play Services).
Either it's caused by a wrong version that you build against, and you can build against another one.
Or it's caused by the Play Services installed on the device, and you can only hope that the Play Services team has stopped roolout of this version until the bug is fixed.
FINALLY! I spent literally several hours trying to resolve this issue, maybe it has already been resolved but it turns out any of the google classes you use have to all be the SAME VERSION in the gradle, i.e.
compile 'com.google.android.gms:play-services-identity:7.8.0'
compile 'com.google.android.gms:play-services-location:7.5.0'
I was calling two different versions. Once I chanced it to this:
compile 'com.google.android.gms:play-services-identity:7.8.0'
compile 'com.google.android.gms:play-services-location:7.8.0'
the classdeferror was resolved!
Related
I want to integrate my app with facebook login, but when adding below dependency and syncing Gradle:
implementation 'com.facebook.android:facebook-android-sdk:[5,6)'
I got the following errors:
ERROR: Failed to resolve: legacy-support-v4
Affected Modules: app
ERROR: Failed to resolve: browser
Affected Modules: app
ERROR: Failed to resolve: legacy-support-core-utils
Affected Modules: app
ERROR: Failed to resolve: media
Affected Modules: app
My build.gradle in app-level:
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
buildscript {
repositories {
maven { url 'https://plugins.gradle.org/m2/'}
}
}
repositories { }
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.***************"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.android.support:design:28.0.0'
implementation 'com.google.firebase:firebase-analytics:17.2.1'
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
implementation 'com.github.GrenderG:Toasty:1.4.1'
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
implementation 'com.gauravk.bubblenavigation:bubblenavigation:1.0.7'
implementation 'com.tuyenmonkey:mkloader:1.4.0'
implementation 'me.riddhimanadib.form-master:form-master:1.1.0'
implementation 'com.facebook.android:facebook-android-sdk:[5,6)'
}
apply plugin: 'com.google.gms.google-services'
and build.gradle on project-level:
buildscript {
repositories {
google()
jcenter()
maven { url 'https://maven.fabric.io/public' }
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.8.2'
classpath 'com.google.gms:google-services:4.3.3'
classpath 'io.fabric.tools:gradle:1.31.2'
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://www.jitpack.io" }
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I've searched a lot on google and StackOverflow and tested all the methods, but this problem doesn't fix. Please help me where is my problem.
First of all remove
buildscript {
repositories {
maven { url 'https://plugins.gradle.org/m2/'}
}
}
repositories { }
from your app-level Gradle file when you have repositories set in your project-level Gradle file. This causes confusion.
Use implementation 'com.facebook.android:facebook-android-sdk:5.13.0' instead of your dependency.
You can always check Maven Centeral for the latest version of libraries.
or
Use Gradle, please, just enter the library name you need and copy the result (don't forget to replace compile with implementation)
I've tested some of Facebook SDK versions, suddenly in 4.26.0 version, my Gradle was successfully built.
I've checked the release note of Facebook SDK on the next version ( 4.27.0 ) and I find this:
Modified
+ Restructured the Facebook SDK and organized it into separate libraries/modules that can depend on one another.
+ Moves GraphRequest.createOpenGraphObject(ShareOpenGraphObject) to ShareGraphRequest.createOpenGraphObject(ShareOpenGraphObject)
+ Moves FacebookSDK.[set|get]WebDialogTheme(...) to WebDialog.[set|get]WebDialogTheme(...)
+ Removes unused dimens from styles.xml
+ Removes files only used by internal tests
+ updates proguard files
Anyway, with the following line, my problem was solved:
implementation 'com.facebook.android:facebook-android-sdk:4.26.0'
It's not good news for me to use about 3 years ago package, but at this point, I don't have any Idea.
Looks like you're pointing to a library that doesn't exist.
Replace your implementation.... with:
implementation 'com.facebook.android:facebook-login:[5,6)'
(source: https://developers.facebook.com/docs/android/componentsdks/)
As Stated in this post, you need to add these two properties to gradle.properties file:
android.useAndroidX=true
android.enableJetifier=true
The Android studio ask me to update the gradle version to 4.4 and gradle build tool version to 3.1.2.
After the update, The whole android studio shows red lines in file, when I hover my cursor on these error it says "cannot resolve symbol" but compiles with no error i.e., build is successful.Click here to see red lines in java files
and Here are the gradle app and project files.
//Build.gradle(project)
//Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
maven {
url 'https://maven.fabric.io/public'
}
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:3.2.0'
classpath 'io.fabric.tools:gradle:1.25.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven {
url 'https://maven.google.com/'
}
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and
//build.gradle(module:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.developers.paras.droidwatch"
minSdkVersion 19
targetSdkVersion 27
versionCode 9
versionName "9.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
android.defaultConfig.vectorDrawables.useSupportLibrary = true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:27.1.1'
compile 'com.android.support:customtabs:27.1.1'
compile 'com.android.support.constraint:constraint-layout:1.1.0'
compile 'com.android.support:design:27.1.1'
compile 'com.android.support:support-v4:27.1.1'
compile 'com.google.android.gms:play-services-ads:15.0.1'
compile 'com.google.firebase:firebase-core:15.0.2'
compile 'com.crashlytics.sdk.android:crashlytics:2.9.2'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
apply plugin: 'io.fabric'
Things I have already tried.
Clean and Rebuild.
Invalidate Cache and Restart.
Updating gradle version to 4.9.
Setting local gradle for the project.
See my gradle logs here https://drive.google.com/open?id=18bFZdkWX4AFPfpmfjvN1t80WpVRpiHWs
See even release build is generated after these errors. Release apk generated
Update : Recently after Reinstalling Studio, I've created a new project and everything works fine. No errors for "cannot resolve symbol".
not the most graceful solution in the world but deleting and re-cloning the project was the fastest way to resolve this for me.
if you're not using git... well. now is a good time to start.
I tried deleting and re-syncing all the various config files and it didn't do anything.
I got into similar situation: upgraded Gradle to 4.4, then opened a former porject which had been built with Gradle 3.1.2.
Android Studio noticed it and generously offered:
To take advantage of all the latest features (such as Instant Run), improvements and security fixes, we strongly recommend that you update the Android Gradle plugin to version 3.1.2 and Gradle to version 4.4.
When I choose to update, I got the red underlines showing errors everywhere in MainActivity.java, however the project was building and runnig perfectly.
I also tried to rebuild and to invalidate cache & restart, but had no success.
For me, editing the build.gradle (module:app) file helped.
When I modified both compileSdkVersion and targetSdkVersion to the latest (27) and changed the version number of line implementation 'com.android.support:appcompat-v7:2x.x.x' under dependencies to the latest, then resynced, the red lines suddenly disappeared from MainActivity.java and everything became normal.
Maybe not the fiddling with sdk version numbers are important here, but to force a proper gradle resync.
Please note also, that since Gradle 3.4, under dependencies in build.gradle file some configuration words changed: compile, testCompile, androidTestCompile, testApi, androidTestApi become obsolete and should be replaced with implementation or api.
You can find more on this issue here: https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration?utm_source=android-studio#new_configurations and a proper explanation on the difference between choosing implementation or api here: https://medium.com/mindorks/implementation-vs-api-in-gradle-3-0-494c817a6fa
I try to implement firebase into my app. But there is an interference between firebase and google play service.
Here is my build.gradle for the module:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.nefrin.client"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
// Enabling multidex support.
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.google.android.gms:play-services:11.0.4'
compile 'com.github.tajchert:nammu:1.1.3'
compile 'gun0912.ted:tedpermission:1.0.3'
compile 'com.github.jksiezni.permissive:permissive:0.2'
compile 'com.github.arimorty:floatingsearchview:2.0.3'
//compile 'net.sf.sprockets:sprockets-android:4.0.0'
compile 'com.github.michael-rapp:android-material-dialog:4.0.2'
compile 'com.github.bumptech.glide:glide:3.5.2'
compile 'com.google.firebase:firebase-auth:11.2.0'
}
apply plugin: 'com.google.gms.google-services'
And here is build.gradle for the project:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.google.gms:google-services:3.1.0' // google-services plugin
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://jitpack.io"
}
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots'
}
maven {
url "https://maven.google.com" // Google's Maven repository
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
When I try to run the app I get eventhough I didn't use cardview in my app:
Error:Execution failed for task ':app:prepareComAndroidSupportCardviewV72330Library'.
> Could not expand ZIP 'C:\Users\Nefrin\.gradle\caches\modules-2\files-2.1\com.android.support\cardview-v7\23.3.0\abdf83a0192c03ff190f941c6c885af18d257a2c\cardview-v7-23.3.0.aar'.
Android Studio is underlining the compile 'com.google.android.gms:play-services:11.0.4' and says:
All com.google.android.gms libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 11.2.0, 11.0.4. Examples include com.google.android.gms:play-services-basement:11.2.0 and com.google.android.gms:play-services:11.0.4 less... (Ctrl+F1)
There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion.)
As the error says all the google libraries should use the same version.
So you should update the play-services library and use the same version as firebase:
compile 'com.google.android.gms:play-services:11.2.0'
compile 'com.google.firebase:firebase-auth:11.2.0'
You need to change this line of code:
compile 'com.google.android.gms:play-services:11.0.4'
with
compile 'com.google.android.gms:play-services:11.2.0'
Hope it helps.
I have seen similar responses to the below question. Sorry but i could not fixed it out trying multiple things so I am asking it again.
Whenever I am trying to build my app, the gradle build throws me the below error stating ...due to duplicate entry of javax/Inject class.
This only occurred when I am trying to put compile 'org.glassfish.jersey.containers:jersey-container-jdk-http:2.9' in my build.gradle file; This package is necessary for javax.ws.rs.* services.
I tried running the gradlew clean command in my root directory, it says that build is successful but when I am building my application again it started throwing the error again.
Can you please help on the below error:
*Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: javax/inject/Inject.class*
Below is my app gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.usfca.studentrecordsverifycation"
minSdkVersion 17
targetSdkVersion 23
versionCode 1
versionName "1.0"
// Enabling multidex support.
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
maven { url 'http://repo1.maven.org/maven2' }
maven { url 'http://maven.restlet.com' }
maven { url 'https://maven.java.net/content/repositories/releases/' }
maven { url 'http://download.java.net/maven/2/' }
maven { url 'http://download.java.net/maven/1' }
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:design:23.3.0'
compile 'com.android.support:multidex:1.0.1'
compile 'log4j:log4j:1.2.17'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.madgag:sc-light-jdk15on:1.47.0.3'
compile 'com.cloudinary:cloudinary-http44:1.4.5'
compile 'org.glassfish.jersey.containers:jersey-container-jdk-http:2.9'
compile 'commons-lang:commons-lang:2.6'
}
Below is my Project gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Ok so I created a sample project with all those dependencies and I got a different error.
So if you are still getting the ZipException error, you have some jars in your lib folder that we are not aware of?
Here's the error I got:
Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/LICENSE
If you are getting a similar error, all you need to do is add the following to your build.gradle:
android {
defaultConfig {
...
}
buildTypes {
....
}
packagingOptions {
exclude 'META-INF/LICENSE'
}
}
If this doesn't make any difference, do you have any jar libraries in your project? If so, we need to see the list.
EDIT:
I can't know for sure if it will work because I am not getting the same error. In your dependencies, change to this:
compile ('org.glassfish.jersey.containers:jersey-container-jdk-http:2.9') {
exclude group: 'javax.inject', module: 'javax.inject'
}
This error means that the class javax.inject.Inject is being included twice in your apk when the dexer runs. That is, this exact same class is coming from 2 different dependencies. One of them is probably org.glassfish.jersey.containers:jersey-container-jdk-http:2.9 because it happens after you added it.
If you CMD+O (jump to class) on Android Studio, you should be able to see the 2 versions of this class and see where they are coming from. Make sure you select the checkbox that allows it to show classes included from your dependencies. Once you open them, hover over the file tab and you'll see a tooltip with the artifact name. That is gonna be the dependency that's including that class.
Hope it makes sense.
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
}
Your AAR library is not the problem. Libraries are not supposed to include their dependencies as it may cause version conflicts further down.
The reason your app project is not transitively loading your library's dependencies is the flatdir. Here's the relevant part in the docs (https://docs.gradle.org/current/userguide/declaring_repositories.html#sub:flat_dir_resolver):
This type of repository does not support any meta-data formats like
Ivy XML or Maven POM files. Instead, Gradle will dynamically generate
a module descriptor (without any dependency information) based on the
presence of artifacts.
The correct approach would be to host your library in a public or private maven repository.
The accepted answer from How to include JAR dependency into an AAR library works. You need to add an evaluation listener, like this:
afterEvaluate {project -> project.tasks.preBuild.dependsOn copyLibs}