Closed redirect11 closed 10 years ago
The reason it's that the system can't find the class into dex files... But if i try to put android.support.multidex.MultiDexApplication in my Manifest, my app start without a problem, but i really need to load some roboguice modules in a custom application class... How can i solve this problem?
Hi @redirect11! You can try specify your classes on the file that contains the classes that always stay on main dex file. Did you tried this? https://github.com/casidiablo/multidex#whats-it-for-again. Basically you need to enable the main-dex-file option for dx, and add your application classes (the it.eng.mainapp.MainApplication and it's super class) on the main dex file.
Yes, i read that... this is my build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
defaultConfig {
minSdkVersion 11
targetSdkVersion 19
versionCode 5
versionName "0.9"
}
buildTypes {
debug {
debuggable true
runProguard false
//applicationIdSuffix ".debug"
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.txt'
}
release {
debuggable false
runProguard false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.txt'
}
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
dexOptions {
preDexLibraries = false
}
}
dependencies {
compile 'com.google.android:multidex:0.1'
compile fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
compile project(':Skeleton')
compile project(':Core')
compile project(':imageUpload')
// compile 'se.emilsjolander:android-flipview:1.1.0'
compile project(':library-slidingMenu')
compile project(':LoginAuthorization')
compile project(':WeatherDicet')
compile project(':AR')
compile project(':library-photoview')
compile 'com.viewpagerindicator:library:2.4.1@aar'
}
afterEvaluate {
tasks.matching {
it.name.startsWith('dex')
}.each { dx ->
if (dx.additionalParameters == null) {
dx.additionalParameters = []
}
dx.additionalParameters += '--multi-dex' // enable multidex
// optional
dx.additionalParameters += "--main-dex-list=$projectDir/class-list.txt".toString() // enable the main-dex-list
dx.additionalParameters += '--minimal-main-dex'
}
}
and this is my class-list.txt:
android/support/multidex/BuildConfig.class
android/support/multidex/MultiDex$V14.class
android/support/multidex/MultiDex$V19.class
android/support/multidex/MultiDex$V4.class
android/support/multidex/MultiDex.class
android/support/multidex/MultiDexApplication.class
android/support/multidex/MultiDexExtractor$1.class
android/support/multidex/MultiDexExtractor.class
android/support/multidex/ZipUtil$CentralDirectory.class
android/support/multidex/ZipUtil.class
Do you mean to put my application class in the file above?
Yes, exactly!
OK... Solved XD... Thanks Il 01/ott/2014 16:35 "Fernando Gonçalves" notifications@github.com ha scritto:
Yes, exactly!
— Reply to this email directly or view it on GitHub https://github.com/casidiablo/multidex/issues/7#issuecomment-57473568.
I'm having the same problem and I think I'm writing my application class path in a wrong way on the file.
Assuming the Application Class is it.eng.mainapp.MainApplication: should i write: it/eng/mainapp/MainApplication.class under android/support/multidex/ZipUtil.class ?
@dcampogiani yes. Keep in mind that even doing that, if MainApplication
tries to load a class that is not in the main APK, then it will still fail. What's the exact error message?
@casidiablo the problem was the same as @redirect11.
I solved this downloading the new support library release yesterday and new build tools (version 21), changed compileSdkVersion, buildToolsVersion and targetSdkVersion in build.gradle
In the application class I'm overriding attachBaseContext and in the onCreate I'me moved some initialization in a Runnable.
Even if i'm using compile 'com.android.support:support-v4:21.0.+' I need to add also compile 'com.google.android:multidex:0.1' in build.gradle, otherwise it won't find Multidex class.
I traied your method but, after a succesful build, Android give me a ClassNotFoundException:
I have multiple modules in my Android Project and MainApplication extends BaseApplication that it's defined into another module (Core) and that class extends MultiDexApplication.
All modules are "android-library" (Core module too) and my app it's in "mainapp" module.
All gradle related snippets for multi-dex are in gradle.build in mainapp module.
What could be the problem here?