无法在下载的apk上获取提供商com.google.firebase.provider.FirebaseInitProvider,使用adb

时间:2017-10-12 14:10:33

标签: android firebase google-cloud-messaging

非常清楚有类似的问题。尝试了所有的答案,没有一个帮助。

当我使用Android Studio将apk上传到我的手机时,一切正常,但是当我下载并安装apk时,我得到了这个废话:

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.mycompany.myapp-1/base.apk"],nativeLibraryDirectories=[/data/app/com.mycompany.myapp-1/lib/arm64, /system/lib64, /vendor/lib64]]
                                                   at android.app.ActivityThread.installProvider(ActivityThread.java:5945)
                                                   at android.app.ActivityThread.installContentProviders(ActivityThread.java:5534)
                                                   at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5473)
                                                   at android.app.ActivityThread.-wrap2(ActivityThread.java)
                                                   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1571)
                                                   at android.os.Handler.dispatchMessage(Handler.java:102)
                                                   at android.os.Looper.loop(Looper.java:154)
                                                   at android.app.ActivityThread.main(ActivityThread.java:6209)
                                                   at java.lang.reflect.Method.invoke(Native Method)
                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
                                                Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList[[zip file "/data/app/com.mycompany.myapp-1/base.apk"],nativeLibraryDirectories=[/data/app/com.mycompany.myapp-1/lib/arm64, /system/lib64, /vendor/lib64]]
                                                   at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
                                                   at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
                                                   at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
                                                   at android.app.ActivityThread.installProvider(ActivityThread.java:5930)
                                                   at android.app.ActivityThread.installContentProviders(ActivityThread.java:5534) 
                                                   at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5473) 
                                                   at android.app.ActivityThread.-wrap2(ActivityThread.java) 
                                                   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1571) 
                                                   at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                   at android.os.Looper.loop(Looper.java:154) 
                                                   at android.app.ActivityThread.main(ActivityThread.java:6209) 
                                                   at java.lang.reflect.Method.invoke(Native Method) 
                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865) 
                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755) 

该应用程序几乎只是webapp + widget + GCM功能的webview包装器,可以接收推送消息并显示通知。如果我让它工作,我可能永远不需要再次触摸Android,所以对于上帝的爱,请帮助我解决这个最后的问题。

这是我的build.gradle文件:

项目:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'
        classpath 'com.google.gms:google-services:3.0.0'


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

模块:

apply plugin: 'com.android.application'

//apply plugin: "com.ewerk.gradle.plugins.annotation-processor"

android {
    compileSdkVersion 24
    buildToolsVersion '25.0.0'

    defaultConfig {
        applicationId "com.mycompany.myapp"
        minSdkVersion 21
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        multiDexEnabled true  //tried this due to one answer, didnt do anything
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
/*
configurations.all {
    resolutionStrategy {
        force 'com.android.support:design:23.4.0'
        force 'com.android.support:support-v4:23.4.0'
        force 'com.android.support:appcompat-v7:23.4.0'
    }
}
*/

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    //compile 'com.android.support:appcompat-v7:24.4.0'

    //compile 'com.jakewharton:butterknife-compiler:8.4.0'
    //annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
    compile 'org.greenrobot:eventbus:3.0.0'
    compile 'com.jakewharton:butterknife:8.4.0'
    //compile 'com.google.android.gms:play-services-gcm:10.0.1'
    //compile 'com.google.firebase:firebase-messaging:10.0.1'
    compile 'com.google.android.gms:play-services-gcm:9.4.0'
    compile 'com.google.firebase:firebase-messaging:9.4.0'
    //compile 'com.firebase:firebase-client-android:2.3.1'

    // https://mvnrepository.com/artifact/com.squareup.okhttp/okhttp
    compile group: 'com.squareup.okhttp', name: 'okhttp', version: '2.7.5'
}
apply plugin: 'com.google.gms.google-services'

1 个答案:

答案 0 :(得分:0)

终于,Yessss。再见安卓!

原来在正常构建过程中构建的APK android工作室由于某种原因是垃圾。建设 - > Build APK构建了一个3x更大的apk文件,在下载时也能正常工作。