Fix for Google Play Services Dex error in 10.2.3

Posted by on in Blogs

AdMob by GoogleIf you installed 10.2.3 over 10.2.2 you may see an error similar to the one found below relating to dex and google-play-services.dex.jar when targeting Android. There were some changes in 10.2.3 to update it to use AdMob SDK version 7, and there is a workaround on the DocWiki page for migrating existing apps to 10.2.3. You can use that workaround for your new projects, or if you installed 10.2.3 over 10.2.x then there may be some files you need to clean up . . . 

If you go to C:\Program Files (x86)\Embarcadero\Studio\19.0\lib\android\debug (see picture above) you will find that two of these jar/dex files are not like the others. With a date from December of 2017, while the rest are dated for March of 2018. They are left behind from 10.2.2 and the earlier version of AdMob. The suspect jar/dex files are found in both the lib\android\debug and lib\android\release folders. Delete them from both locations:

  • Delete the following files (or remove and back them up if you are the paranoid cautious type)
    • C:\Program Files (x86)\Embarcadero\Studio\19.0\lib\android\debug\google-play-services.dex.jar
    • C:\Program Files (x86)\Embarcadero\Studio\19.0\lib\android\debug\google-play-services.jar
    • C:\Program Files (x86)\Embarcadero\Studio\19.0\lib\android\release\google-play-services.dex.jar
    • C:\Program Files (x86)\Embarcadero\Studio\19.0\lib\android\release\google-play-services.jar

You may need to restart the IDE.

If you made a clean uninstall/reinstall then you shouldn't have this error. 

Here is the full dump of the error text. . . . 

[Exec Error] The command "C:\Users\Public\Documents\Embarcadero\Studio\PlatformSDKs\android-sdk-windows\build-tools\27.0.3\dx.bat" --dex --output="C:\Users\[user]\Documents\Embarcadero\Studio\Projects\Recording\Android\Debug\classes.dex" "c:\program files (x86)\embarcadero\studio\19.0\lib\Android\Debug\android-support-v4.dex.jar" "c:\program files (x86)\embarcadero\studio\19.0\lib\Android\Debug\cloud-messaging.dex.jar" "c:\program files (x86)\embarcadero\studio\19.0\lib\Android\Debug\fmx.dex.jar" "c:\program files (x86)\embarcadero\studio\19.0\lib\Android\Debug\google-analytics-v2.dex.jar" "c:\program files (x86)\embarcadero\studio\19.0\lib\Android\Debug\google-play-billing.dex.jar" "c:\program files (x86)\embarcadero\studio\19.0\lib\Android\Debug\google-play-licensing.dex.jar" "c:\program files (x86)\embarcadero\studio\19.0\lib\Android\Debug\google-play-services-ads-7.0.0.dex.jar" "c:\program files (x86)\embarcadero\studio\19.0\lib\Android\Debug\google-play-services-analytics-7.0.0.dex.jar" "c:\program files (x86)\embarcadero\studio\19.0\lib\Android\Debug\google-play-services-base-7.0.0.dex.jar" "c:\program files (x86)\embarcadero\studio\19.0\lib\Android\Debug\google-play-services-identity-7.0.0.dex.jar" "c:\program files (x86)\embarcadero\studio\19.0\lib\Android\Debug\google-play-services-maps-7.0.0.dex.jar" "c:\program files (x86)\embarcadero\studio\19.0\lib\Android\Debug\google-play-services-panorama-7.0.0.dex.jar" "c:\program files (x86)\embarcadero\studio\19.0\lib\Android\Debug\google-play-services-plus-7.0.0.dex.jar" "c:\program files (x86)\embarcadero\studio\19.0\lib\Android\Debug\google-play-services-wallet-7.0.0.dex.jar" "c:\program files (x86)\embarcadero\studio\19.0\lib\Android\Debug\google-play-services.dex.jar" " exited with code 2.

    UNEXPECTED TOP-LEVEL EXCEPTION:

    com.android.dex.DexException: Multiple dex files define Lcom/google/ads/AdRequest$ErrorCode;
        at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:661)
        at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:616)
        at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:598)
        at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
        at com.android.dx.merge.DexMerger.merge(DexMerger.java:198)
        at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:506)
        at com.android.dx.command.dexer.Main.runMonoDex(Main.java:336)
        at com.android.dx.command.dexer.Main.runDx(Main.java:291)
        at com.android.dx.command.dexer.Main.main(Main.java:247)
        at com.android.dx.command.Main.main(Main.java:94)

    c:\program files (x86)\embarcadero\studio\19.0\bin\CodeGear.Common.Targets(894,5): error MSB3073: The command "PATH C:\Program Files\Java\jdk1.8.0_60\bin;C:\Users\Public\Documents\Embarcadero\InterBase\redist\InterBaseXE7\IDE_spoof;C:\Users\Public\Documents\Embarcadero\InterBase\redist\InterBaseXE7\IDE_spoof;S:\Binaries\Delphi;C:\Program Files (x86)\Embarcadero\Studio\19.0\bin;C:\Users\Public\Documents\Embarcadero\Studio\19.0\Bpl;C:\Program Files (x86)\Embarcadero\Studio\19.0\bin64;C:\Users\Public\Documents\Embarcadero\Studio\19.0\Bpl\Win64;C:\Users\Public\Documents\Embarcadero\Studio\19.0\PlatformSDKs\android-sdk-windows\platform-tools;C:\Program Files\Java\jdk1.7.0_80\bin;C:\Utils\java2op;C:\Users\Public\Documents\Embarcadero\Studio\19.0\Bpl;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\WinMerge;C:\Program Files\PuTTY\;C:\Users\Dubten\AppData\Local\Microsoft\WindowsApps;;C:\Users\Dubten\AppData\Local\Programs\Fiddler & "C:\Users\Public\Documents\Embarcadero\Studio\19.0\PlatformSDKs\android-sdk-windows\build-tools\26.0.2\dx.bat" --dex --output="S:\DelphiWorlds\Applications\Default\Android\Debug\classes.dex" "c:\program files (x86)\embarcadero\studio\19.0\lib\Android\Debug\android-support-v4.dex.jar" "c:\program files (x86)\embarcadero\studio\19.0\lib\Android\Debug\cloud-messaging.dex.jar" "c:\program files (x86)\embarcadero\studio\19.0\lib\Android\Debug\fmx.dex.jar" "c:\program files (x86)\embarcadero\studio\19.0\lib\Android\Debug\google-analytics-v2.dex.jar" "c:\program files (x86)\embarcadero\studio\19.0\lib\Android\Debug\google-play-billing.dex.jar" "c:\program files (x86)\embarcadero\studio\19.0\lib\Android\Debug\google-play-licensing.dex.jar" "c:\program files (x86)\embarcadero\studio\19.0\lib\Android\Debug\google-play-services-ads-7.0.0.dex.jar" "c:\program files (x86)\embarcadero\studio\19.0\lib\Android\Debug\google-play-services-analytics-7.0.0.dex.jar" "c:\program files (x86)\embarcadero\studio\19.0\lib\Android\Debug\google-play-services-base-7.0.0.dex.jar" "c:\program files (x86)\embarcadero\studio\19.0\lib\Android\Debug\google-play-services-identity-7.0.0.dex.jar" "c:\program files (x86)\embarcadero\studio\19.0\lib\Android\Debug\google-play-services-maps-7.0.0.dex.jar" "c:\program files (x86)\embarcadero\studio\19.0\lib\Android\Debug\google-play-services-panorama-7.0.0.dex.jar" "c:\program files (x86)\embarcadero\studio\19.0\lib\Android\Debug\google-play-services-plus-7.0.0.dex.jar" "c:\program files (x86)\embarcadero\studio\19.0\lib\Android\Debug\google-play-services-wallet-7.0.0.dex.jar" "c:\program files (x86)\embarcadero\studio\19.0\lib\Android\Debug\google-play-services.dex.jar" " exited with code 2.

Done building target "BuildClassesDex" in project "Project1.dproj" -- FAILED.

Done building project "Project1.dproj" -- FAILED.

Build FAILED.



Comments

  • Uros C1463
    Uros C1463 Saturday, 28 April 2018

    Thank you for posting this. I wasted some time to fix this one. Can you make some kind of a notification system for developers to alert them on bugs and bug fixes.

  • Rafael Ribas Aguiló
    Rafael Ribas Aguiló Wednesday, 28 March 2018

    A patch for push notifications was released:
    https://cc.embarcadero.com/item/30831

  • Davis
    Davis Tuesday, 27 March 2018

    Champagne can you share this .jar file that you changed?

  • Davis
    Davis Tuesday, 27 March 2018

    @Champagne

  • Jim McKeeth
    Jim McKeeth Tuesday, 20 March 2018

    Not familiar with that error.

  • GKirkwood
    GKirkwood Tuesday, 20 March 2018

    Why don't Embarcadero have a system in place for notifying us of these types of errors ? This is the second time in a couple of weeks (last was the Tab Transition problem) that I've spent hours / days trying to find out why my deployed applications don't work. Only after lots of work and trawling forums do I find this fix to my error. Why should we have to hunt for these things ? Why not send out an email or Twitter message informing us ? It would save us all a lot of heartache.

  • Rafael Ribas Aguiló
    Rafael Ribas Aguiló Monday, 19 March 2018

    @Jiri P8614
    The bug is not in Kinvey.
    I don't use Kinvey and I got the same error.
    I already openned request for a fix at https://quality.embarcadero.com/browse/RSP-20137
    I also noticed some minor differences (just a folder structure is missing) between actual and previous versions of the cloud messaging jars. You can see it at http://www.agilesoftware.com.br/GoogleCloudMessagingError.png

  • Jiri P8614
    Jiri P8614 Thursday, 15 March 2018

    Jim, how to fix error 'java class JGoogleCloudMessaging could not be found' in delphi 10.2.3 (libraries were reverted to system files default - ver 7.0.0)?

  • Jiri P8614
    Jiri P8614 Thursday, 15 March 2018

    The bug is in Kinvey...

  • Rafael Ribas Aguiló
    Rafael Ribas Aguiló Tuesday, 20 March 2018

    The bug seems to be in the cloud messaging library.
    Kinvey uses it as well as I use it in my own component. I dont't use Kinkey and have the same message error.

  • Rafael Ribas Aguiló
    Rafael Ribas Aguiló Tuesday, 20 March 2018

    Sorry!
    Google rebranded Google Cloud Messaging (GCM) to Firebase Cloud Message (FCM).
    Not only my component became incompatible but also Embarcadero's components did.


    More info at:
    https://developers.google.com/android/reference/com/google/android/gms/gcm/GoogleCloudMessaging

  • Champagne
    Champagne Friday, 23 March 2018

    The new JAR files (with file date 10 March 2018) do not contain the GoogleCloudMessaging class.

    - Enable the google-play-services.jar file (with date 14 December 2017)
    - Disable all new libraries (with 7.0.0)
    works for me.

  • Please login first in order for you to submit comments
  • Page :
  • 1

Check out more tips and tricks in this development video: