Android Multidex RuntimeException

醉酒当歌 提交于 2019-12-01 17:50:33

Try this, this is working for me, pretty much copied from a current project....

build.gradle

android {
compileSdkVersion 23
buildToolsVersion "22.0.1"
defaultConfig {
    applicationId "my.package.name"
    minSdkVersion 16
    targetSdkVersion 23
    multiDexEnabled = true
    versionCode 3
    versionName "0.1.2"
    renderscriptTargetApi 14
    renderscriptSupportModeEnabled true
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:multidex:1.0.1'
}

Application Class

public class MyApp extends MultiDexApplication {

    @Override
    public void onCreate() {
        super.onCreate();
    }
}

Manifest

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

...

   <application
    android:name=".MyApp"
    android:allowBackup="true"
    android:hardwareAccelerated="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >

...

It is worth noting that I had a similar issue until i added the READ permission and extends MultiDexApplication

Problem is because of this obfuscator:

    <dependency>
        <groupId>net.java.truelicense</groupId>
        <artifactId>truelicense-obfuscate</artifactId>
        <version>${truelicense.obfuscate.version}</version>
    </dependency>

After 3 days its solved by removing one of dependencies which caused it.

EDIT: As @Asprelis pointed out, the lib which was causing problems is net.java.truelicense

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!