2015-10-25 1 views
7

Je reçois l'erreur suivante.La VM a un support multidex, la bibliothèque de support MultiDex est désactivée

FATAL EXCEPTION: principale

  • VM avec la version 2.1.0 supporte multidex
  • installer
  • VM a un support multidex, bibliothèque de soutien MultiDex est désactivé.
  • install
  • La VM a un support multidex, la bibliothèque de support MultiDex est désactivée.
  • Arrêt VM

voici mon build.gradle, j'ai permet multidex dans la partie android,

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' 

} 

et mon fichier manifeste est

<?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> 
+0

avez-vous une classe allant de l'application? – Baniares

+1

J'ai la classe MainActivity qui étend AppCompactActivity – Anil

+1

Des docs: Cette bibliothèque fournit la compatibilité pour les plates-formes avec les niveaux d'API 4 à 20. Cette bibliothèque ne fait rien sur les versions plus récentes de la plate-forme qui prennent en charge les fichiers dex secondaires. J'ai vérifié leur code sur [grepcode] (http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/5.0.2_r1/android/support/multidex/MultiDex.java –

Répondre

2

créer un classe permet de le nommer App et d'étendre de MultiDexApplication comme ceci:

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 
} 

dans votre manifeste ajouter App comme nom de votre application comme ce

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

Après avoir ajouté tout faire une construction propre et il devrait fonctionner :).

+0

J'ai téléchargé mon fichier manifeste, s'il vous plaît jeter un oeil et m'aider à où ajouter votre dans mon fichier manifeste – Anil

+1

android: name = "android.support.multidex.MultiDexApplication" '-> Remplacer cela par votre classe personnalisée. – kientux

+0

Je l'ai fait mais il montre toujours la même erreur – Anil

1

Remplacer méthode attachBaseContext dans votre classe d'application

@Override 
protected void attachBaseContext(Context base) { 
    super.attachBaseContext(base); 
    MultiDex.install(this); 
} 
+0

Cela suppose qu'il existe une classe qui s'étend ** Application ** –