Android Question admob runtime error re. missing declaration

RichyK68

Active Member
Licensed User
Longtime User
Hi,

I'm getting the error message "an error has occurred in sub... you must have the following declaration within the <application> element: <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />" when I run my app using the admob library.

My manifest looks like:

B4X:
'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: http://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="14"/>
<supports-screens android:largeScreens="true" 
    android:normalScreens="true" 
    android:smallScreens="true" 
    android:anyDensity="true"/>   
)
'AdMob
AddApplicationText(
 <activity android:name="com.google.ads.AdActivity"
  android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
)
AddApplicationText(<meta-data
   android:name="com.google.android.gms.version"
   android:value="@integer/google_play_services_version" />)
'End of AdMob
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'End of default text.

It has the meta data tag in there already, any idea why the error would be happening?

Richard
 

GMan

Well-Known Member
Licensed User
Longtime User
Hoi,

did you use the SEARCH before ? There are several threads.
Here is the Tutorial thread:
http://www.b4x.com/android/forum/threads/admob-tutorial-add-ads-to-your-application.7300/
and here the one with the AdMob library:
http://www.b4x.com/android/forum/threads/admob-library.7301/

Bes ure to use the newest Lib from B4A and the new Google Services in the ADK (all written in the given links)

The error depends on a wrong part in the Manifest Editor ...OR in the pub key: how do you implemented it ?
 
Upvote 0

RichyK68

Active Member
Licensed User
Longtime User
Hi,

I believe I've done all that, I'm currently using AdMob v2.00 from the admob.zip as opposed to the oldadmob.zip, and I've downloaded the Google Play Services jar file via the Android SDK toolkit though I'm not sure how to find out what version that is.

Richard
 
Upvote 0

GMan

Well-Known Member
Licensed User
Longtime User
Try this in the Manifest editor:
B4X:
'AdMob
AddApplicationText(
<activity android:name="com.google.ads.AdActivity"
  android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
)
'End of AdMob
 
Upvote 0

RichyK68

Active Member
Licensed User
Longtime User
That's already in there, which is why I added the

B4X:
AddApplicationText(<meta-data
 android:name="com.google.android.gms.version"
 android:value="@integer/google_play_services_version" />)

:)

Richard
 
Upvote 0

RichyK68

Active Member
Licensed User
Longtime User
Hi, yes, I've been through the examples multiple times.

I now see the slight difference in the AddApplicationText that GMan posted. The app now runs but I get a FailedToReceiveAd response with an error code of 0 which is ERROR_CODE_INTERNAL_ERROR (I'm using the correct publisher id because if I don't I get an error code of 1 (ERROR_CODE_INVALID_REQUEST)).

I'm initiating the ad with

B4X:
    AdView1.Initialize2("Ad", "mypublisherid", AdView1.SIZE_BANNER) 'publisher id that you received from AdMob.
    Activity.AddView(AdView1, 0dip, 0dip, 320dip, 50dip)
    AdView1.LoadAd 'loads an ad

Maybe it takes a while for Admob to dish out ads, maybe I'll start getting ads soon.

Richard
 
Upvote 0

RichyK68

Active Member
Licensed User
Longtime User
This is now my manifest after replacing what I'd got with what is in the tutorial:

B4X:
'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: http://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="14"/>
<supports-screens android:largeScreens="true" 
    android:normalScreens="true" 
    android:smallScreens="true" 
    android:anyDensity="true"/>   
)

'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


SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'End of default text.

Is there anything wrong with this?

Richard
 
Upvote 0

GMan

Well-Known Member
Licensed User
Longtime User
Are you really SURE that you configured ALL parts of AdMob and you App in AdMob, including networks for your country ?
 
Upvote 0

RichyK68

Active Member
Licensed User
Longtime User
I think so, in Admob Settings there is the Ad Network Optimization Settings where you can add (what I think are) other sources of ads, and the ones I get are InMobi, JumpTap, MdotM and MobFox but I don't need to add those do I? They require logons/ids etc and I've never signed up with those, just Google Admob. Where do I configure networks for my country?

Richard
 
Upvote 0

RichyK68

Active Member
Licensed User
Longtime User
Thank you, I literally hadn't set up Ad units for the app, I had only linked the app to the Ad Mob account, which is what I thought I just had to do.

Cheers :)
 
Upvote 0

GMan

Well-Known Member
Licensed User
Longtime User
Thank you, I literally hadn't set up Ad units for the app, I had only linked the app to the Ad Mob account, which is what I thought I just had to do.
Yo, mostly is that part missing when problems appear :cool: therefore i made this little TuT ;)
 
Upvote 0
Top