locked
Multiple issues with library project and multidex RRS feed

  • Question

  • User10127 posted

    In order to have multiple app sharing the same functionality I have moved all code to a separate library project but still have a doubt If I did everything correct and the issue with running app on devices which do not support multidex natively.

    So basically my questions are:

    • What is the proper location and build action for AndroidManifest.xml in library?
    • Is it enough to reference required libraries (say, Play Services, Facebook etc) only in this library and leave application references clear? The thing is it kind of works either way but if I don't reference say Xamarin.GooglePlayServices.Ads in application it won't build because of missing resource references.
    • Somehow enabling ProGuard doesn't help much, it decreases number from 88k to 84k only. Is there any other step required?
    • On devices which do not support multidex I'm getting an error

    ``` [AndroidRuntime] Caused by: java.lang.ClassNotFoundException: Didn't find class "TestApp" on path: /data/app/com.test-1.apk [AndroidRuntime] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:64) [AndroidRuntime] at java.lang.ClassLoader.loadClass(ClassLoader.java:501) [AndroidRuntime] at java.lang.ClassLoader.loadClass(ClassLoader.java:461) [AndroidRuntime] at android.app.Instrumentation.newApplication(Instrumentation.java:992) [AndroidRuntime] at android.app.LoadedApk.makeApplication(LoadedApk.java:504)

    and inspection of apk shows that MutiDexApplication is packaged to the second dex, when I assume it should present in the main dex as it is a base class for my application: \smali\com.test\TestApp.smali \smali_classes2\android\support\multidex\MultiDexApplication.smali ``` So if this is the issue then how to make Xamarin / Android SDK to properly allocate classes?

    Thursday, December 10, 2015 11:41 AM

All replies

  • User10127 posted

    For those who is interested there is a cross-tool issue on Windows. Build process generates an input which is not compatible with a script from android tools (which has its own issues on Windows) and as a result the list of classes selected to be moved to the first DEX stays empty.

    Saturday, January 16, 2016 4:46 AM
  • User10127 posted

    Here are changes I've done to \sdk\build-tools\23.0.x\mainDexClasses.bat:

    Also I've raised a ticket for Xamarin to fix at least first part of the issue: https://bugzilla.xamarin.com/show_bug.cgi?id=38693

    Thursday, February 11, 2016 8:06 PM
  • User53176 posted

    Hi MikhailMelnik,

    Could you share a copy of your mainDexClasses.bat with the changes?

    Thanks, Brad

    Tuesday, April 5, 2016 12:22 PM
  • User10127 posted

    Sure, here it is.

    Wednesday, April 6, 2016 4:43 AM