AdMob unusable error

canalrun

Well-Known Member
Licensed User
Longtime User
Hello,
I am trying to incorporate AdMod into an app.
I downloaded the AdMob library a few days ago.
I get the following error:

Compiling generated Java code. Error
B4A line: 31
Panel4.AddView(AdView1, 0dip, 0dip, 320dip, 50dip)
javac 1.6.0_21
src\canalrun\apps\aslalpha\main.java:202: cannot access com.google.ads.AdView
class file for com.google.ads.AdView not found

Searching the forums, I see somebody else has this problem and identified the solution. The forum post is shown below.

I would agree that this needs immediate attention. Maybe it's just a fix in the XML file - in which case he can do that ourselves.

Thanks,
Barry.


------------------------------------------------
Inman Inman is offline
Knows the basics

Join Date: Feb 2011
Posts: 63
Default
I think I found the issue. Looks like Admob made some changes to SDK JAR file, which was not updated in the B4A library. The obvious change is filename (from admob-sdk-android.rar to GoogleAdMobAdsSdk-4.0.2.jar). Then inside the JAR file, B4A expects the class file to be at com.admob.android.ads.AdView but the folder structure has changed to com.google.ads.Adview. The name of the Adview classes have also been changed in the Adview.class and may be other class files.

Most probably all this have to be due to Google's acquisition of Admob and they are changing all com.admob.android.ads references to com.google.ads. I hope Erel will update the B4A Admob library immediately. Till then Admob is unusable.
-------------------------------------------------
 

Inman

Well-Known Member
Licensed User
Longtime User
Actually Erel updated AdMob library after my post and it is working fine now.

Did you make the necessary changes to AndroidManifest.xml file in the Objects folder, to set the correct permissions for AdMob? And if you did make the change, did you set the AndroidManifest.xml file to read only, after doing so? Otherwise it will get overwritten by B4A every time you compile and therefore AdMob permissions will get removed.
 
Upvote 0

canalrun

Well-Known Member
Licensed User
Longtime User
Thanks for the replies.

I have followed the tutorials and checked it pretty carefully, but I will download and reinstall all the admob stuff following the tutorials again.

I see that the dates on the files are fairly new so I also wouldn't expect the error I am seeing.

Since you confirmed it should work, I must be doing something incorrectly.

Thanks,
Barry.
 
Upvote 0

canalrun

Well-Known Member
Licensed User
Longtime User
Please update us whether it succeeded or not.

Hi,
I deleted everything that had to with AdMob and B4A, then followed the tutorial line by line:

http://www.b4x.com/forum/basic4andr...-admob-tutorial-add-ads-your-application.html

A few things:
The GoogleAdMobAdsSdkAndroid-x.x.x.jar library is now version 4.0.4. You reference 4.0.2.

What seems to be a spelling mistake; the files no longer have "Android" appended to the name. I noticed the XML file in your AdMod.zip file no longer has "Android" appended either. I had to take the "Android" off the jar file name or upon opening B4A, I would get an error referencing GoogleAdMobAdsSDK.xml saying jar file not found. The tutorial still has "Android" appended to the names in step 3.

I get the same error when compiling:

Compiling code. 0.02
Using existing readonly AndroidManifest.xml
Generating R file. 0.00
Compiling generated Java code. Error
B4A line: 31
Activity.AddView(AdView1, 0dip, 0dip, 320dip, 50dip)
javac 1.6.0_21
src\canalrun\apps\aslalpha\main.java:202: cannot access com.google.ads.AdView
class file for com.google.ads.AdView not found
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)));

Here is my B4A "other libraries" directory:

Directory of C:\Users\Barry\Android Dev\Basic4Android\AdLibs

04/17/2011 03:27 PM <DIR> .
04/17/2011 03:27 PM <DIR> ..
03/23/2011 09:11 AM 3,355 AdMob.jar
03/23/2011 09:26 AM 6,991 AdMob.xml
03/24/2011 03:28 PM 159,463 GoogleAdMobAdsSdk.jar
01/12/2011 11:55 AM 163 GoogleAdMobAdsSDK.xml
4 File(s) 169,972 bytes
2 Dir(s) 383,215,050,752 bytes free

My code and XML file look almost exactly like the tutorial.

Thanks,
Barry.
 
Upvote 0

canalrun

Well-Known Member
Licensed User
Longtime User
You are correct about the name which should be GoogleAdMobAdsSdk.

Just to make sure, did you add a reference in the Libraries tab to both AdMob and GoogleAdMobAdsSdk?

Whoops! Thanks you found it!

I had added the AdMob's library in the library tabs, but I did not add the Google library in the library's tabs.

Can I make a request? In the tutorial while you are fixing the "Android" typo, could you modify step 1 of the "Adding AdMob to your Application" to read something like:

In the B4A library tab on the right-hand side of the B4A IDE, enable references to the AdMod and GoogleAdMobAdsSdk.

I read right over that step thinking it referred to the listings beneath it. I only learned about enabling the AdMob library by reading a forum post, but I did not see a mention the Google library - maybe it's just me.

Again, thanks so much for your help.

A quick question - I see references in the forums to testing an application with AdMob and the emulator or a phone connected by the B4A Bridge, but I am not sure whether they relate to an old version of the AdMob library or this new version.

Could I ask what I should do and what precautions I should take while testing to be sure the ads served aren't counted as being paid for with both the emulator and testing on my phone?

Also what should I be sure to do with respect to the AdMob library and my application before releasing the application for real?

Thanks,
Barry.
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…