It’s been a while since I originally posted this, at the time I ended up removing some libraries that were replaced with others, and that took me back under the method limit. I’m now back at this problem, my issue is that I don’t know enough about the build process to know how to modify that build.xml file to use multi dexing.
I followed the link in @davepayne’s post, which led me here: https://github.com/ruboto/ruboto-irb/blob/master/build.xml
I tried modifying my own build.xml using that which gives me this:
\<?xml version="1.0" encoding="UTF-8"?\> \<project name="MyGame" default="help"\> \<property file="local.properties" /\> \<property file="ant.properties" /\> \<loadproperties srcFile="project.properties" /\> \<!-- quick check on sdk.dir --\> \<fail message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through an env var" unless="sdk.dir" /\> \<import file="custom\_rules.xml" optional="true" /\> \<!-- version-tag: custom --\> \<import file="${sdk.dir}/tools/ant/build.xml" /\> \<!-- allow building with debug cert this is only used if ant debug is used in build.sh instead of ant release --\> \<target name="-set-debug-mode" depends="-setup"\> \<!-- record the current build target --\> \<property name="build.target" value="debug" /\> \<if\> \<condition\> \<and\> \<istrue value="${project.is.testapp}" /\> \<istrue value="${emma.enabled}" /\> \</and\> \</condition\> \<then\> \<property name="build.is.instrumented" value="true" /\> \</then\> \<else\> \<property name="build.is.instrumented" value="false" /\> \</else\> \</if\> \<!-- whether the build is a debug build. always set. --\> \<property name="build.is.packaging.debug" value="true" /\> \<!-- signing mode: debug --\> \<property name="build.is.signing.debug" value="false" /\> \<!-- Renderscript optimization level: none --\> \<property name="renderscript.opt.level" value="${renderscript.debug.opt.level}" /\> \</target\> \<!-- BEGIN added multidex stuff --\> \<property name="second\_dex\_file" value="${out.absolute.dir}/classes2.dex" /\> \<macrodef name="multi-dex-helper"\> \<element name="external-libs" optional="yes" /\> \<sequential\> \<union id="out.dex.jar.input.ref.union"\> \<resources refid="out.dex.jar.input.ref"/\> \</union\> \<if\> \<condition\> \<uptodate targetfile="${out.absolute.dir}/classes.dex" \> \<srcfiles dir="${out.classes.absolute.dir}" includes="\*\*/\*.class"/\> \<srcresources refid="out.dex.jar.input.ref.union"/\> \</uptodate\> \</condition\> \<then\> \<echo\>Java classes and jars are unchanged.\</echo\> \</then\> \<else\> \<echo\>Converting compiled files and external libraries into ${out.absolute.dir} (multi-dex)\</echo\> \<delete file="${out.absolute.dir}/classes2.dex"/\> \<echo\>Dexing ${out.classes.absolute.dir} and ${toString:out.dex.jar.input.ref}\</echo\> \<apply executable="${dx}" failonerror="true" parallel="true"\> \<arg value="--dex" /\> \<arg value="--multi-dex" /\> \<arg value="--output=${out.absolute.dir}" /\> \<arg line="${jumbo.option}" /\> \<arg line="${verbose.option}" /\> \<arg path="${out.classes.absolute.dir}" /\> \<path refid="out.dex.jar.input.ref" /\> \<external-libs /\> \</apply\> \<sleep seconds="1"/\> \</else\> \</if\> \</sequential\> \</macrodef\> \<macrodef name="dex-helper"\> \<element name="external-libs" optional="yes" /\> \<attribute name="nolocals" default="false" /\> \<sequential\> \<!-- sets the primary input for dex. If a pre-dex task sets it to something else this has no effect --\> \<property name="out.dex.input.absolute.dir" value="${out.classes.absolute.dir}" /\> \<!-- set the secondary dx input: the project (and library) jar files If a pre-dex task sets it to something else this has no effect --\> \<if\> \<condition\> \<isreference refid="out.dex.jar.input.ref" /\> \</condition\> \<else\> \<path id="out.dex.jar.input.ref"\> \<path refid="project.all.jars.path" /\> \</path\> \</else\> \</if\> \<condition property="verbose.option" value="--verbose" else=""\> \<istrue value="${verbose}" /\> \</condition\> \<condition property="jumbo.option" value="--force-jumbo" else=""\> \<istrue value="${dex.force.jumbo}" /\> \</condition\> \<if\> \<condition\> \<not\> \<available file="${second\_dex\_file}" /\> \</not\> \</condition\> \<then\> \<!-- Regular DEX process. We would prefer to use the Android SDK ANT target, but we need to detect the "use multidex" error. https://android.googlesource.com/platform/sdk/+/tools\_r21.1/anttasks/src/com/android/ant/DexExecTask.java --\> \<mapper id="pre-dex-mapper" type="glob" from="libs/\*.jar" to="bin/dexedLibs/\*-dexed.jar"/\> \<!-- FIXME(uwe): Output something about what we are doing --\> \<apply executable="${dx}" failonerror="true" parallel="false" dest="${out.dexed.absolute.dir}" relative="true"\> \<arg value="--dex" /\> \<arg value="--output" /\> \<targetfile/\> \<arg line="${jumbo.option}" /\> \<arg line="${verbose.option}" /\> \<fileset dir="." includes="libs/\*" /\> \<external-libs /\> \<mapper refid="pre-dex-mapper"/\> \</apply\> \<apply executable="${dx}" resultproperty="dex.merge.result" outputproperty="dex.merge.output" parallel="true"\> \<arg value="--dex" /\> \<arg value="--output=${intermediate.dex.file}" /\> \<arg line="${jumbo.option}" /\> \<arg line="${verbose.option}" /\> \<arg path="${out.classes.absolute.dir}" /\> \<fileset dir="${out.dexed.absolute.dir}" includes="\*-dexed.jar" /\> \<external-libs /\> \</apply\> \<if\> \<condition\> \<contains string="${dex.merge.output}" substring="method ID not in [0, 0xffff]: 65536"/\> \</condition\> \<then\> \<echo message="The package contains too many methods. Switching to multi-dex build." /\> \<multi-dex-helper\> \<external-libs\> \<external-libs/\> \</external-libs\> \</multi-dex-helper\> \</then\> \<else\> \<echo message="${dex.merge.output}"/\> \<fail status="${dex.merge.result}"\> \<condition\> \<not\> \<equals arg1="${dex.merge.result}" arg2="0"/\> \</not\> \</condition\> \</fail\> \</else\> \</if\> \</then\> \<else\> \<multi-dex-helper\> \<external-libs\> \<external-libs/\> \</external-libs\> \</multi-dex-helper\> \</else\> \</if\> \</sequential\> \</macrodef\> \<target name="-package" depends="-dex, -package-resources, -post-package-resources"\> \<!-- only package apk if \*not\* a library project --\> \<do-only-if-not-library elseText="Library project: do not package apk..." \> \<if condition="${build.is.instrumented}"\> \<then\> \<package-helper\> \<extra-jars\> \<!-- Injected from external file --\> \<jarfile path="${emma.dir}/emma\_device.jar" /\> \</extra-jars\> \</package-helper\> \</then\> \<else\> \<package-helper /\> \</else\> \</if\> \</do-only-if-not-library\> \</target\> \<target name="-post-package-resources"\> \<!-- FIXME(uwe): This is hardcoded for one extra dex file. It should iterate over all classes?.dex files --\> \<property name="second\_dex\_path" value="assets/classes2.jar" /\> \<property name="second\_dex\_jar" value="${out.dexed.absolute.dir}/${second\_dex\_path}" /\> \<property name="second\_dex\_copy" value="${out.dexed.absolute.dir}/classes.dex" /\> \<if\> \<condition\> \<and\> \<available file="${second\_dex\_file}" /\> \<or\> \<not\> \<uptodate srcfile="${second\_dex\_file}" targetfile="${out.absolute.dir}/${resource.package.file.name}" /\> \</not\> \<uptodate srcfile="${out.absolute.dir}/${resource.package.file.name}" targetfile="${out.absolute.dir}/${resource.package.file.name}.d" /\> \</or\> \</and\> \</condition\> \<then\> \<echo\>Adding ${second\_dex\_path} to ${resource.package.file.name}\</echo\> \<exec executable="aapt" dir="${out.dexed.absolute.dir}"\> \<arg line='remove -v "${out.absolute.dir}/${resource.package.file.name}" ${second\_dex\_path}'/\> \</exec\> \<copy file="${second\_dex\_file}" tofile="${second\_dex\_copy}"/\> \<mkdir dir="${out.dexed.absolute.dir}/assets"/\> \<zip destfile="${second\_dex\_jar}" basedir="${out.dexed.absolute.dir}" includes="classes.dex" /\> \<delete file="${second\_dex\_copy}"/\> \<!-- FIXME(uwe): Use zip instead of aapt? --\> \<exec executable="aapt" dir="${out.dexed.absolute.dir}" failonerror="true"\> \<arg line='add -v "${out.absolute.dir}/${resource.package.file.name}" ${second\_dex\_path}'/\> \</exec\> \<!-- EMXIF --\> \</then\> \</if\> \</target\> \<!-- END multidex stuff --\> \<!-- Run the "Corona Builder" in the pre-build step. --\> \<target name="-pre-build"\> \<mkdir dir="${basedir}/assets" /\> \<exec executable="${CoronaEnterpriseDir}/Corona/mac/bin/lua" failonerror="true"\> \<arg value="-e" /\> \<arg value="package.path='${CoronaEnterpriseDir}/Corona/shared/bin/?.lua;${CoronaEnterpriseDir}/Corona/shared/bin/?/init.lua;'..package.path" /\> \<arg value="${CoronaEnterpriseDir}/Corona/shared/bin/Compile.lua" /\> \<arg value="mac" /\> \<arg value="${CoronaEnterpriseDir}" /\> \<env key="LUA\_CPATH" value="${CoronaEnterpriseDir}/Corona/mac/bin/?.so"/\> \<env key="TARGET\_PLATFORM" value="android"/\> \<env key="PROJECT\_DIR" value="${basedir}"/\> \<env key="CORONA\_COPY\_PNG\_PRESERVE" value="--preserve"/\> \<env key="CONFIGURATION" value="${ant.project.invoked-targets}"/\> \<env key="CORONA\_ASSETS\_DIR" value="${basedir}/../Corona"/\> \<env key="CORONA\_TARGET\_RESOURCES\_DIR" value="${basedir}/assets"/\> \<env key="CORONA\_TARGET\_EXECUTABLE\_DIR" value="${basedir}/assets"/\> \<env key="BUNDLE\_ID" value="com.mycompany.templateapp"/\> \</exec\> \</target\> \<!-- This certifies the built APK before digitally signing it. --\> \<target name="-post-package"\> \<exec executable="${CoronaEnterpriseDir}/Corona/mac/bin/CertifyBuild.sh" failonerror="true"\> \<env key="CORONA\_APK\_PATH" value="${out.packaged.file}"/\> \<env key="CORONA\_RESOURCE\_CAR\_PATH" value="${basedir}/assets"/\> \</exec\> \</target\> \</project\>
It seemed to build ok, but when I installed and tried to open on my device I get this error:
06-12 14:23:47.166: E/AndroidRuntime(9662): FATAL EXCEPTION: main 06-12 14:23:47.166: E/AndroidRuntime(9662): Process: com.quiztix.mygame, PID: 9662 06-12 14:23:47.166: E/AndroidRuntime(9662): java.lang.RuntimeException: Unable to get provider com.ansca.corona.storage.FileContentProvider: java.lang.ClassNotFoundException: Didn't find class "com.ansca.corona.storage.FileContentProvider" on path: DexPathList[[zip file "/data/app/com.quiztix.mygame-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.quiztix.mygame-1, /vendor/lib, /system/lib]] 06-12 14:23:47.166: E/AndroidRuntime(9662): at android.app.ActivityThread.installProvider(ActivityThread.java:5056) 06-12 14:23:47.166: E/AndroidRuntime(9662): at android.app.ActivityThread.installContentProviders(ActivityThread.java:4648) 06-12 14:23:47.166: E/AndroidRuntime(9662): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4562) 06-12 14:23:47.166: E/AndroidRuntime(9662): at android.app.ActivityThread.access$1600(ActivityThread.java:161) 06-12 14:23:47.166: E/AndroidRuntime(9662): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1325) 06-12 14:23:47.166: E/AndroidRuntime(9662): at android.os.Handler.dispatchMessage(Handler.java:102) 06-12 14:23:47.166: E/AndroidRuntime(9662): at android.os.Looper.loop(Looper.java:157) 06-12 14:23:47.166: E/AndroidRuntime(9662): at android.app.ActivityThread.main(ActivityThread.java:5356) 06-12 14:23:47.166: E/AndroidRuntime(9662): at java.lang.reflect.Method.invokeNative(Native Method) 06-12 14:23:47.166: E/AndroidRuntime(9662): at java.lang.reflect.Method.invoke(Method.java:515) 06-12 14:23:47.166: E/AndroidRuntime(9662): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265) 06-12 14:23:47.166: E/AndroidRuntime(9662): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081) 06-12 14:23:47.166: E/AndroidRuntime(9662): at dalvik.system.NativeStart.main(Native Method) 06-12 14:23:47.166: E/AndroidRuntime(9662): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.ansca.corona.storage.FileContentProvider" on path: DexPathList[[zip file "/data/app/com.quiztix.mygame-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.quiztix.mygame-1, /vendor/lib, /system/lib]] 06-12 14:23:47.166: E/AndroidRuntime(9662): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:67) 06-12 14:23:47.166: E/AndroidRuntime(9662): at java.lang.ClassLoader.loadClass(ClassLoader.java:497) 06-12 14:23:47.166: E/AndroidRuntime(9662): at java.lang.ClassLoader.loadClass(ClassLoader.java:457) 06-12 14:23:47.166: E/AndroidRuntime(9662): at android.app.ActivityThread.installProvider(ActivityThread.java:5041) 06-12 14:23:47.166: E/AndroidRuntime(9662): ... 12 more 06-12 14:23:47.186: W/ActivityManager(821): Force finishing activity com.quiztix.mygame/com.ansca.corona.CoronaActivity
Is anyone able to give a foolproof guide on how to get it up and running?