17

I'm getting the following error.

FATAL EXCEPTION: main

  • VM with version 2.1.0 has multidex support
  • install
  • VM has multidex support, MultiDex support library is disabled.
  • install
  • VM has multidex support, MultiDex support library is disabled.
  • Shutting down VM

here is my build.gradle,i have enables the multidex in the android part,

apply plugin: 'com.android.application'


android {
compileSdkVersion 23
buildToolsVersion '23.0.0'

defaultConfig {
    applicationId "com.mycompany.newlogin"
    minSdkVersion 15
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"
    multiDexEnabled true
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
productFlavors {

}
useLibrary 'org.apache.http.legacy'
}



dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:multidex:1.0.0'
compile 'com.google.guava:guava-jdk5:17.0'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
//compile 'org.apache.httpcomponents:httpcore:4.4.1'
compile 'org.apache.httpcomponents:httpclient:4.5'
compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'

}

and my manifest file is

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mycompany.newlogin" >
<uses-permission android:name="android.permission.INTERNET"/>


<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme"
    android:name="android.support.multidex.MultiDexApplication">
    <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>
    <activity
        android:name=".Login"
        android:label="@string/title_activity_login" >
    </activity>
    <activity
        android:name=".Register"
        android:label="@string/title_activity_register" >
    </activity>
</application>
</manifest>
Cœur
  • 37,241
  • 25
  • 195
  • 267
Anil
  • 1,748
  • 8
  • 32
  • 67
  • do you have a class extending from Application? – Baniares Oct 25 '15 at 05:59
  • 1
    I have class MainActivity that extends AppCompactActivity – Anil Oct 25 '15 at 06:15
  • 2
    From the docs: This library provides compatibility for platforms with API level 4 through 20. This library does nothing on newer versions of the platform which provide built-in support for secondary dex files. I checked their code on [grepcode](http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/5.0.2_r1/android/support/multidex/MultiDex.java) – Ankit Aggarwal Aug 14 '16 at 10:45

2 Answers2

4

create a class lets name it App and extend from MultiDexApplication like this:

import android.support.multidex.MultiDexApplication;

public class App extends MultiDexApplication {
    //you can leave this empty or override methods if you like so the thing is that you need to extend from MultiDexApplication
}

in your manifest add App as your application name just like this

<application
        android:name=".App" // <<< this is the important line!
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name">

After adding everything make a clean build and it should work now :).

Baniares
  • 525
  • 1
  • 3
  • 9
  • I have uploaded my manifest file,please take a look and help me to where to add your in my manifest file – Anil Oct 25 '15 at 07:06
  • 2
    `android:name="android.support.multidex.MultiDexApplication"` -> Replace this with your custom class. – kientux Oct 25 '15 at 07:44
  • Hi Baniares and Kientux thank you guys for the help. iam getting some null point exception error but dont know why?So help me to resolver this. – Anil Oct 27 '15 at 10:05
  • 6
    dude, I think this is not an error , The vm has already have the support of multidex that is why they are disabling , try to check the log in below 5.0. I guess the the ART vm have already have the multidex support – Bytecode Jun 18 '16 at 23:02
1

Override attachBaseContext method in your application class

@Override
protected void attachBaseContext(Context base) {
  super.attachBaseContext(base);
  MultiDex.install(this);
}
user3875399
  • 69
  • 2
  • 1