Android Question AdMob Without Firebase Tutorial

hanyelmehy

Active Member
Licensed User
Longtime User
As Google Say :
B4X:
Firebase is recommended, but optional

The best way to use AdMob is with Firebase, but for those publishers who aren't ready to make the switch just yet, Google Mobile Ads remains available as a standalone SDK.

Android publishers can continue to import the play-services-ads Gradle artifact without using the Firebase plugin.

Can any one Send Complete Tutorial how to integrate AdMob with latest google play service and B4a 6+
The reason for not using Firebase :
-just need admob
-i did not want to add more permission
-i did not want to register every app with firebase
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
There are three permissions added when you use Firebase:
B4X:
AddPermission(android.permission.WAKE_LOCK)
AddPermission(com.google.android.c2dm.permission.RECEIVE)
AddPermission(${applicationId}.permission.C2D_MESSAGE)
All three are "non-dangerous" permissions. You can remove them if you like and it will still work.

The latest AdMob library depends on Firebase. It includes many new features.

You can use the older AdMob library: https://www.b4x.com/android/forum/threads/admob-library.7301/#content
Did you get any error with it?
 
Upvote 0

hanyelmehy

Active Member
Licensed User
Longtime User
There are three permissions added when you use Firebase:
B4X:
AddPermission(android.permission.WAKE_LOCK)
AddPermission(com.google.android.c2dm.permission.RECEIVE)
AddPermission(${applicationId}.permission.C2D_MESSAGE)
All three are "non-dangerous" permissions. You can remove them if you like and it will still work.

The latest AdMob library depends on Firebase. It includes many new features.

You can use the older AdMob library: https://www.b4x.com/android/forum/threads/admob-library.7301/#content
Did you get any error with it?
Than you for your answer :
i use this code :
in manifest
B4X:
AddPermission(android.permission.INTERNET)
AddApplicationText(
   <activity android:name="com.google.android.gms.common.api.GoogleApiActivity"
  android:theme="@android:style/Theme.Translucent.NoTitleBar"
  android:exported="false"/>
    <meta-data
  android:name="com.google.android.gms.version"
  android:value="@integer/google_play_services_version" />
)
'AdMob
AddApplicationText(
<meta-data android:name="com.google.android.gms.version"
  android:value="@integer/google_play_services_version"/>
<activity android:name="com.google.android.gms.ads.AdActivity"
  android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>

)
'End of AdMob
Code :
B4X:
#AdditionalJar: com.google.android.gms:play-services-ads
#AdditionalJar: android-support-v4
Private BannerAd As AdView

BannerAd.Initialize2("BannerAd", "ca-app-pub-xxxxxxxxxxxx/xxxxx", BannerAd.SIZE_SMART_BANNER)
    Dim Adheight As Int
    If GetDeviceLayoutValues.ApproximateScreenSize < 6 Then 'phones
    If 100%x > 100%y Then Adheight = 32dip Else Adheight = 50dip
    Else
     Adheight = 90dip 'tablets
    End If
    Adheight = 50dip
    Activity.AddView(BannerAd, 0dip, 100%y - Adheight, 100%x, Adheight)
    BannerAd.LoadAd
i get :Failed To Receive Ad :error code 0 (mean internal error)
Notes :
- i use pub banner code with admob firebase and its work ,so the problem not in pub banner code
- i am using B4A 6+ ,android jar 23 ,google play service 37
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
It is better to use: #AdditionalJar: com.android.support:support-v4

Check the unfiltered logs. There might be more information.

As I previously wrote there is no good reason not to use Firebase. It will take you less time to setup the project then to find out why the old and deprecated library doesn't work for you.
 
Upvote 0
Top