Android Question optimized dex error with admob

le_toubib

Active Member
Licensed User
Longtime User
hi all
i m trying to revive an old app , installing the new admob

using these module attributes :
B4X:
#Region Module Attributes
    #FullScreen: False
    #IncludeTitle: True
    #ApplicationLabel: 
    #VersionCode: 9
    #VersionName: E
    #SupportedOrientations: portrait
    #CanInstallToExternalStorage: False
        #AdditionalRes: F:\Android\android-sdk\extras\google\google_play_services\libproject\google-play-services_lib\res, com.google.android.gms
    #AdditionalJar: android-support-v4
   #ExcludeClasses: com.google.ads, anywheresoftware.b4a.phone.RingtoneManager
#End Region


manifest editor :
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: http://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="21" />
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>
)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'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
'End of default text.

i received this error :
Installing file.
PackageAdded: package:xxxx.xxxx.xxx
Copying updated assets files (4)
** Activity (main) Create, isFirst = true **
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/ads/mediation/admob/AdMobAdapter;
at com.google.android.gms.ads.internal.client.zzh.zza(Unknown Source)
at com.google.android.gms.ads.internal.client.zzab.zza(Unknown Source)
at com.google.android.gms.ads.BaseAdView.loadAd(Unknown Source)
at com.google.android.gms.ads.AdView.loadAd(Unknown Source)
at anywheresoftware.b4a.admobwrapper.AdViewWrapper.LoadAd(AdViewWrapper.java:118)
at Dardiries.mukhtar.abmegeed.main._activity_create(main.java:430)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:708)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:340)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:247)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
at Dardiries.mukhtar.abmegeed.main.afterFirstLayout(main.java:102)
at Dardiries.mukhtar.abmegeed.main.access$000(main.java:17)
at Dardiries.mukhtar.abmegeed.main$WaitForLayout.run(main.java:80)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:158)


B4A version: 6.30
Parsing code. (0.02s)
Compiling code. (0.28s)
Compiling layouts code. (0.01s)
Organizing libraries. (0.02s)
Generating R file. (2.45s)
Compiling generated Java code. (2.71s)
Convert byte code - optimized dex. (147.34s)
Optimized dexer failed. Switching to Standard dexer.
Packaging files. (20.36s)
Copying libraries resources (0.00s)
Signing package file (private key) (6.10s)
ZipAlign file. (0.18s)
Installing file to device. (0.25s)
Installing with B4A-Bridge.
Completed successfully.
P.s: i still get the library googleadmobsdk is not used warning
P.S : had to change process timeout to 120 even though i have 16GB ram i7 device ... and a relatively small app (apk size 3.3MB including a 4MB map)
P.S : is working perfectly fine before admob
P.S : libraries used : RAF , JO, IME , admob, googleadmobsdk

what s wrong did i do ?
 

sorex

Expert
Licensed User
Longtime User
the new admob is the firebase one. You better switch to that as it doesn't rely on those v4 files etc...
 
  • Like
Reactions: eps
Upvote 0

eps

Expert
Licensed User
Longtime User
You probably need to 'up' your minsdk version substantially - I think 14 is around the lowest that works for most services.

ETA : Actually it might be 9, but I think 14 is for Maps and so on.

I've been through this pain with my Apps - once set up it is fine, but it's a bit of a trek getting there.
 
Upvote 0
Top