Android Question Google maps + AdMob problem

krzyszp

Member
Licensed User
Longtime User
Based on tutorial I have created app with map displayed on it...
Now I wish to add some ads to it, but found this problem while compilig:

B4X:
Convert byte code - optimized dex.      Error
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Lcom/google/ads/AdRequest$ErrorCode;
    at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:122)
    at com.android.dx.dex.file.DexFile.add(DexFile.java:161)
    at com.android.dx.command.dexer.Main.processClass(Main.java:685)
    at com.android.dx.command.dexer.Main.processFileBytes(Main.java:634)
    at com.android.dx.command.dexer.Main.access$600(Main.java:78)
    at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:572)
    at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
    at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
    at com.android.dx.command.dexer.Main.processOne(Main.java:596)
    at com.android.dx.command.dexer.Main.processAllFiles(Main.java:498)
    at com.android.dx.command.dexer.Main.runMonoDex(Main.java:264)
    at com.android.dx.command.dexer.Main.run(Main.java:230)
    at com.android.dx.command.dexer.Main.main(Main.java:199)
    at com.android.dx.command.Main.main(Main.java:103)
1 error; aborting
    Optimized dexer failed. Switching to Standard dexer.

And idea what I'm doing wrong?

There is my manifest file:
B4X:
AddManifestText( <permission
          android:name="$PACKAGE$.permission.MAPS_RECEIVE"
          android:protectionLevel="signature"/>
      <uses-feature android:glEsVersion="0x00020000" android:required="true"/>)

AddApplicationText(<meta-data
    android:name="com.google.android.maps.v2.API_KEY"
    android:value="AIzaSyBBUEE"/>
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"
    />)
    'AdMob
AddApplicationText(
<meta-data android:name="com.google.android.gms.version"
  android:value="@integer/google_play_services_version"/>
<activity android:name="com.google.android.gms.ads.AdActivity"
  android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>

)
'End of AdMob
AddPermission(android.permission.ACCESS_NETWORK_STATE)
AddPermission("android.permission.READ_CONTACTS")
AddPermission("android.permission.GET_ACCOUNTS")
 
Last edited by a moderator:

warwound

Expert
Licensed User
Longtime User
Try removing one of these lines from the manifest - you have the line added twice:

B4X:
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"/>

Martin.
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
Both Google Maps and AdMob are part of the Google Play Services library.
It's unlikely that they are incompatible but likely that you've got a conflict in the modifications made to the manifest.
 
Upvote 0
Top