我在API 18中遇到问题,它适用于API 21&上方。
在Pre Lollipop版本设备中获取错误,并且它成功运行API 21中的应用程序&上图:
E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to get provider com.google.firebase.provider.FirebaseInitProvider: android.content.res.Resources$NotFoundException: String resource ID #0x7f070150
at android.app.ActivityThread.installProvider(ActivityThread.java:4882)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4485)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4425)
at android.app.ActivityThread.access$1300(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x7f070150
at android.content.res.Resources.getText(Resources.java:239)
at android.content.res.Resources.getString(Resources.java:325)
at com.google.android.gms.common.internal.zzai.getString(Unknown Source)
at com.google.firebase.FirebaseOptions.fromResource(Unknown Source)
at com.google.firebase.FirebaseApp.zzeh(Unknown Source)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1214)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1189)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
at android.app.ActivityThread.installProvider(ActivityThread.java:4879)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4485)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4425)
at android.app.ActivityThread.access$1300(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
请帮助..: - (
提前致谢。
我尝试了以下链接和搜索,但没有得到结果。 Unable to get provider com.google.firebase.provider.FirebaseInitProvider
等待某人寻求帮助: - (
Gradle文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.2'
compileOptions.encoding = 'windows-1251'
compileOptions.encoding = 'ISO-8859-1'
defaultConfig {
applicationId "com.ascovalve.calculators"
minSdkVersion 14
targetSdkVersion 22
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
sourceSets { main { res.srcDirs = ['src/main/res', 'src/main/res/values-v21'] } }
dexOptions {
preDexLibraries = false
incremental = true;
javaMaxHeapSize "4g"
}
useLibrary 'org.apache.http.legacy'
}
configurations {
all*.exclude group: 'com.google.firebase', module: 'firebase-common'
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.google.code.gson:gson:2.2.3'
compile 'com.android.support:support-v4:+'
compile 'com.google.firebase:firebase-core:9.2.1'
compile 'com.google.android.gms:play-services-location:9.2.1'
compile 'com.firebase:firebase-client-android:2.3.1'
compile 'com.google.firebase:firebase-messaging:9.2.1'
compile 'com.google.firebase:firebase-database:9.2.1'
compile 'com.google.firebase:firebase-auth:9.2.1'
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support:design:+'
compile 'com.android.support:multidex:1.0.1'
}
afterEvaluate {
tasks.matching {
it.name.startsWith('dex')
}.each { dx ->
if (dx.additionalParameters == null) {
dx.additionalParameters = []
}
dx.additionalParameters += '--multi-dex'
dx.additionalParameters += "--main-dex-list=$projectDir/multidex.keep".toString()
}
}
apply plugin: 'com.google.gms.google-services'
答案 0 :(得分:0)
我有类似的错误,并通过从另一个Android应用程序的反编译中删除剩余的R.java文件来解决它。 (是的,反编译是道德的!)
其他Android应用程序也使用google-play-services作为库,因此其R.java文件覆盖了我自己应用程序资源中的R.java,使得运行时使用的资源ID为无效,因此当firebase尝试使用google-play-services时会导致错误。