Multidex support for Android - settings?

Hi,
Is somone who play with multidex setting in VS Oxygene for Android ?
I reached 64 k limit and I want to set Multidex for my app.
I changed settings (Android MultiDex = true) and my Application Object hasn’t been created at all…
I have my own lib .jar and shared projects - should I set (Android MultiDex = true) for my lib ?
In my lib i have my base objects like activities, fragments , adapters … In my app I inherit from them ?
Have you got any directions in this topic ?
Main activity and Application object hasn’t been run properly :frowning: without multidex all works fine…
I did simple example (without MultiDex it is working - with Multidex it is not working)
As you can see class is not found (app) - what should I do more ???


Here is interesting part of output window :
LogCat: 01-09 18:56:07.181 23444 23444 E AndroidRuntime: java.lang.RuntimeException: Unable to instantiate application org.me.androidapplication1.app: java.lang.ClassNotFoundException: Didn’t find class “org.me.androidapplication1.app” on path: DexPathList[[zip file “/data/app/org.me.androidapplication1-2/base.apk”],nativeLibraryDirectories=[/data/app/org.me.androidapplication1-2/lib/arm, /vendor/lib, /system/lib]]
LogCat: 01-09 18:56:07.181 23444 23444 E AndroidRuntime: at android.app.LoadedApk.makeApplication(LoadedApk.java:578)
LogCat: 01-09 18:56:07.181 23444 23444 E AndroidRuntime: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4680)
LogCat: 01-09 18:56:07.181 23444 23444 E AndroidRuntime: at android.app.ActivityThread.-wrap1(ActivityThread.java)
LogCat: 01-09 18:56:07.181 23444 23444 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
LogCat: 01-09 18:56:07.181 23444 23444 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
LogCat: 01-09 18:56:07.181 23444 23444 E AndroidRuntime: at android.os.Looper.loop(Looper.java:148)
LogCat: 01-09 18:56:07.181 23444 23444 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5417)
LogCat: 01-09 18:56:07.181 23444 23444 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
LogCat: 01-09 18:56:07.181 23444 23444 E AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
LogCat: 01-09 18:56:07.181 23444 23444 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
LogCat: 01-09 18:56:07.181 23444 23444 E AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn’t find class “org.me.androidapplication1.app” on path: DexPathList[[zip file “/data/app/org.me.androidapplication1-2/base.apk”],nativeLibraryDirectories=[/data/app/org.me.androidapplication1-2/lib/arm, /vendor/lib, /system/lib]]
LogCat: 01-09 18:56:07.181 23444 23444 E AndroidRuntime: at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
LogCat: 01-09 18:56:07.181 23444 23444 E AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
LogCat: 01-09 18:56:07.181 23444 23444 E AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
LogCat: 01-09 18:56:07.181 23444 23444 E AndroidRuntime: at android.app.Instrumentation.newApplication(Instrumentation.java:981)
LogCat: 01-09 18:56:07.181 23444 23444 E AndroidRuntime: at android.app.LoadedApk.makeApplication(LoadedApk.java:573)
LogCat: 01-09 18:56:07.181 23444 23444 E AndroidRuntime: … 9 more
LogCat: 01-09 18:56:07.181 23444 23444 E AndroidRuntime: Suppressed: java.io.IOException: No original dex files found for dex location /data/app/org.me.androidapplication1-2/base.apk
LogCat: 01-09 18:56:07.181 23444 23444 E AndroidRuntime: at dalvik.system.DexFile.openDexFileNative(Native Method)
LogCat: 01-09 18:56:07.181 23444 23444 E AndroidRuntime: at dalvik.system.DexFile.openDexFile(DexFile.java:295)
LogCat: 01-09 18:56:07.181 23444 23444 E AndroidRuntime: at dalvik.system.DexFile.(DexFile.java:80)
LogCat: 01-09 18:56:07.181 23444 23444 E AndroidRuntime: at dalvik.system.DexFile.(DexFile.java:59)
LogCat: 01-09 18:56:07.181 23444 23444 E AndroidRuntime: at dalvik.system.DexPathList.loadDexFile(DexPathList.java:279)
LogCat: 01-09 18:56:07.181 23444 23444 E AndroidRuntime: at dalvik.system.DexPathList.makePathElements(DexPathList.java:248)
LogCat: 01-09 18:56:07.181 23444 23444 E AndroidRuntime: at dalvik.system.DexPathList.(DexPathList.java:120)
LogCat: 01-09 18:56:07.181 23444 23444 E AndroidRuntime: at dalvik.system.BaseDexClassLoader.(BaseDexClassLoader.java:48)
LogCat: 01-09 18:56:07.181 23444 23444 E AndroidRuntime: at dalvik.system.PathClassLoader.(PathClassLoader.java:65)
LogCat: 01-09 18:56:07.181 23444 23444 E AndroidRuntime: at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:58)
LogCat: 01-09 18:56:07.181 23444 23444 E AndroidRuntime: at android.app.LoadedApk.getClassLoader(LoadedApk.java:376)
LogCat: 01-09 18:56:07.181 23444 23444 E AndroidRuntime: at android.app.LoadedApk.makeApplication(LoadedApk.java:568)
LogCat: 01-09 18:56:07.181 23444 23444 E AndroidRuntime: … 9 more
LogCat: 01-09 18:56:07.181 23444 23444 E AndroidRuntime: Suppressed: java.lang.ClassNotFoundException: org.me.androidapplication1.app
LogCat: 01-09 18:56:07.181 23444 23444 E AndroidRuntime: at java.lang.Class.classForName(Native Method)
LogCat: 01-09 18:56:07.181 23444 23444 E AndroidRuntime: at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
LogCat: 01-09 18:56:07.181 23444 23444 E AndroidRuntime: at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
LogCat: 01-09 18:56:07.181 23444 23444 E AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
LogCat: 01-09 18:56:07.181 23444 23444 E AndroidRuntime: … 12 more
LogCat: 01-09 18:56:07.181 23444 23444 E AndroidRuntime: Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
LogCat: 01-09 18:56:07.183 775 1864 W ActivityManager: Force finishing activity org.me.androidapplication1/.MainActivity

Here is the code :slight_smile:
multidex.7z (56.5 KB)

I’m using latest official version.

How to add multiDexEnabled in our gradle script ??
Can I configure in Remobjects some other parameters used by dex (for example --main-dex-list) ?
Where can I change it to inform dex about my main class ?

Mateusz

1 Like

What version of Elements are you using, v9 for v10? could you. by any chance try the v10 preview, inside Water and with the new EBuild tool chain enabled?

Latest official 9.
10 not yet :slight_smile: I’m working on it.
I have to replace sugar by rtl:)
I need some time…
Mateusz

Ah ok. that makes diagnosing a bit trickier, as we did rework all of threse tool chains for v10/EBuild. That said, Multi-Dex should work fine in v9 as well, of course…

Marc, Is this example from attachment is working in your 9 Elements environment with multidex?

My colleague who is looking into this tells me the sample works in non-MultiDex for her, yes. We’re investigating…

In non multidex all is working fine but in multidex it is not working for me;) this simple project and my application too…
Thank you :smile:

What about File|New Project, unchanged, except to turn on MultiDex. does that work, or fail too, for you?

Mateusz, I can’t install your project on the device at all, I’m getting

---------------------------
Error
---------------------------
Failed to install, output:

adb: failed to install E:\RemObjects\Support\Android multidex\multidex\org.me.multidex\org.me.androidapplication1\bin\Debug\org.me.androidapplication1.apk: Failure [INSTALL_FAILED_INVALID_APK: Package couldn’t be installed in /data/app/org.me.androidapplication1-1: Package /data/app/org.me.androidapplication1-1/base.apk code is missing]

With or without Multidex set. But with other simple project - Multidex property doesn’t affect it…
So, I just can’t get to the error in your project.

Unrelated question (and pardon my ignorance), what is the call to

android.support.multidex.MultiDex.install(self);

for?

as far as I understand, multi-dex is simply a build-time change in how the dex file(s) get processed. What does this API do? Another thing I notice is that you’re DexMode is set to Incremental. IIRC Incremental and Multidex are mutually exclusive. Can you try turning the mode to None or Predex?

Thanks, logged as bugs://79366

Mateusz, I reproduced project start failing, with dependence of Multidex property and logged an issue. Thanks for the report!

Ok. Thank you !

Marc I have read about multidex here :
https://developer.android.com/studio/build/multidex.html
As I understood I need special type of Application (android.support.multidex.MultiDexApplication or standard Application supporting MultiDex - I have to override attachBaseContext and run MultiDex.install(this) )

I haven’t tried with None or Predex.
Mateusz

Any information about this bug ?

yes. it’s fixed in today’s beta.

bugs://79366 got closed with status fixed.

yeeaaah :slight_smile: Thank you Carlo :slight_smile:

1 Like