3

Today i have a Error like these :

Error:The number of method references in a .dex file cannot exceed 64K.
Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html

I write in my build.gradle :

multiDexEnabled true

and

dependencies {
  compile 'com.android.support:multidex:1.0.1'
}

In my Manifest:

android:name="android.support.multidex.MultiDexApplication"

And in my main methode :

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

But yet i receive these error:

03-15 12:15:37.066 19676-19676/de.example E/AndroidRuntime: FATAL EXCEPTION: main
03-15 12:15:37.066 19676-19676/de.example E/AndroidRuntime: Process: de.imatics.mediplan, PID: 19676
03-15 12:15:37.066 19676-19676/de.example E/AndroidRuntime: java.lang.RuntimeException: Unable to resume activity {de.imatics.mediplan/de.example.MedicationScheduleActivity}: java.lang.NullPointerException
developKinberg
  • 363
  • 4
  • 18

4 Answers4

3

in build.gradle under android exclude meta info like

packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
    }

and also MultiDex.install(this); should be written in Application class that extends with Application class like

public class MyApp extends Application {

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }
}
IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198
arsalan
  • 41
  • 9
1

You'll need to add your Application class to the AndroidManifest instead of the MultiDexApplication class

 <application
            android:name="com.app.YourAppClass"
            android:icon="@drawable/icon"
            android:theme="@style/Theme"
            android:label="@string/app_name">
Miro
  • 97
  • 3
0
apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "de.imatics.mediplan"
        minSdkVersion 19
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    lintOptions {
        abortOnError false
    }
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    wearApp project(':wear')
    testCompile 'junit:junit:4.12'
    compile files('libs/Android-DDP.jar')
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.google.android.gms:play-services:8.4.0'
    compile 'com.android.support:design:23.1.1'
    compile 'com.android.support:multidex:1.0.1'
}
developKinberg
  • 363
  • 4
  • 18
0

I solve the problem , i impl. automatically a setting activity but these delete from my build.gradle some code that support meteor.. thanks god for github

developKinberg
  • 363
  • 4
  • 18