Android Question Error AdMob

monadhl

Member
Licensed User
Longtime User
مرحبا
حاولت تثبيت AdMob
لكني أظهر خطأ





كود الاعراب. 0.16
ترجمة التعليمات البرمجية. 0.23
تجميع كود التخطيطات. 0.03
توليد ملف R. 0.31
ترجمة ولدت كود جافا. خطأ
خط B4A: 98
Activity.AddView (AdView1، 0dip، 0dip، 320dip، 50dip) "AdView1.LoadAd" يقوم بتحميل إعلان
جافاك 1.7.0_65

^
ملف الفصل لـ com.google.android.gms.ads.AdView غير موجود
 
Last edited:

AllyAndroid

Member
Licensed User
Longtime User
There are a number of different things you need to do to get AdMob to work.

First, you need to add this to your Manifest Editor:

B4X:
'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"/>)
AddApplicationText(
<activity android:name="com.google.ads.AdActivity"
  android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
)
'End of AdMob

Next, this is added to the #Region Project Attributes in the main module:

B4X:
#Region  Project Attributes
    #AdditionalRes: C:\Program Files (x86)\Android\android-sdk\extras\google\google_play_services\libproject\google-play-services_lib\res, com.google.android.gms
#End Region

Next, this code needs to be added to the activity you want to display your ad:

B4X:
    ' Uncomment when ready to add ads.
    AdView1.Initialize("Ad", "##-###-###-###########################")    ' Replace # with Ad Your Mob ID.
    PanelAd.AddView(AdView1, (100%x - 320dip) / 2, 4dip, 320dip, 50dip)
    AdView1.LoadAd 'loads an ad
    '### End AdMob Block ###

Next, Add the following three subs:

B4X:
Sub Ad_FailedToReceiveAd (ErrorCode As String)
    Log("failed: " & ErrorCode)
End Sub
Sub Ad_ReceiveAd
    Log("received")
End Sub
Sub Ad_AdScreenDismissed
   Log("screen dismissed")
End Sub

Finally, every time you update your Google Play Services, you need to copy google-play-services.jar from your Android folder (IE: C:\Program Files (x86)\Android\android-sdk\extras\google\google_play_services\libproject\google-play-services_lib\libs) to your B4A Library folder.

A final check would be to make sure you are using the latest AdMob library. https://www.b4x.com/android/forum/threads/admob-library.7301/#post41711
 
Upvote 0

AllyAndroid

Member
Licensed User
Longtime User
Hmm, would need some more information about your setup.

Which version of B4A are you using?
Which AdMob Library are you using?
Which Google Play Service revision are you using?

For my setup I have B4A 4.0, AdMob 2.0, and Google Play Services 22.
 
Upvote 0

AllyAndroid

Member
Licensed User
Longtime User
I had mentioned that in my first post but with all the other stuff it was easily missed. I thought you had already checked it which is why I couldn't think of anything else that might be the issue. Luckily we have Earl and the others to help us out when we get stuck.
 
Upvote 0

edwardcaceres

New Member
Licensed User
Hello
I tried installing AdMob
But I show an error





Parsing code. 0.16
Compiling code. 0.23
Compiling layouts code. 0.03
Generating R file. 0.31
Compiling generated Java code. Error
B4A line: 98
Activity.AddView(AdView1, 0dip, 0dip, 320dip, 50dip)' AdView1.LoadAd 'loads an ad
javac 1.7.0_65
src\com\Hours\astrology\General\monadhl\main.java:464: error: cannot access AdView
mostCurrent._activity.AddView((android.view.View)(mostCurrent._adview1.getObject()),anywheresoftware.b4a.keywords.Common.DipToCurrent((int) (0)),anywheresoftware.b4a.keywords.Common.DipToCurrent((int) (0)),anywheresoftware.b4a.keywords.Common.DipToCurrent((int) (320)),anywheresoftware.b4a.keywords.Common.DipToCurrent((int) (50)));
^
class file for com.google.android.gms.ads.AdView not found



The problem is the AppCompat libray
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
The problem is the AppCompat libray
I´m pretty sure AppCompat is not the problem.

Anyway: This is an old thread.

If you have any question then please start a new thread.
 
Upvote 0
Top