Thanks for the info Andrew. I did confirm I was able to build with your plugin fine. It looks like that was a red herring on my end.
I¹ve pushed up a github repo showing the DEX issue. You should be able to clone it and run cordova commands. This does have the fix to generate the proper settings.gradle file. https://github.com/imaffett/gradle-dex-issue One thing to note - https://github.com/imaffett/gradle-dex-issue/blob/master/platforms/android/ org.apache.cordova.xapkreader/foobar-downloader_library/build-extras.gradle If I do not have compile in there, then I get reference errors trying to build. I think this is causing the DEX issue since the main build.gradle is building project(':org.apache.cordova.xapkreader:library¹) Thanks, Ian On 5/19/15, 8:05 PM, "Andrew Grieve" <agri...@chromium.org> wrote: >Hmm, I've written a couple of other plugins that don't suffer from >multiple >dex exceptions. I forget the first, but the second is: > >https://github.com/MobileChromeApps/cordova-plugin-background-app > >So, I think there might be something else going on besides the plugin's >lib >having a dependency on CordovaLib (this is what allows plugin library >projects to reference Cordova APIs) > >On Mon, May 18, 2015 at 9:18 AM, Maffett, Ian <ian.maff...@intel.com> >wrote: > >> I¹ve run into a few issues with Cordova CLI5, Android 4 and >> libraries/frameworks. I will try to explain below, but the issue >>appears >> to be related to the dependency section in build.gradle and each >>librarie¹s >> build.gradle file. >> >> We¹ve developed a plugin to enable expansion files on Android. It is >> dependent on three custom Android libraries, which declare in the >> plugin.xml file. >> >> <framework src="AndroidLibrary/GoogleExtras/play_licensing/library" >> custom="true" /> >> <framework >> src="AndroidLibrary/GoogleExtras/play_apk_expansion/downloader_library" >> custom="true"/> >> <framework src="AndroidLibrary/GoogleExtras/play_apk_expansion/zip_file" >> custom="true" />¹ >> >> >> The first problem we ran into we will be submitting a patch to fix. The >> issue is that the project¹s folder name was prepended to the path when >>it >> was created. We could not reference this in the build-extras.gradle due >>to >> the constant name change. Below is an example where my project¹s >>directory >> from cordova create is ³foobar" >> >> org.apache.cordova.xapkreader/foobar-library >> >> I spoke with Andrew Grieve via email and he recommend changing the >> build.js file in cordova-android to enable the following in creating the >> settings.gradle . We can now properly reference the library in a >> build-extras.gradle >> >> include ":org.apache.cordova.xapkreader:library" >> project(":org.apache.cordova.xapkreader:library").projectDir = new >> File("org.apache.cordova.xapkreader/foobar-library²) >> >> >> The second issue we are running into is bigger. Whenever we run a >>build, >> we get DEX errors. There are two specific cases we are running into. >>The >> first is for general Cordova errors, the second is specific to our >> AndroidLibrary/GoogleExtras/play_licensing/library . >> >> com.android.dex.DexException: Multiple dex files define >> >> I believe this is due to the following >> >> 1. The main build.gradle has dependencies to all the sub >> projects/libraries which get built >> 2. The libraries each have their own build.gradle which has a >> dependency on CordovaLib >> >> In the general case, it appears that with each library CordovaLib is >>being >> compiled into the jar and causes the error for DEX since it includes >> multiple definitions. If I open up Android studio and change each >> libraries build.gradle dependency to only have the following (the >>reference >> to CordovaLib was removed) >> >> >> dependencies { >> compile fileTree(dir: 'libs', include: '*.jar') >> } >> >> This removes the DEX errors for Cordova. The issue specific to our >> plugin is that I have to modify the main build.gradle dependency to >>remove >> the references for the following, which is a custom library we¹ve >>declared. >> >> >> debugCompile project(path: ":org.apache.cordova.xapkreader:library", >> configuration: "debug") >> releaseCompile project(path: ":org.apache.cordova.xapkreader:library", >> configuration: "release") >> >> Removing those references allows the >> AndroidLibrary/GoogleExtras/play_apk_expansion/downloader_library >> build-extras.gradle file to reference it and build successfully. >> >> dependencies { >> compile(project(':org.apache.cordova.xapkreader:library')) >> compile fileTree(dir: 'libs', include: '*.jar') >> } >> >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org >> For additional commands, e-mail: dev-h...@cordova.apache.org >> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org For additional commands, e-mail: dev-h...@cordova.apache.org