Android Question [Solved] Need help in latest way to add activity ads in app for B4A 11.50 ?

AnandGupta

Expert
Licensed User
Longtime User
I tried, @Jack Cole excellent one below
(1) AdsHelper Extension for Traditional B4A apps & more | B4X Programming Forum
But giving error now,
B4X:
B4A Version: 11.50
Parsing code.    (0.07s)
    Java Version: 8
Building folders structure.    (0.03s)
Compiling code.    (0.13s)
Compiling layouts code.    (0.04s)
Organizing libraries.    (0.12s)
    (AndroidX SDK)
Compiling resources    (1.13s)
Linking resources    (0.80s)
Compiling debugger engine code.    (3.01s)
Compiling generated Java code.    Error
javac 1.8.0_261
src\b4a\example\adshelper.java:1235: error: incompatible types: <anonymous OnUserEarnedRewardListener> cannot be converted to RewardedAdCallback
          mRewardedAd.show(context, new OnUserEarnedRewardListener() {
                                    ^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
1 error

I tried @Erel sample, created a project from the codes on the thread,
FirebaseAdMob2 - Google Mobile Ads SDK v20+ | B4X Programming Forum

But the app just closes without any error, both in release and debug modes.
I understand I need to make some changes as per error to fix them, but do not know where to begin.

In FirebaseAdMob2 thread it is mentioned,
B4X:
Note that you can use FirebaseAdMob2 without creating a Firebase account.
So I am more interested in it, as I had too many problems in Firebase account earlier.

I can attach the sample projects I tried, if it helps.
 
Solution
I made changes in starter still crashes on run. No log both in filtered and unfiltered.
I have attached the activity sample which I created from Erel's example, as I am interested in Activity+Banner only as of now.
I want to check in test ad ids now. If Ok, then will put mine.
I request If you get time, please check and guide me, if possible.
1 - If you check the unfiltered log of your example, will see:
B4X:
java.lang.RuntimeException: Unable to get provider com.google.android.gms.ads.MobileAdsInitProvider: java.lang.IllegalStateException:
******************************************************************************
* Invalid application ID. Follow instructions here:                          *
*...

asales

Expert
Licensed User
Longtime User
But the app just closes without any error, both in release and debug modes.
- Check the unfiltered log.
- Did you put the AdMob App Id in the manifest?
- Did you initialized the MobileAds in the Starter?

Check this example too:
 
Upvote 1

AnandGupta

Expert
Licensed User
Longtime User
- Check the unfiltered log.
- Did you put the AdMob App Id in the manifest?
- Did you initialized the MobileAds in the Starter?

Check this example too:
Thanks for reply.

I made changes in starter still crashes on run. No log both in filtered and unfiltered.

I was going to check you example, but as you mentioned at top, so went for Jack's one :)
Checked now but it also gives error
B4X:
B4A Version: 11.50
Parsing code.    (0.09s)
    Java Version: 8
Building folders structure.    (0.02s)
Compiling code.    (0.15s)
    
ObfuscatorMap.txt file created in Objects folder.
Compiling layouts code.    (0.08s)
Organizing libraries.    (0.13s)
    (AndroidX SDK)
Compiling resources    (1.15s)
Linking resources    (0.85s)
Compiling generated Java code.    Error
B4A line: 62
End Sub
javac 1.8.0_261
src\admob\tests\adshelper.java:542: error: method does not override or implement a method from a supertype
    @Override
    ^

I have attached the activity sample which I created from Erel's example, as I am interested in Activity+Banner only as of now.
I want to check in test ad ids now. If Ok, then will put mine.
I request If you get time, please check and guide me, if possible.
 

Attachments

  • AdsTest.zip
    11 KB · Views: 174
Upvote 0

asales

Expert
Licensed User
Longtime User
I made changes in starter still crashes on run. No log both in filtered and unfiltered.
I have attached the activity sample which I created from Erel's example, as I am interested in Activity+Banner only as of now.
I want to check in test ad ids now. If Ok, then will put mine.
I request If you get time, please check and guide me, if possible.
1 - If you check the unfiltered log of your example, will see:
B4X:
java.lang.RuntimeException: Unable to get provider com.google.android.gms.ads.MobileAdsInitProvider: java.lang.IllegalStateException:
******************************************************************************
* Invalid application ID. Follow instructions here:                          *
* https://googlemobileadssdk.page.link/admob-android-update-manifest         *
* to find your app ID.                                                       *
******************************************************************************
Your Admob App ID in manifest is wrong. Try with this sample code and use your real app ID in production:
B4X:
AddReplacement($ADMOB_APP_ID$, ca-app-pub-3940256099942544~3347511713)  'Sample AdMob app ID

2 - You put this line in Service_Start and disable this:
B4X:
''    Dim m As MobileAds

2.1 - Put this line in Service_Create (Starter) and remove all other codes:
B4X:
    Dim m As MobileAds
    Wait For (m.Initialize) MobileAds_Ready

3 - Here your example running:
1661362175994.png
 

Attachments

  • AdsTest2.zip
    11.1 KB · Views: 162
Upvote 0
Solution

AnandGupta

Expert
Licensed User
Longtime User
Thanks a Lot @asales ? for helping me out.

Your Admob App ID in manifest is wrong.
I got it from the Erel's thread, maybe it is changed now.
Anyway your sample is running perfectly correct here and now I can move forward. Thank you again.
 
Upvote 0

asales

Expert
Licensed User
Longtime User
If you are starting now, I think is better uses only banner and interstitial ads.
Later you can check the other options.
 
Upvote 0
Top