我试图在我正在开发的SDK中添加firebase到配置中,但是当我在一个应用程序中运行SDK时,它会使用IllegalStateException并抛出以下内容
“在此过程中未初始化默认FirebaseApp com.example.xyz。请确保首先调用FirebaseApp.initializeApp(上下文)。”
当我在SDK中调用FirebaseApp.initializeApp(context)时。我能否知道是否有人在SDK中实现了FirebaseRemoteConfig (即.aar文件)。
另一个导致gradle生成应用程序的错误是:
Could not get unknown property 'LibraryVariants' for object of type com.android.build.gradle.LibraryExtension.这是我的build.gradle文件:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
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:25.3.1'
testCompile 'junit:junit:4.12'
compile 'com.google.code.gson:gson:2.8.0'
//Retrofit
compile 'com.squareup.retrofit2:retrofit:2.2.0'
compile 'com.squareup.retrofit2:converter-gson:2.2.0'
//Okhttp3
compile 'com.squareup.okhttp3:okhttp:3.6.0'
//Wakelock
compile 'com.commonsware.cwac:wakeful:1.1.0'
//Google Play Services
compile 'com.google.android.gms:play-services-maps:11.0.1'
compile 'com.google.android.gms:play-services-location:11.0.1'
//Android Job
compile 'com.evernote:android-job:1.1.7'
//Firebase
compile 'com.google.firebase:firebase-config:11.0.1'
}
}
apply plugin: 'com.google.gms.google-services' 发布于 2017-06-21 12:22:47
您需要在sdk中拥有至少一个静态方法的类,例如MySdk.init(context),它将上下文作为输入,并且在此方法中调用Firebaseapp.initializeApp(context)。此外,您还必须要求sdk的用户在代码的Application类或launcher activity类中调用Application。
https://stackoverflow.com/questions/44675814
复制相似问题