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
>
>

Reply via email to