Search code examples
javaandroidglobal-variablesandroid-manifest

MultiDexApplication and global class in the manifest xml


My problem is that I have a global class, that have information about my app and I show in other activities,

my AndroidManifest.xml was like this...

<application
    android:name=".Global"      <-------- global class
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/nobar">
 .
 .
</application>

but i have errors java.lang.OutOfMemoryError: GC overhead limit exceeded and 65k limit in dex and i need to change it to...

<application
    android:name="android.support.multidex.MultiDexApplication" <--- changed
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/nobar">
 .
 .
</application>

this is my build.gradle

apply plugin: 'com.android.application'

android {

    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
    }

    compileSdkVersion 24
    buildToolsVersion "24.0.0"
    defaultConfig {
        applicationId "com.xx.xx"
        minSdkVersion 16
        targetSdkVersion 24
        versionCode 25
        versionName "1.0"
        // Enabling multidex support.
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            signingConfig signingConfigs.xx
            debuggable false
        }
    }
    dexOptions {
        javaMaxHeapSize "4g"
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:24.1.1'
    compile 'com.google.android.gms:play-services:9.4.0'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.mcxiaoke.volley:library:1.0.19'
    compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'

}

but I need the global class to share information about activities...

or there is another way to do this thing??


Solution

  • Well I has a global class for my project, i did this example of global class

    Example of global class with android manifest

    My solution for my global class is this example..

    Android global variable