Bug? Admob example crash

Douglas Farias

Expert
Licensed User
Longtime User
Hello everyone.

I believe the Admob example has a bug.

To reproduce, I downloaded b4a.
I followed all the steps correctly.

I followed this tutorial.


However, the app never starts. It crashes right at the start, and it doesn't even show anything in the log, so there's no time.

The crash seems to happen when i declare in the manifest:

B4X:
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
CreateResourceFromFile(Macro, FirebaseAdMob.FirebaseAds)
AddReplacement($ADMOB_APP_ID$, ca-app-pub-12673333333~67613333333)

I created a new project, just checked the firebaseadmob2 lib, and added the code above to the manifest, and the problem already occurs.

I'm using a Samsung S25 Ultra. Android 15.
jdk-19.0.2
platforms\android-36\android.jar
Debug
B4A 13.40
 

Douglas Farias

Expert
Licensed User
Longtime User
Erel, I tested it, and your example worked.

However, creating a new project (Pages) is where the problem occurs.

I tried creating a new project and simply copying the pages from your example to mine, and the problem persists. The code is exactly the same, manifest and everything.

This example I sent is exactly the same code as yours, but in a new project.

I thought it might be a problem with the package name, but even changing it doesn't start.

The app starts quickly and closes, with no logs.

thx
 

Attachments

  • erel.zip
    13.2 KB · Views: 9

Erel

B4X founder
Staff member
Licensed User
Longtime User
I've replaced your manifest editor snippet with:
B4X:
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
CreateResourceFromFile (Macro, FirebaseAdMob2.FirebaseAds)
AddReplacement($ADMOB_APP_ID$, ca-app-pub-1267570815929340~6761974519)

It now works. Note that it is better to use the updated macro in FirebaseAdMob2 instead of FirebaseAdMob, though it isn't the cause of the crash.


If you check the unfiltered logs carefully (it will be simpler in the next update of B4A) then you will find this:

09-21 09:27:26.038 16242 16242 E AndroidRuntime: FATAL EXCEPTION: main
09-21 09:27:26.038 16242 16242 E AndroidRuntime: Process: b4a.example, PID: 16242
09-21 09:27:26.038 16242 16242 E AndroidRuntime: java.lang.RuntimeException: Unable to get provider com.google.android.gms.ads.MobileAdsInitProvider: java.lang.IllegalStateException:
09-21 09:27:26.038 16242 16242 E AndroidRuntime:
09-21 09:27:26.038 16242 16242 E AndroidRuntime: ******************************************************************************
09-21 09:27:26.038 16242 16242 E AndroidRuntime: * Invalid application ID. Follow instructions here: *
09-21 09:27:26.038 16242 16242 E AndroidRuntime: * https://goo.gle/admob-android-update-manifest *
09-21 09:27:26.038 16242 16242 E AndroidRuntime: * to find your app ID. *
09-21 09:27:26.038 16242 16242 E AndroidRuntime: * Google Ad Manager publishers should follow instructions here: *
09-21 09:27:26.038 16242 16242 E AndroidRuntime: * https://goo.gle/ad-manager-android-update-manifest. *
09-21 09:27:26.038 16242 16242 E AndroidRuntime: ******************************************************************************
 
Top