[英]Android Studio Unable to get provider com.google.firebase.provider
When I use an AVD with that targets API 24 everything ok. 当我将AVD与目标API 24一起使用时,一切正常。 When is use an AVD that targets API 19 I get error:
当使用针对API 19的AVD时出现错误:
java.lang.RuntimeException: Unable to get provider com.google.firebase.provider.FirebaseInitProvider: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList[[zip file "/data/app/com.cabbytech.driverapphttp-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.cabbytech.driverapphttp-2, /system/lib]]
This is my gradle script: 这是我的gradle脚本:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.cabbytech.driverapphttp"
minSdkVersion 10
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
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:25.1.0'
compile 'com.google.android.gms:play-services:10.0.1'
compile 'com.google.code.gson:gson:2.6.2'
testCompile 'junit:junit:4.12'
}
I think that there is a problem in this gradle script but I can't find any solution. 我认为此gradle脚本中存在问题,但找不到任何解决方案。
Ok I hadn't read this 好吧,我还没看过
https://developer.android.com/studio/build/multidex.html
I implemented these steps and it worked. 我执行了这些步骤,并且成功了。 In the manifes under application tab:
在应用程序选项卡下的菜单中:
<application
android:name="android.support.multidex.MultiDexApplication" >
...
</application>
and in the gradle script: 并在gradle脚本中:
dependencies {
compile 'com.android.support:multidex:1.0.1'
}
It's because you are using wrong virtual device image. 这是因为您使用了错误的虚拟设备映像。 When creating virtual device you should choose system image that support Google APIs.
创建虚拟设备时,您应该选择支持Google API的系统映像。
Correct system image is at the screenshot below. 正确的系统映像在下面的屏幕截图中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.