硬件信息
phone: Huawei Mate 7(MT7-TL10)
OS: Android 4.4.2
CPU: Kirin925
Build.gradle
android {
compileSdkVersion 27
defaultConfig {
minSdkVersion 15
targetSdkVersion 25
}
dependencies {
compile 'com.android.support:multidex:1.0.3'
}
}
这里是我的minSdkVersion> 14,所以它支持multidex
重要日志
I/MultiDex( 4514): VM with version 1.6.0 does not have multidex support
I/MultiDex( 4514): Installing application
I/MultiDex( 4514): MultiDexExtractor(/data/app/pkg_name-1.apk, /data/data/pkg_name/code_cache/secondary-dexes)
I/MultiDex( 4514): Blocking on lock /data/data/pkg_name/code_cache/secondary-dexes/MultiDex.lock
I/MultiDex( 4514): /data/data/pkg_name/code_cache/secondary-dexes/MultiDex.lock locked
I/MultiDex( 4514): MultiDexExtractor.load(/data/app/pkg_name-1.apk, false, )
I/MultiDex( 4514): Detected that extraction must be performed.
I/MultiDex( 4514): Extraction is needed for file /data/data/pkg_name/code_cache/secondary-dexes/pkg_name-1.apk.classes2.zip
I/MultiDex( 4514): Extracting /data/data/pkg_name/code_cache/secondary-dexes/tmp-pkg_name-1.apk.classes1353338101.zip
08-01
I/MultiDex( 4514): Renaming to /data/data/pkg_name/code_cache/secondary-dexes/pkg_name-1.apk.classes2.zip
I/MultiDex( 4514): Extraction succeeded '/data/data//pkg_name/code_cache/secondary-dexes//pkg_name-1.apk.classes2.zip': length 3303095 - crc: 3802116964
I/MultiDex( 4514): Extraction is needed for file /data/data//pkg_name/code_cache/secondary-dexes//pkg_name-1.apk.classes3.zip
I/MultiDex( 4514): Renaming to /data/data/pkg_name/code_cache/secondary-dexes/pkg_name-1.apk.classes3.zip
I/MultiDex( 4514): Extraction succeeded '/data/data/pkg_name/code_cache/secondary-dexes/pkg_name-1.apk.classes3.zip': length 1904964 - crc: 3374652227
I/MultiDex( 4514): load found 2 secondary dex files
W/MultiDex( 4514): Failed to install extracted secondary dex files, retrying with forced extraction
W/MultiDex( 4514): java.io.IOException: unable to open DEX file
W/MultiDex( 4514): at dalvik.system.DexFile.openDexFile(Native Method)
W/MultiDex( 4514): at dalvik.system.DexFile.<init>(DexFile.java:109)
W/MultiDex( 4514): at dalvik.system.DexFile.loadDex(DexFile.java:149)
W/MultiDex( 4514): at android.support.multidex.b$a.a(MultiDex.java:700)
W/MultiDex( 4514): at android.support.multidex.b$a.a(MultiDex.java:660)
W/MultiDex( 4514): at android.support.multidex.b.a(MultiDex.java:349)
W/MultiDex( 4514): at android.support.multidex.b.a(MultiDex.java:263)
W/MultiDex( 4514): at android.support.multidex.b.a(MultiDex.java:112)
W/MultiDex( 4514): at pkg_name.baselib.base.BaseApplication.attachBaseContext(BaseApplication.java:59)
提取apk次要dexes成功,但是installSecondaryDexes失败
我尝试
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
try {
MultiDex.install(this);
} catch(Exception e) {
e.printStackTrace();
}
}
但也失败了,非常感谢任何帮助。
答案 0 :(得分:1)
修改您的“ build.gradle”
android {
compileSdkVersion 22
buildToolsVersion "23.0.0"
defaultConfig {
minSdkVersion 14 //lower than 14 doesn't support multidex
targetSdkVersion 22
// Enabling multidex support.
multiDexEnabled true
}
}
dependencies {
compile 'com.android.support:multidex:1.0.3'
}
答案 1 :(得分:0)
请参阅以下日志:
I/MultiDex( 4514): VM with version 1.6.0 does not have multidex support
I/MultiDex( 4514): Installing application
I/MultiDex( 4514): MultiDexExtractor(/data/app/pkg_name-1.apk, /data/data/pkg_name/code_cache/secondary-dexes)
I/MultiDex( 4514): Blocking on lock /data/data/pkg_name/code_cache/secondary-dexes/MultiDex.lock
I/MultiDex( 4514): /data/data/pkg_name/code_cache/secondary-dexes/MultiDex.lock locked
I/MultiDex( 4514): MultiDexExtractor.load(/data/app/pkg_name-1.apk, false, )
I/MultiDex( 4514): Detected that extraction must be performed.
尝试完全卸载应用程序,并确保路径/data/data/pkg_name
不存在,然后重新安装应用程序。