0

I am using android.support.multidex, and have faced with a problem( I get this error "Didn't find class "my.package.MyApplication" on path: DexPathList". MyApplication extends MyAbstractApplication, which is .aar in Maven repository and extends MultiDexApplication . And i override attachBaseContext(Context base) in MyApplication. What am i doing wrong? multidex.keep:

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

PS: If i use Maven *.aar like a submodule everything works fine. Thanks for help!

ADK
  • 513
  • 3
  • 8
  • 22
  • I am having the same issue as well.... But in my case, i am declaring the MultiDexApplication in the AndroidManifest.xml, if that helps someone clarify.. – Andrew Phillips Oct 22 '14 at 14:44
  • @AndrewPhillips If you will decide to add something extra into your Application, you will have an ClassCastException. – ADK Oct 24 '14 at 06:09
  • @AndrewPhillips Alex's solution works fine, but in additional you must to add into your --main-dex-list file all classes which uses in Application OnCreate method – ADK Oct 24 '14 at 06:12
  • you are correct, i realized the issue i was having as well. Mine was specifically that i had the multidex library in my path but was not including it in the APK. works fine now, sorry for the confusion. – Andrew Phillips Oct 24 '14 at 13:28

1 Answers1

2

As you subclassing the Application class, your derived classes should be present in main dex file.
Add them to your --main-dex-list file. As per your example:

my/package/MyApplication.class
my/package/MyAbstractApplication.class

Btw, to add MultiDex support you have to either extend MultiDexApplication or override attachBaseContext to call MultiDex.install. Doing both makes no sense.

Additionally, you can generate the main-dex-list file.

Alex Lipov
  • 13,503
  • 5
  • 64
  • 87