Android Question Problems with "activity_admob_example".

This is not first time with AdMobs and Firebase. I have unfinished app with theese, which wokred fine. But it was on B4A 10.20 several weeks ago. Now I have back to this app already with B4A 10.50, but had an error. The easiest way - try official example from forum. So...

B4A 10.50 reinstalled twice following the step-by-step manual.
I downloaded "activity_admob_example" (https://www.b4x.com/android/forum/threads/b4xpages-the-almost-definitive-admob-example.113586/).
I downloaded my google-services.json, changed in "activity_admob_example" #ApplicationLabel and AddReplacement($ADMOB_APP_ID$, ca-app-pub-... in manifest.
I have done everything in SDK manager updates (I have read the forum and more or less know how it to do).

The compilation in Debug mode or Release mode is Ok, no errors, app is installing like usually on device via Bridge.
But after start the app I receive the messege from phone operating system:
----------------------------------------------------------------------------------------------------------------
java.lang.RuntimeException: Unable to get provider com.google.android.gms.ads.MobileAdsInitProvider: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.ads.MobileAdsInitProvider" on path: DexPathList[[zip file "/data/app/lsv.iqtest-32UniKoceJHAXq8xGaNA4w==/base.apk"],nativeLibraryDirectories=[/data/app/lsv.iqtest-32UniKoceJHAXq8xGaNA4w==/lib/arm64, /system/lib64, /system/vendor/lib64]]
at android.app.ActivityThread.installProvider(ActivityThread.java:6398)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5900)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5808)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1685)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:6651)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:824)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.ads.MobileAdsInitProvider" on path: DexPathList[[zip file "/data/app/lsv.iqtest-32UniKoceJHAXq8xGaNA4w==/base.apk"],nativeLibraryDirectories=[/data/app/lsv.iqtest-32UniKoceJHAXq8xGaNA4w==/lib/arm64, /system/lib64, /system/vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.ActivityThread.installProvider(ActivityThread.java:6374)
... 10 more
-------------------------------------------------------------------------------------------------------------------------

Like a black box! Please, have you any ideas what to do with this?
 
It was first I have done before reinstalling the B4A. I reinstalled all of components step-by-step via manual you mentioned. Twice. Still error...
Well I'll try again.
 
Upvote 0
So, the new quest!

Java SDK, Android SDK, B4A removed (also manually removed all files and folders, remained after deinstallation), and installed again via B4X.com instructions.
B4A started. Paths to java.exe (C:\Program Files\Java\jdk1.8.0_281\bin\javac.exe) and android.jar (C:\android\platforms\android-30\android.jar) was input in paths manager.
SDK Manager started (SDK version: 6609375, C:\android\tools\bin\sdkmanager.bat), installed all Recommended.
Android Applications without Firebase and AdMob tested: compilation and operation are ok, no errors.

Loaded the app with FirebaseAdMob library reference.
App started. Error: Artifact Maven not found: androidx.work/work-runtime.
In SDK Manager the androidx.work/work-runtime (Google Maven) v 2.5.0 was installed.

App started. Error: Artifact Maven not found: com.google.guava/listenablefuture. Forum https://www.b4x.com/android/forum/t...e-guava-listenablefuture-solved.123671/page-2. The file “com.google.guava-listenablefuture.jar” downloaded from Erel’s post and addem manually.

App started. Compilation – Ok, Device installation – ok. On device Run – New ERROR: java.lang.RuntimeException: Unable to get provider com.google.android.gms.ads.MobileAdsInitProvider: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.ads.MobileAdsInitProvider" on path: DexPathList[[zip file "/data/app/lsv.iqtest-p2w-SkC8anzy7j2A7DxsBg==/base.apk"],nativeLibraryDirectories=[/data/app/lsv.iqtest-p2w-SkC8anzy7j2A7DxsBg==/lib/arm64, /system/lib64, /system/vendor/lib64]]
at android.app.ActivityThread.installProvider(ActivityThread.java:6398)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5900)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5808)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1685)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:6651)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:824)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.ads.MobileAdsInitProvider" on path: DexPathList[[zip file "/data/app/lsv.iqtest-p2w-SkC8anzy7j2A7DxsBg==/base.apk"],nativeLibraryDirectories=[/data/app/lsv.iqtest-p2w-SkC8anzy7j2A7DxsBg==/lib/arm64, /system/lib64, /system/vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.ActivityThread.installProvider(ActivityThread.java:6374)
... 10 more

At least it is new error. Looks like labrary in APK is incorrect or absent.
I found https://www.b4x.com/android/forum/threads/firebaseadmob-1-60-mobileads.111049/, but it for Firebase 1.6, now I have 2.0, the paths seems correct.

Please, What to do? The app worked before, but now it does not! What to do with this Firebase?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0
Of course. It is Example from forum. I'm just changed adMob code in last string.


'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: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="30"/>
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'End of default text.

'************ Google Play Services Base ************
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
'************ Google Play Services Base (end) ************
'************ Firebase Base ************
CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)
'************ Firebase Base (end) ************'************ Firebase Ads ************
CreateResourceFromFile(Macro, FirebaseAdMob.FirebaseAds)
'************ Firebase Ads (end) ************

'This is a sample AdMob app id. You need to change it to your id.
AddReplacement($ADMOB_APP_ID$, ca-app-pub-4988734109XXXX~455805XXXX)
 
Upvote 0
YES!.........🥳
I found what wrong! What have I do to solve problem? Nothing!
I'm reinstalled Java, Android SDK and B4A again in .... time. And now I did not install Recommended in B4A SDK manager. I'm not even ran this SDK manager. Just configured the paths.
So, the application with AdMob worked again!!! Like before.

Any way, thank you Erel for support and attitude.
 
Upvote 0
Top