I want to use Firebase Analytics in a library (AAR). Using Android Gradle Plugin 3.0.1 and Gradle 4.1. I included the firebase dependency as api, however, when it is packaged in the AAR, there is no dependency, and it crashes during the execution of the consumer application (this is not a “module” in this application). This failure is caused by an exception java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.analytics.FirebaseAnalytics".
Library module: build.gradle
dependencies {
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.squareup.okhttp3:okhttp:3.9.0'
implementation "com.android.support:support-annotations:$supportLibraryVersion"
implementation "com.android.support:appcompat-v7:$supportLibraryVersion"
api 'com.google.firebase:firebase-core:11.6.0'
}
I can get around this by including the string implementation "<firebase>"in the consumer application, however, I realized that it apiwould appear as a transitive dependency for the consumer.
I do not want to force the consumer application to implement Firebase, and it works when it does not configure the changes google-play-services.json, the plugin and app/build.gradle(if I have a consumer implementation line).
Using either implementation <firebase>, or api <firebase>inside the library module, in the same project, an application that includes it in accordance with: implementation project(':mylib')works fine, only when using AAR a problem arises.
Please note: the module creating the AAR contains its own code.
source
share