2 Replies Latest reply on Nov 10, 2016 4:02 AM by barryt35413213

    The android build fails with the "Multiple dex files define" error

    barryt35413213 Level 1

      My Android build fails on the build.phonegap.com with such log :

      .....

      > :CordovaLib:bundleRelease

      > :prepareComAndroidSupportCardviewV72311Library

      > :prepareComAndroidSupportSupportV42311Library

      > :prepareComGoogleAndroidGmsPlayServicesAnalytics940Library

      > :prepareComGoogleAndroidGmsPlayServicesAnalyticsImpl940Library

      > :prepareComGoogleAndroidGmsPlayServicesBase940Library

      > :prepareComGoogleAndroidGmsPlayServicesBasement940Library

      > :prepareComGoogleAndroidGmsPlayServicesGcm840Library

      > :prepareComGoogleAndroidGmsPlayServicesLocation940Library

      > :prepareComGoogleAndroidGmsPlayServicesMaps940Library

      > :prepareComGoogleAndroidGmsPlayServicesMeasurement840Library

      > :prepareComGoogleAndroidGmsPlayServicesTasks940Library

      > :prepareComUrbanairshipAndroidUrbanairshipSdk701Library

      > :prepareProjectCordovaLibUnspecifiedReleaseLibrary

      > :prepareReleaseDependencies

      >

      > ....

      > * What went wrong:

      > Execution failed for task ':transformClassesWithDexForRelease'.

      >> com.android.build.api.transform.TransformException:

      >> com.android.ide.common.process.ProcessException:

      >> java.util.concurrent.ExecutionException:  com.android.dex.DexException: Multiple dex files define  Lcom/google/android/gms/iid/MessengerCompat$1;

       

            I have read on the forum and other sources on the internet that such error typically occurs if there are configured conflicting versions of the google-play-services used by the plugins.

           But on my local computer build executed without any problems and I got fully functional .apk file.

           So I expect that there is an issue with Gradle configuration on build.phonegap.com and Gradle configuration can be adjusted similar to my local.

           So my questions is:

      - Do you plan to fix Gradle configuration on the build.phonegap.com to solve such issues?

      - Could you advise how I can adjust configuration to have working build and fully functional .apk?

       

      My configuration file is:

      <?xml version="1.0" encoding="utf-8"?>

      <widget xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"

          id="my.id"

          version="my.version"

          versionCode = "1" >

          <name>App</name>

          <description>

              My description

          </description>

          <author href="<my author>">

          </author>

          <content src="index.html" />

          <access origin="*" />

          <allow-navigation href="*" />

          <preference name="Orientation" value="portrait" />

          <preference name="webviewbounce" value="false" />

          <preference name="UIWebViewBounce" value="false" />

          <preference name="DisallowOverscroll" value="true" />

          <preference name="android-minSdkVersion" value="17" />

          <preference name="BackupWebStorage" value="none" />

          <preference name="SplashScreen" value="screen" />

          <preference name="SplashScreenDelay" value="4000" />

          <preference name="SplashMaintainAspectRatio" value="true" />

          <preference name="SplashShowOnlyFirstTime" value="false" />

          <preference name="FadeSplashScreen" value="true" />

          <preference name="AutoHideSplashScreen" value="false" />

          <preference name="ShowSplashScreenSpinner" value="false" />

          <preference name="FadeSplashScreenDuration" value="1000" />

          <preference name="BackgroundColor" value="0xffffffff" />

          <preference name="AndroidPersistentFileLocation" value="Internal" />

          <feature name="StatusBar">

              <param name="ios-package" onload="true" value="CDVStatusBar" />

          </feature>

          <platform name="android">

              <preference name="android-build-tool" value="gradle" />

              <icon height="48" src="res/icons/android/icon_48x48px.png" width="48" />

              <icon height="72" src="res/icons/android/icon_72x72px.png" width="72" />

              <icon height="96" src="res/icons/android/icon_96x96px.png" width="96" />

              <icon height="144" src="res/icons/android/icon_144x144px.png" width="144" />

              <icon height="192" src="res/icons/android/icon_192x192px.png" width="192" />

              <icon height="512" src="res/icons/android/icon_512x512px.png" width="512" />

              <splash density="port-ldpi" src="res/screen/android/port-ldpi-splash.png" />

              <splash density="port-mdpi" src="res/screen/android/port-mdpi-splash.png" />

              <splash density="port-hdpi" src="res/screen/android/port-hdpi-splash.png" />

              <splash density="port-xhdpi" src="res/screen/android/port-xhdpi-splash.png" />

              <splash density="port-xxhdpi" src="res/screen/android/port-xxhdpi-splash.png" />

              <splash density="port-xxxhdpi" src="res/screen/android/port-xxxhdpi-splash.png" />

          </platform>

          <platform name="ios">

              <icon height="180" src="res/icons/ios/icon-60@3x.png" width="180" />

              <icon height="60" src="res/icons/ios/icon-60.png" width="60" />

              <icon height="120" src="res/icons/ios/icon-60@2x.png" width="120" />

              <icon height="76" src="res/icons/ios/icon-76.png" width="76" />

              <icon height="152" src="res/icons/ios/icon-76@2x.png" width="152" />

              <icon height="40" src="res/icons/ios/icon-40.png" width="40" />

              <icon height="80" src="res/icons/ios/icon-40@2x.png" width="80" />

              <icon height="58" src="res/icons/ios/icon-small@2x.png" width="58" />

              <icon height="29" src="res/icons/ios/icon-small.png" width="29" />

              <splash src="res/screen/ios/Default-568h@2x~iphone.png" width="640" height="1136"/>

              <splash src="res/screen/ios/Default-667h.png" width="750" height="1334"/>

              <splash src="res/screen/ios/Default-736h.png" width="1242" height="2208"/>

              <splash src="res/screen/ios/Default-Portrait@2x~ipad.png" width="1536" height="2048"/>

              <splash src="res/screen/ios/Default-Portrait~ipad.png" width="768" height="1024"/>

              <splash src="res/screen/ios/Default@2x~iphone.png" width="640" height="960"/>

              <splash src="res/screen/ios/Default~iphone.png" width="320" height="480"/>

          </platform>

          <allow origin="*" />

          <allow-navigation href="*" />

       

          <plugin name="plugin.google.maps" spec="https://github.com/mapsplugin/cordova-plugin-googlemaps">

              <param name="API_KEY_FOR_ANDROID" value="My.Key" />

              <param name="API_KEY_FOR_IOS" value="My.Key" />

          </plugin>

          <plugin name="cordova-plugin-console" spec="~1.0.2" />

          <plugin name="cordova-plugin-whitelist" spec="~1.2.1" />

          <plugin name="cordova-plugin-inappbrowser" spec="~1.3.0" />

          <plugin name="cordova-plugin-device" spec="~1.1.1" />

          <plugin name="cordova-plugin-customurlscheme" spec="~4.1.3">

              <param name="URL_SCHEME" value="My.Url" />

          </plugin>

          <plugin name="ionic-plugin-keyboard" spec="https://github.com/driftyco/ionic-plugin-keyboard" />

          <plugin name="cordova-plugin-geolocation" />

          <plugin name="com.cmackay.plugins.googleanalytics" spec="~0.1.22" />

          <plugin name="urbanairship-cordova" spec="~4.1.1" />

          <plugin name="cordova-plugin-app-version" spec="~0.1.8" />

          <plugin name="cordova-plugin-splashscreen" spec="~3.2.1" />

          <plugin name="cordova-plugin-file" spec="~4.1.1" />

          <plugin name="cordova-plugin-root-detection" spec="https://github.com/trykovyura/cordova-plugin-root-detection.git" />

          <plugin name="cordova-plugin-jailbreak-detection" spec="https://github.com/leecrossley/cordova-plugin-jailbreak-detection.git" />

      </widget>

        • 1. Re: The android build fails with the "Multiple dex files define" error
          VectorP Level 4

          A couple of things to consider:

           

          1. You have this combination:

              <preference name="SplashScreenDelay" value="4000" />

              <preference name="AutoHideSplashScreen" value="false" />

          which doesn't make sense. You say: "Don't hide my splash automatically, and please do that after 4 seconds".

           

          2. You have:

              <feature name="StatusBar">

                  <param name="ios-package" onload="true" value="CDVStatusBar" />

              </feature>

          Please remove that, because the feature element is obsolete in PGB

           

          3. For Android icons, you should not specify dimensions. Instead, use the qualifier attribute. See the PGB Docs, section Configuring - Icons and Splash

           

          4. For Android, you can't use the density attribute with splashes for compound qualifiers. Use the qualifier attribute.

           

          5. For your plugins, you often pin an older version. Do you do that for any purpose?

          I recommend removing the spec attribute wherever possible (although many forum participants prefere setting some version).

           

          6. If, after correction, the issue remains, I suggest removing the plugins, then adding them one by one (especially the third party plugins) and see which plugin causes the problem.

          • 2. Re: The android build fails with the "Multiple dex files define" error
            barryt35413213 Level 1

            Thank you for you suggestion. I applied suggested improvements but it did not fix the build.

            I experimented with plugins and fount that

                <!--<plugin name="plugin.google.maps" spec="https://github.com/mapsplugin/cordova-plugin-googlemaps">

                    <param name="API_KEY_FOR_ANDROID" value="AIzaSyDPaLSXmQBkThkQRy0yYZ7uhF7aej2xfJI" />

                    <param name="API_KEY_FOR_IOS" value="AIzaSyBC4p-TJEXipQeHK1pSbxbMnleoXYSd_Vs" />

                </plugin>-->

                <!--<plugin name="com.cmackay.plugins.googleanalytics" spec="~0.1.22" />-->

             

            generate error. When these plugins are commented build on the phonegap is successful.

            I am getting successful build with these plugins on the local machine. I think this maybe because of such settings in the build.gradle file:

            dependencies {

                compile fileTree(dir: 'libs', include: '*.jar')

                // SUB-PROJECT DEPENDENCIES START

                debugCompile project(path: "CordovaLib", configuration: "debug")

                releaseCompile project(path: "CordovaLib", configuration: "release")

                compile "com.google.android.gms:play-services-analytics:+"

                // SUB-PROJECT DEPENDENCIES END

            }

            especially compile "com.google.android.gms:play-services-analytics:+"

             

            Which settings are used by build.gradle in the Adobe PhoneGap Build  ?

            Can I adjust this setting from my config.xml?

             

            What additional steps could be made to make listed plugins working with the build phonegap?