其他分享
首页 > 其他分享> > 如何修复android 4.4.2错误ClassNotFoundException:在路径上找不到类“com.google.firebase.provider.FirebaseInitProvider

如何修复android 4.4.2错误ClassNotFoundException:在路径上找不到类“com.google.firebase.provider.FirebaseInitProvider

作者:互联网

AndroidRuntime: FATAL EXCEPTION: main
  Process: com.info.app, PID: 24503
  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.info.app-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.info.app-1, /vendor/lib, /system/lib]]
      at android.app.ActivityThread.installProvider(ActivityThread.java:5236)
      at android.app.ActivityThread.installContentProviders(ActivityThread.java:4827)
      at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4710)
      at android.app.ActivityThread.access$1600(ActivityThread.java:174)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1367)
      at android.os.Handler.dispatchMessage(Handler.java:102)
      at android.os.Looper.loop(Looper.java:146)
      at android.app.ActivityThread.main(ActivityThread.java:5593)
      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:1283)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
      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.info.app-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.info.app-1, /vendor/lib, /system/lib]]
      at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:67)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
      at android.app.ActivityThread.installProvider(ActivityThread.java:5221)
      at android.app.ActivityThread.installContentProviders(ActivityThread.java:4827) 
      at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4710) 
      at android.app.ActivityThread.access$1600(ActivityThread.java:174) 
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1367) 
      at android.os.Handler.dispatchMessage(Handler.java:102) 
      at android.os.Looper.loop(Looper.java:146) 
      at android.app.ActivityThread.main(ActivityThread.java:5593) 
      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:1283) 
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099) 
      at dalvik.system.NativeStart.main(Native Method) 

的build.gradle:

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
    mavenCentral()
    maven() {
        url "https://oss.sonatype.org/content/repositories/snapshots"
    }
    maven { url 'https://maven.fabric.io/public' }

}

android {
    dexOptions {
        javaMaxHeapSize "4g"
    }

    compileSdkVersion 25
    buildToolsVersion '25.0.1'
    defaultConfig {
        // Enabling multidex support.
        multiDexEnabled true
        applicationId "com.info.app"
        minSdkVersion 17
        targetSdkVersion 25
        versionCode 16
        versionName "1.0.12"
        testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            debuggable false
            signingConfig signingConfigs.config
        }
        debug {
            debuggable true
            signingConfig signingConfigs.config
        }
    }

    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile project(':CustomBrowser-release')
    compile project(':PayU-release')
    compile project(':sdkui')

    compile('com.github.worker8:tourguide:1.0.17-SNAPSHOT@aar') {
        transitive = true
    }
    compile('com.twitter.sdk.android:twitter:2.3.2@aar') {
        transitive = true;
    }
    compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
        transitive = true;
    }
    compile 'com.intuit.sdp:sdp-android:1.0.4'
    compile 'com.android.support:appcompat-v7:25.0.1'
    compile 'com.android.support:cardview-v7:25.0.1'
    compile 'com.android.support:design:25.0.1'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
    compile 'com.soundcloud.android:android-crop:1.0.1@aar'
    compile 'com.mcxiaoke.volley:library:1.0.19'
    compile 'com.google.code.gson:gson:2.2.4'
    compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
    compile 'de.hdodenhof:circleimageview:2.0.0'
    compile 'com.google.android.gms:play-services:10.2.4'
    compile 'com.facebook.android:facebook-android-sdk:4.15.0'
    compile 'com.google.firebase:firebase-messaging:10.2.4'
    compile 'com.nononsenseapps:filepicker:3.1.0'
    compile 'com.ufreedom.uikit:FloatingViewLib:1.0.2'
    compile 'com.github.paolorotolo:appintro:4.1.0'
    compile 'com.google.firebase:firebase-crash:10.2.4'
    compile 'com.google.firebase:firebase-appindexing:10.2.4'
    compile 'com.stripe:stripe-android:3.1.1'
    compile 'com.braintreepayments:card-form:3.0.5'
    compile 'com.daimajia.numberprogressbar:library:1.4@aar'
    testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'

MyApplication.java:

public class MyApplication extends Application {

      @Override
      public void onCreate() {
          MultiDex.install(getApplicationContext());
          super.onCreate();

AndroidManifest.xml中:

<application
        android:name=".MyApplication"
        android:allowBackup="true"
        android:hardwareAccelerated="false"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:largeHeap="true"
        android:supportsRtl="true"
        android:theme="@style/MyMaterialTheme">

不幸的是,只有app在Android下面停止了4.4.

最新日志文件:

06-17 16:50:36.955 586-586/? I/SELinux: Function: selinux_android_load_priority [0], There is no sepolicy file.

06-17 16:50:37.005 586-586/? I/SELinux: Function: selinux_android_load_priority , spota verifySig and checkHash pass. priority version is VE=SEPF_GT-I9192_4.4.2_0055

06-17 16:50:37.005 586-586/? I/SELinux: selinux_android_seapp_context_reload: seapp_contexts file is loaded from /data/security/spota/seapp_contexts
06-17 16:50:37.005 586-586/? E/dalvikvm: >>>>> Normal User
06-17 16:50:37.005 586-586/? E/dalvikvm: >>>>> com.info.app [ userId:0 | appId:10286 ]
06-17 16:50:37.005 586-586/? D/dalvikvm: Late-enabling CheckJNI
06-17 16:50:37.415 586-586/com.info.app D/AndroidRuntime: Shutting down VM
06-17 16:50:37.415 586-586/com.info.app W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x41ea2da0)
06-17 16:50:37.415 586-586/com.info.app E/AndroidRuntime: FATAL EXCEPTION: main
  Process: com.info.app, PID: 586
  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.info.app-3.apk"],nativeLibraryDirectories=[/data/app-lib/com.info.app-3, /vendor/lib, /system/lib]]
      at android.app.ActivityThread.installProvider(ActivityThread.java:5236)
      at android.app.ActivityThread.installContentProviders(ActivityThread.java:4827)
      at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4710)
      at android.app.ActivityThread.access$1600(ActivityThread.java:174)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1367)
      at android.os.Handler.dispatchMessage(Handler.java:102)
      at android.os.Looper.loop(Looper.java:146)
      at android.app.ActivityThread.main(ActivityThread.java:5593)
      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:1283)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
      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.info.app-3.apk"],nativeLibraryDirectories=[/data/app-lib/com.info.app-3, /vendor/lib, /system/lib]]
      at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:67)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
      at android.app.ActivityThread.installProvider(ActivityThread.java:5221)
      at android.app.ActivityThread.installContentProviders(ActivityThread.java:4827) 
      at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4710) 
      at android.app.ActivityThread.access$1600(ActivityThread.java:174) 
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1367) 
      at android.os.Handler.dispatchMessage(Handler.java:102) 
      at android.os.Looper.loop(Looper.java:146) 
      at android.app.ActivityThread.main(ActivityThread.java:5593) 
      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:1283) 
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099) 
      at dalvik.system.NativeStart.main(Native Method) 

解决方法:

注意:如果您的项目配置为minSdkVersion 20或更低版本的multidex,并且您部署到运行Android 4.4(API级别20)或更低版本的目标设备,则Android Studio将禁用Instant Run.

在Android 5.0(API级别21)之前的版本上运行时,使用multidex不足以解决linearalloc限制(issue 78035).此限制在Android 4.0(API级别14)中有所增加,但这并未完全解决.在低于Android 4.0的版本中,您可能会在达到DEX索引限制之前达到linearalloc限制.因此,如果您将API级别定位为低于14,请在平台的这些版本上进行彻底测试,因为您的应用可能在启动时或在加载特定类组时遇到问题. Code shrinking可以减少或可能消除这些问题.

你有太多的方法. dex只能有65536种方法.

因此,启用multidex如下:

android {    
defaultConfig {
    // Enabling multidex support.
    multiDexEnabled true
}  
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
}

像这样创建一个类

public class Multi_Dex extends Application {
@Override
protected void attachBaseContext(Context base) {
    super.attachBaseContext(base);
    MultiDex.install(this);
}
}

现在在你最明显的文件中添加这个

<application
    android:name=".Multi_Dex"
    android:allowBackup="true"
    android:icon="@drawable/logo"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">

解决这个问题,如此链接所述:developer.android.com/studio/build/multidex

或试试我的朋友kitkat或更低版本

android {
defaultConfig {
    ...
    multiDexEnabled true
}
productFlavors {
    dev {
        // Enable pre-dexing to produce an APK that can be tested on
        // Android 5.0+ without the time-consuming DEX build processes.
        minSdkVersion 21
    }
    prod {
        // The actual minSdkVersion for the production version.
        minSdkVersion 14
    }
}
buildTypes {
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'),
                                             'proguard-rules.pro'
    }
}
}
dependencies {
compile 'com.android.support:multidex:1.0.1'
}

标签:android,firebase,android-4-4-kitkat
来源: https://codeday.me/bug/20190917/1809421.html