2

硬件信息

    phone: Huawei Mate 7(MT7-TL10)
    OS: Android 4.4.2
    CPU: Kirin925

构建.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();
     }
}

但也失败了,非常感谢任何帮助。

4

2 回答 2

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'
     }
于 2018-08-03T04:29:50.767 回答
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已消失并重新安装您的应用程序。

于 2018-12-10T05:36:11.243 回答