Android Question Firebase admob Issue

Keith Flanagan

Member
Licensed User
Hi All

I am having an issue with my app. I am creating a simple B4x Page application, with one page [this has a couple of images and a button. there is also a panel which is the placeholder for the admob to display into.

My app will install and run on my phone perfectly until I add FireBaseAdMob, the resources in the manifest and the google-services.json file.

Once I add these references and files, the code will compile correctly and will install to the device using B4ABridge.

But once I open the App using the Bridge, it just disappears - like what happens when the code crashes, however there is nothing in the log to suggest what the problem may be.

Now it probably is something in my Android setup, although I have just refreshed this earlier to try to rule it in or out

I reference Firebase AdMob library 2.00 , I have added the manifest details [See Screens below]

TestWithAdsConfig.png


B4X:
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    Private Panel1 As Panel
    Private pnlAds As Panel
    
    Private BannerAd As AdView
End Sub

Public Sub Initialize
    
End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    
    BannerAd.Initialize2("BannerAd", "ca-app-pub-9**************1/2********9", BannerAd.SIZE_SMART_BANNER)
    pnlAds.AddView(BannerAd, 0, 0, pnlAds.Width, pnlAds.Height)
    BannerAd.LoadAd

End Sub

I can include the full project if this helps trouble shooting.

But before I do, should I remove the google-service.json file and also the ad unit IDs?

Thanks in Advance
 

Keith Flanagan

Member
Licensed User
From another thread I found that you should Initialize MobileAds Library first, is this OK to do in B4A Pages in the main module?

B4X:
Sub Activity_Create(FirstTime As Boolean)
    Dim pm As B4XPagesManager
    pm.Initialize(Activity)
    
    Dim MobileAds As MobileAds
    MobileAds.Initialize
End Sub

Adding to Activity Create has not resolved my issue anyway, still crashes without any error logged, app is fine if I remove firebaseAds library and references in manifest
 
Upvote 0

asales

Well-Known Member
Licensed User
Longtime User
is this OK to do in B4A Pages in the main module?
No.

Check this:
" Initialize MobileAds in Service_Create of the starter service "
and this examples:
 
Upvote 0

Keith Flanagan

Member
Licensed User
Thanks for the Response asales.

I have tried your example B4X Pages project : [B4XPages] The (almost) Definitive Admob Example | B4X Programming Forum

I added my Google-service.json [for which I created a fresh Android app project in google console with the same package name as your project.

All this is fine and the code compiles and installs to the device, however I get the exact same result I was seeing with my own code.

The app crashes immediately at startup, with no error in B4a log view.

I changed the manifest to use my ad id, but I left the ad unit id you have in Main page, its not even getting that far though.

Any suggestions, I wonder is it my specific phone or android version does not like something in the App with firebase ads library?

Thanks in Advance
 
Upvote 0

asales

Well-Known Member
Licensed User
Longtime User
The app crashes immediately at startup, with no error in B4a log view.
Check the unfiltered logs (disable the Filter checkbox in the Logs tab).
You should see an error message regarding the problem.

I wonder is it my specific phone or android version does not like something in the App with firebase ads library?
Which phone model and Android version?
 
Upvote 0

Keith Flanagan

Member
Licensed User
Check the unfiltered logs (disable the Filter checkbox in the Logs tab).
You should see an error message regarding the problem.


Which phone model and Android version?

Thanks asales - I unchecked the filter tickbox, but unfortunately this has made no difference.

The model details are attached below:
 

Attachments

  • Screenshot_20210224_091950_com.android.settings.jpg
    Screenshot_20210224_091950_com.android.settings.jpg
    222.5 KB · Views: 132
Upvote 0

Keith Flanagan

Member
Licensed User
Looks correct.
Are you using B4A v10.6?

If you like you can send me the complete project with the json file and I'll try it.

Thanks Erel.

Yes using version 10.6

I have my project [Test With Ads], with my JSON file and ad ID's

I have also a slight mod I made to asales example : [B4XPages] The (almost) Definitive Admob Example | B4X Programming Forum

This is also attached, but I get the same behaviour.

The software will be visible on my phone for like a fraction of a second, and then shuts down.

There is no exception logged in B4A.

Thanks for the help.
 
Upvote 0

Keith Flanagan

Member
Licensed User
I just tried it on another device and same result, see screenshot attached.

I guess this rules out the device or android software
 

Attachments

  • Screenshot_20210224-104549.jpeg
    Screenshot_20210224-104549.jpeg
    50.5 KB · Views: 126
Upvote 0

Keith Flanagan

Member
Licensed User
There must be an error message in the logs when you see this dialog. Check the unfiltered logs and find it.

Hi Erel

If there is its not showing in the IDE, both Filtered or unfiltered, see screenshot where i am debugging app, it has crashed on the phone showing the error in the screen from 10.54

But as you can see nothing in the IDE

Thanks
 

Attachments

  • TestWithAdsConfig.png
    TestWithAdsConfig.png
    129.3 KB · Views: 121
Upvote 0

Keith Flanagan

Member
Licensed User
Switch to USB debug mode instead of B4A-Bridge.

That's done the trick Erel, Huge log of data now attached.

I see this error:
B4X:
Process: com.test.withads, PID: 7480
java.lang.RuntimeException: Unable to get provider com.google.firebase.provider.FirebaseInitProvider: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList[[zip file "/data/app/com.test.withads-m6cFAUr5dVTNaEFD1jGVwQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.test.withads-m6cFAUr5dVTNaEFD1jGVwQ==/lib/arm, /system/lib, /vendor/lib]]
    at android.app.ActivityThread.installProvider(ActivityThread.java:6401)
    at android.app.ActivityThread.installContentProviders(ActivityThread.java:5964)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5881)
    at android.app.ActivityThread.-wrap1(Unknown Source:0)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6666)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:583)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:870)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList[[zip file "/data/app/com.test.withads-m6cFAUr5dVTNaEFD1jGVwQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.test.withads-m6cFAUr5dVTNaEFD1jGVwQ==/lib/arm, /system/lib, /vendor/lib]]
    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:6386)
    ... 10 more

Is there anything specifically I can check in the Android SDK to confirm correctness?

SDK Paths in screenshot attached.
Thanks
 

Attachments

  • UsbDebugging.txt
    411 KB · Views: 132
  • Paths.png
    Paths.png
    17.4 KB · Views: 124
Last edited:
Upvote 0

Keith Flanagan

Member
Licensed User
A bit disappointing to see that your settings are still incorrect. I've asked you several times to follow the installation instructions: https://www.b4x.com/b4a.html
I don't see how I can further help here...

Hi Erel

Not sure I understand here, I have tried changing the paths to different folders, I have followed the steps in your link several times and I'm not sure what you see that I am missing. See attached folders and paths

I have retried using android 30, but still no difference, the app crashes with the same error.

Can you tell me what you see is incorrect with my settings please?

I have also downloaded android studio and eclipse to see if they would fix any potential missing or misconfigured items in the android folder

Thanks
 

Attachments

  • paths2.png
    paths2.png
    17.9 KB · Views: 122
  • Folders.png
    Folders.png
    80.7 KB · Views: 114
Last edited:
Upvote 0
Top