Multidex support for Android - settings?

oxygene

(Mateusz Gałązka) #1

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


(marc hoffman) #2

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?


(Mateusz Gałązka) #3

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


(marc hoffman) #4

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…


(Mateusz Gałązka) #5

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


(marc hoffman) #6

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


(Mateusz Gałązka) #7

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:


(marc hoffman) #8

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


(ekaterina) #9

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.


(marc hoffman) #10

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?


(RemObjects) #11

Thanks, logged as bugs://79366


(ekaterina) #12

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


(Mateusz Gałązka) #13

Ok. Thank you !


(Mateusz Gałązka) #14

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