当我在android manifest.xml中添加权限时,我正在使用谷歌地图,现在我的应用已停止。
在此之前我的应用程序运行正常。
我启用了multiDexEnabled true
。通过这样做,它删除了此错误,但我的应用程序仍然停止。请帮助我,我花了很多时间在这上面但不能。
gradle.build
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "24.0.3"
defaultConfig {
applicationId "com.shah.myapplication1"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
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.0.0'
compile 'com.android.support:design:25.0.0'
testCompile 'junit:junit:4.12'
compile 'com.google.android.gms:play-services:9.6.1'
}
这些是我添加的权限。
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
logcat的
01-21 01:06:27.732 12427-12427/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.shah.myapplication1, PID: 12427
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.shah.myapplication1-1.apk"],nativeLibraryDirectories= [/data/app-lib/com.shah.myapplication1-1, /vendor/lib, /system/lib]]
at android.app.ActivityThread.installProvider(ActivityThread.java:5275)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4867)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4750)
at android.app.ActivityThread.access$1600(ActivityThread.java:179)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1384)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5641)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1288)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1104)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList[[zip file "/data/app/com.shah.myapplication1-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.shah.myapplication1-1, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
at android.app.ActivityThread.installProvider(ActivityThread.java:5260)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4867)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4750)
at android.app.ActivityThread.access$1600(ActivityThread.java:179)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1384)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5641)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1288)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1104)
at dalvik.system.NativeStart.main(Native Method)
01-21 01:06:27.742 12427-12427/? I/Process: Sending signal. PID: 12427 SIG: 9
答案 0 :(得分:0)
我注意到崩溃与Firebase有关。尝试将此添加到rest
下的应用级build.gradle
:
dependencies
并将其放在应用级compile 'com.google.firebase:firebase-core:10.0.1'
的底部:
build.gradle
答案 1 :(得分:0)
你的multidex配置正在进行折腾。请仔细阅读以下链接 - MultiDex documentation
特别注意 multidexkeepfile 和 multidexkeepproguard 配置
部分