简体   繁体   中英

When I add a permission in android manifest.xml my app stops

I was working on google maps when I added permissions in android manifest.xml, now my app has stopped. Before doing that my app was working fine. I enabled multiDexEnabled true . By doing this it removes this error but my app still stops. Please help me, I've spent a lot of time on this but can't.

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'
}

These are the permission which I added.

<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

I notice that the crash is related to Firebase. Try adding this to your app-level build.gradle under dependencies :

compile 'com.google.firebase:firebase-core:10.0.1'

And put this at the bottom of your app-level build.gradle :

// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'

See also: Firebase setup instructions

Your multidex configuration is going for a toss. Please go through the following link - MultiDex documentation

Specially pay attention to the section multidexkeepfile and multidexkeepproguard config

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM