Android Multidex Support Library Disabled

I had some problem with multidex support in my application, actually the application installs fine, but through this process some activities crashed and the application resumed the main activity. In logcat I found this:

I/MultiDex: install
I/MultiDex: VM has multidex support, MultiDex support library is disabled.

      

But I followed the recommendations for Multidex support:

Gradle:

compileSdkVersion 25
buildToolsVersion '25.0.2'

defaultConfig {
    applicationId "com..company.package"
    minSdkVersion 15
    targetSdkVersion 25
    multiDexEnabled true
    versionCode 21
    versionName "2.1.3"

}

dexOptions {
    javaMaxHeapSize "4g"
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
//compile project(':rangebar')
compile('com.github.afollestad.material-dialogs:core:0.8.5.3@aar') { transitive = true }
compile('com.weiwangcn.betterspinner:library-material:1.1.0') {
    exclude group: 'com.android.support', module: 'appcompat-v7'
}
compile files('libs/itextpdf-5.5.9.jar')
compile 'com.android.support:multidex:1.0.1'
...

      

Application class extends Multidex:

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

      

I don't know what I am missing to get rid of this question.

Thanks in advance.

+3


source to share


2 answers


I / MultiDex: install I / MultiDex: VM supports multidex, MultiDex support library is disabled.

You must install

public class MyApplication extends Application {

      



manifesto

<application
    android:name=".MyApplication"
   ....>

      

Then Clean-Rebuild-Run .

+3


source


But also add to the answer above ^

Android documentation says that if you have minSdkVersion 21 or higher, you don't need the multidex support library. So I understand why you did it there https://developer.android.com/studio/build/multidex.html#mdex-on-l

The options you have are given below: https://developer.android.com/studio/build/multidex.html#mdex-gradle

Option 1) If you are not overriding the Application class, edit your manifest file to set the android: name in the tag as follows: This will be your entry: android.support.multidex.MultiDexApplication

<manifest 
    xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myapp">
    <application
            android:name="android.support.multidex.MultiDexApplication" >
            android:allowBackup="true"
            android:icon="@mipmap/ic_launcher"
            android:label="@string/app_name"
            android:theme="@style/AppTheme">
            <activity
                    android:name=".MainActivity"
                    android:label="@string/app_name">
                <intent-filter>
                    <action android:name="android.intent.action.MAIN"/>
                    <category android:name="android.intent.category.LAUNCHER"/>
                </intent-filter>
            </activity>
    </application>
</manifest>

      



Option 2) . If you override the Application class, modify it to extend MultiDexApplication (if possible) as follows:

public class MyApplication extends MultiDexApplication { ... }

      

Option 3) . If you override the application class but cannot change the base class, you can instead override the attachBaseContext () method and call MultiDex.install (this) to enable multidex: You add below code without extending MultiDexApplication

public class MyApplication extends **SomeOtherApplication** {

  //You add the code below without extending **MultiDexApplication**
  @Override
  protected void attachBaseContext(Context base) {
     super.attachBaseContext(base);
     MultiDex.install(this);
  }
}

      

Caveat: Do not execute MultiDex.install () or any other code through reflection or JNI until MultiDex.install () completes. Multidex tracing will not follow these calls, throwing a ClassNotFoundException or checking for errors due to an invalid section section between DEX files.

0


source







All Articles