将 Firebase 远程配置添加到 android SDK(.aar)
Add Firebase Remote Config to android SDK(.aar)
我正在尝试将 firebase remote 添加到我正在开发的 SDK 的配置中,但是当我 运行 应用程序中的 SDK 时,它显示 IllegalStateException
并抛出此
"Default FirebaseApp is not initialized in this process
com.example.xyz. Make sure to call FirebaseApp.initializeApp(Context)
first."
我在 SDK 中调用 FirebaseApp.initializeApp(context)
的位置。我能知道是否有人在 SDK(即 .aar 文件)中实现了 FirebaseRemoteConfig
。
另一个导致 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'
您的 sdk 中需要有一个 class 至少有一个静态方法,例如MySdk.init(context)
获取上下文作为输入,在此方法中,您调用 Firebaseapp.initializeApp(context)
。此外,您还必须要求您的 sdk 用户在其代码的 Application
class 或 launcher activity
class.[=15= 中调用 MySdk.init(context)
]
我正在尝试将 firebase remote 添加到我正在开发的 SDK 的配置中,但是当我 运行 应用程序中的 SDK 时,它显示 IllegalStateException
并抛出此
"Default FirebaseApp is not initialized in this process com.example.xyz. Make sure to call FirebaseApp.initializeApp(Context) first."
我在 SDK 中调用 FirebaseApp.initializeApp(context)
的位置。我能知道是否有人在 SDK(即 .aar 文件)中实现了 FirebaseRemoteConfig
。
另一个导致 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'
您的 sdk 中需要有一个 class 至少有一个静态方法,例如MySdk.init(context)
获取上下文作为输入,在此方法中,您调用 Firebaseapp.initializeApp(context)
。此外,您还必须要求您的 sdk 用户在其代码的 Application
class 或 launcher activity
class.[=15= 中调用 MySdk.init(context)
]