如何修复 android 4.4.2 错误 ClassNotFoundException:在路径 DexPathList 上找不到 class "com.google.firebase.provider.FirebaseInitProvider"
How to fix android 4.4.2 error ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList
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.access00(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.access00(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">
不幸的是,只有应用程序停止 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.access00(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.access00(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 运行.
当 运行 在 Android 5.0(API 级别 21) 之前的版本上时,使用 multidex 不足以解决linearalloc 限制 (issue 78035). This limit was increased in Android 4.0 (API level 14), but that did not solve it completely. And on versions lower than Android 4.0, you might reach the linearalloc limit before reaching the DEX index limit. So if you are targeting API levels lower than 14, test thoroughly on those versions of the platform, because your app might have issues at startup or when particular groups of classes are loaded. Code shrinking 可以减少或可能消除这些问题。
你的方法太多了。 dex只能有65536个方法
因此,启用 multidex 如下:
android {
defaultConfig {
// Enabling multidex support.
multiDexEnabled true
}
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
像这样创建一个class
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">
解决这个问题,就像在这个link上描述的那样: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'
}
将此添加到 build.gradle,当您不需要 multidex 功能时,multidex 不是必需的
dexOptions {
preDexLibraries = false
}
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.access00(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.access00(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">
不幸的是,只有应用程序停止 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.access00(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.access00(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 运行.
当 运行 在 Android 5.0(API 级别 21) 之前的版本上时,使用 multidex 不足以解决linearalloc 限制 (issue 78035). This limit was increased in Android 4.0 (API level 14), but that did not solve it completely. And on versions lower than Android 4.0, you might reach the linearalloc limit before reaching the DEX index limit. So if you are targeting API levels lower than 14, test thoroughly on those versions of the platform, because your app might have issues at startup or when particular groups of classes are loaded. Code shrinking 可以减少或可能消除这些问题。
你的方法太多了。 dex只能有65536个方法
因此,启用 multidex 如下:
android {
defaultConfig {
// Enabling multidex support.
multiDexEnabled true
}
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
像这样创建一个class
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">
解决这个问题,就像在这个link上描述的那样: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'
}
将此添加到 build.gradle,当您不需要 multidex 功能时,multidex 不是必需的
dexOptions {
preDexLibraries = false
}