Android Question Updated SDK now AdMob crashes.

ptp170

Member
Licensed User
Longtime User
Hi,

Just updated my SDK to version 20 and also updated Google Play Services to ver20.

Android.jar is set to ver 20 in Tools>Configure

Moved the latest google-play-services.jar into the Libraries folder.

Am using the latest Admob Library from here (2.00?)

MinSDK is set to 13.

Now my apps crash straight away...

B4X:
Could not find class 'com.google.android.gms.ads.InterstitialAd', referenced from method mobi.mindware.admob.interstitial.AdmobInterstitialsAds.Initialize
VFY: unable to resolve new-instance 517 (Lcom/google/android/gms/ads/InterstitialAd;) in Lmobi/mindware/admob/interstitial/AdmobInterstitialsAds;
Could not find class 'com.google.android.gms.ads.AdRequest$Builder', referenced from method mobi.mindware.admob.interstitial.AdmobInterstitialsAds.LoadAd
VFY: unable to resolve new-instance 513 (Lcom/google/android/gms/ads/AdRequest$Builder;) in Lmobi/mindware/admob/interstitial/AdmobInterstitialsAds;
VFY: unable to resolve virtual method 2775: Lcom/google/android/gms/ads/InterstitialAd;.isLoaded ()Z
Unable to resolve superclass of Lmobi/mindware/admob/interstitial/AdmobInterstitialsAds$1; (512)
Link of class 'Lmobi/mindware/admob/interstitial/AdmobInterstitialsAds$1;' failed
VFY: unable to resolve static field 1598 (BANNER) in Lcom/google/android/gms/ads/AdSize;
VFY: unable to resolve static field 1598 (BANNER) in Lcom/google/android/gms/ads/AdSize;
Could not find class 'com.google.android.gms.ads.AdView', referenced from method anywheresoftware.b4a.admobwrapper.AdViewWrapper.Initialize2
VFY: unable to resolve new-instance 516 (Lcom/google/android/gms/ads/AdView;) in Lanywheresoftware/b4a/admobwrapper/AdViewWrapper;
Could not find class 'com.google.android.gms.ads.AdRequest$Builder', referenced from method anywheresoftware.b4a.admobwrapper.AdViewWrapper.LoadAd
VFY: unable to resolve new-instance 513 (Lcom/google/android/gms/ads/AdRequest$Builder;) in Lanywheresoftware/b4a/admobwrapper/AdViewWrapper;
Could not find class 'com.google.android.gms.ads.AdView', referenced from method anywheresoftware.b4a.admobwrapper.AdViewWrapper.Pause
VFY: unable to resolve check-cast 516 (Lcom/google/android/gms/ads/AdView;) in Lanywheresoftware/b4a/admobwrapper/AdViewWrapper;
Could not find class 'com.google.android.gms.ads.AdView', referenced from method anywheresoftware.b4a.admobwrapper.AdViewWrapper.Resume
VFY: unable to resolve check-cast 516 (Lcom/google/android/gms/ads/AdView;) in Lanywheresoftware/b4a/admobwrapper/AdViewWrapper;
Unable to resolve superclass of Lanywheresoftware/b4a/admobwrapper/AdViewWrapper$1; (512)
Link of class 'Lanywheresoftware/b4a/admobwrapper/AdViewWrapper$1;' failed
Exception Ljava/lang/NoClassDefFoundError; thrown while initializing Lanywheresoftware/b4a/admobwrapper/AdViewWrapper;
threadid=1: thread exiting with uncaught exception (group=0x41d09a08)
main_globals (java line: 448)
java.lang.ExceptionInInitializerError
    at ******.******.main._globals(main.java:448)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:174)
    at ******.******.main.initializeGlobals(main.java:264)
    at ******.******.main.afterFirstLayout(main.java:95)
    at ******.******.main.access$100(main.java:16)
    at ******.******.main$WaitForLayout.run(main.java:76)
    at android.os.Handler.handleCallback(Handler.java:725)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:158)
    at android.app.ActivityThread.main(ActivityThread.java:5751)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1083)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:850)
    at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NoClassDefFoundError: com.google.android.gms.ads.AdSize
    at anywheresoftware.b4a.admobwrapper.AdViewWrapper.<clinit>(AdViewWrapper.java:37)
    ... 17 more
FATAL EXCEPTION: main
java.lang.ExceptionInInitializerError
    at ******.******.main._globals(main.java:448)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:174)
    at ******.******.main.initializeGlobals(main.java:264)
    at ******.******.main.afterFirstLayout(main.java:95)
    at ******.******.main.access$100(main.java:16)
    at ******.******.main$WaitForLayout.run(main.java:76)
    at android.os.Handler.handleCallback(Handler.java:725)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:158)
    at android.app.ActivityThread.main(ActivityThread.java:5751)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1083)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:850)
    at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NoClassDefFoundError: com.google.android.gms.ads.AdSize
    at anywheresoftware.b4a.admobwrapper.AdViewWrapper.<clinit>(AdViewWrapper.java:37)
    ... 17 more
App crashed! Process: com.******.******
App crashed! Package: com.******.****** v42 (v3.0.2)
App crashed! Application Label: ************
  Force finishing activity ******.******/.main
acquireWakeLock(427cafd0): PARTIAL_WAKE_LOCK , tag=ActivityManager-Launch, flags=0x1, pid=1311, uid=1000
getMirrorDisplayStatus:falsecurState:1
Activity pause timeout for ActivityRecord{431c0420 u0 ******.******/.main}
Calling a method in the system process without a qualified user: android.app.ContextImpl.sendBroadcast:1313 com.android.internal.policy.impl.PhoneWindowManager.setNavigationBarVisibility:7382 com.android.server.wm.WindowManagerService.setNavigationBarVisibility:12459 com.android.server.am.ActivityStack.resumeTopActivityLocked:1955 com.android.server.am.ActivityStack.resumeTopActivityLocked:1682
onResume
onResume
+onResume
[updatePages] total: 1, current: 0
updateAccounts - Accounts is no change
-onResume
Start proc com.htc.idlescreen.base for content provider com.htc.idlescreen.base/.setting.SettingProvider: pid=3703 uid=10110 gids={50110, 1028}

Was using this code originally..

B4X:
AdView1.Initialize("Ad", "ca-app-pub-*")

Have also tried this method (which I hadn't seen before)

B4X:
AdView1.Initialize2("Ad", "ca-app-pub-8", AdView1.SIZE_SMART_BANNER)

Anyone any ideas?!?

Chris
 

ptp170

Member
Licensed User
Longtime User
Are you sure that you have copied google-play-services.jar to the libraries folder?

Make sure that there isn't an old copy of this jar in the internal libraries folder.

I've made a copy of the project and thinned it down to just the first screen with the adverts to remove any other possible issues. The same error(s) occur 'Caused by: java.lang.NoClassDefFoundError: com.google.android.gms.ads.AdSize'

I've recopied the google-play-services.jar again just in case to C:\Program Files (x86)\Anywhere Software\Basic4android\Libraries. It is version 20 according to the SDK.

Admob Library ver is 2.00
B4A version is 3.8
Android.jar is v20 (C:\Program Files (x86)\Android\android-sdk\platforms\android-20\android.jar)

#AdditionalRes: C:\Program Files (x86)\Android\android-sdk\extras\google\google_play_services\libproject\google-play-services_lib\res, com.google.android.gms I've checked just incase the directory structure has changed and it hasn't.


B4X:
AddManifestText(
<uses-sdk android:minSdkVersion="13" android:targetSdkVersion="14"/>
<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.



All of this was working flawlessly before so I can't really understand what's happened!
 
Last edited:
Upvote 0

ptp170

Member
Licensed User
Longtime User
I've dropped back to ver19 of Android.jar and kept Google_play_services.jar v20

The App now fires up without crashing BUT I get this error..

B4X:
Main_Activity_Create java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value.  Expected 4452000 but found 6111000.  You must have the following declaration within the <application> element:     <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />

I've also tried using a backed up version of google-play-services.jar with android.jar V15 as this is what I was using before I made the 'mistake' of updating the SDK. Using this original combination I get exactly the same error message as above...


EDIT: Started a brand new clean project using android.jar v20 and google_play_services.jar v20. Get the same 'adsize' error as detailed in the first post...
 
Last edited:
Upvote 0

alexis

Member
Licensed User
Longtime User
Thanks PTP170. Unfortunately my subscription also expired a bit before the new upgrade. I might still have to leave the old admob way for a while.
 
Upvote 0
Top