Android Question Question about admob with Firebase

azad222

Member
I used the following code.
codeadmob:
Sub Process_Globals

End Sub

Sub Globals
   Private BannerAd As AdView
   Private IAd As InterstitialAd
End Sub

Sub Activity_Create(FirstTime As Boolean)
   BannerAd.Initialize2("BannerAd", "ca-app-pub-3940256099942544/6300978111", BannerAd.SIZE_SMART_BANNER)
   Dim height As Int
   If GetDeviceLayoutValues.ApproximateScreenSize < 6 Then
    'phones
    If 100%x > 100%y Then height = 32dip Else height = 50dip
   Else
    'tablets
    height = 90dip
   End If
   Activity.AddView(BannerAd, 0dip, 100%y - height, 100%x, height)
   BannerAd.LoadAd
   IAd.Initialize("iad", "ca-app-pub-3940256099942544/1033173712")
   IAd.LoadAd
End Sub

Sub Activity_Click
   If IAd.Ready Then IAd.Show
End Sub

Sub IAD_AdClosed
   IAd.LoadAd 'prepare a new ad
End Sub

Google's test code works. But my codes are not displayed.
Do I need to add this code while working?

https://firebase.google.com/docs/admob/android/quick-start

manidest:
<manifest>
    <application>
        <!-- Sample AdMob App ID: ca-app-pub-3940256099942544~3347511713 -->
        <meta-data
            android:name="com.google.android.gms.ads.APPLICATION_ID"
            android:value="ADMOB_APP_ID"/>
    </application>
</manifest>
 

azad222

Member
I did the following step by step:
step1: First I went to the link below:
https://console.firebase.google.com/
And I made an Android project. I was given a json code.
Download google-services.json and put it in the projects folder (folder of the b4a file).

step2: Add the manifest snippets to the manifest editor based on the services that you need.

add manifest:
'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="5" android:targetSdkVersion="29"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
CreateResourceFromFile(Macro, Themes.LightTheme)
'End of default text.


'AdMob
AddApplicationText(
<meta-data android:name="com.google.android.gms.version"
  android:value="[USER=21225]@Integer[/USER]/google_play_services_version"/>
<activity android:name="com.google.android.gms.ads.AdActivity"
  android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
)

'AdMob
AddApplicationText(
<meta-data
            android:name="com.google.android.gms.ads.ca-app-pub-7920067095036570~8669178654"
            android:value="ca-app-pub-7920067095036570~8669178654"/>
)

'power by milad biroonvand

[B]step3:  Follow the instructions of the specific libraries.  (check use firebaseadmob v1.6)[/B]
[CODE lang="b4x" title="b4acode"]Sub Process_Globals

End Sub

Sub Globals
   Private BannerAd As AdView
   Private IAd As InterstitialAd
End Sub

Sub Activity_Create(FirstTime As Boolean)
   BannerAd.Initialize2("BannerAd", "ca-app-pub-3940256099942544/6300978111", BannerAd.SIZE_SMART_BANNER)
   Dim height As Int
   If GetDeviceLayoutValues.ApproximateScreenSize < 6 Then
    'phones
    If 100%x > 100%y Then height = 32dip Else height = 50dip
   Else
    'tablets
    height = 90dip
   End If
   Activity.AddView(BannerAd, 0dip, 100%y - height, 100%x, height)
   BannerAd.LoadAd
   IAd.Initialize("iad", "ca-app-pub-3940256099942544/1033173712")
   IAd.LoadAd
End Sub

Sub Activity_Click
   If IAd.Ready Then IAd.Show
End Sub

Sub IAD_AdClosed
   IAd.LoadAd 'prepare a new ad
End Sub

step4: I compiled the project
But the following error occurred: error Error Code 0
Google has announced the following errors:
source:

Error Code 0 : ERROR_CODE_INTERNAL_ERROR

  • Error Code 1 : ERROR_CODE_INVALID_REQUEST
That's all I've done

  • Error Code 2 : ERROR_CODE_NETWORK_ERROR



  • Error Code 3 : ERROR_CODE_NO_FILL
 

Attachments

  • json.jpg
    14 KB · Views: 161
  • khata2.jpg
    26.7 KB · Views: 169
Upvote 0

asales

Expert
Licensed User
Longtime User
Check this example that have all code to work with Admob:
 
Upvote 0

asales

Expert
Licensed User
Longtime User
Yes and the best one, I have found.
Many thanks to @asales ?

Regards,

Anand
Thanks!
The example was updated:
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…