Android Question Error trying to ad admob to my game

andymc

Well-Known Member
Licensed User
Longtime User
I'm seeing the error:

invalid resource directory name: C:\adt-bundle-windows-x86-20131030\sdk\extras\google\google_play_services\libproject\google-play-services_lib\res/drawable-xxhdpi


When trying to ad admob banners to my game.

I have installed the admob library and the google play services extra install to version 19.0.1 and upwards but keep getting this error when trying to compile.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Do you see all these folders?
SS-2014-04-23_08.38.34.png
 
Upvote 0

andymc

Well-Known Member
Licensed User
Longtime User
Thanks Erel. I've just done that but am still getting the same error.

The error occurs when trying to generate the R file. My manifest is as below:

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"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'End of default text.

'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

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

I have this in my project atributes:

B4X:
#AdditionalRes: C:\adt-bundle-windows-x86-20131030\sdk\extras\google\google_play_services\libproject\google-play-services_lib\res, com.google.android.gms
 
Upvote 0

andymc

Well-Known Member
Licensed User
Longtime User
I'm going to have to release this with no ads at all to start with and will then try putting leadbolt ads on. I've tried following the admob tutorial and I can't get it to work. I keep running into the 9 patch malformed errors and then if I rename all the files to .png instead of .9.png I just get a black ad view and the ad fails to load.
 
Upvote 0

andymc

Well-Known Member
Licensed User
Longtime User
It was, but then after looking at the referenced thread, I deleted that folder and then got the patch 9 png images error. I googled that problme and renamed all the *.9.png images to just *.png. I then got the app to comile and install but it fails to retrieve the ad. I have registered the ad and have tried using either my publisher id or the ad id but neither work.
 
Upvote 0

eps

Expert
Licensed User
Longtime User
Andy, do you get an error logged within your App?

You need to set the Ad Id in your code.

Something like this :

B4X:
    'AdMob gubbins

    AdView1.Initialize2("Ad", "ca-app-pub-123456789012/1234567890", AdView1.SIZE_SMART_BANNER) 'publisher id that you received from AdMob.

       
    Dim ScreenHeight, pScreenWidth As Int

    ScreenHeight = Activity.Height - 50dip
       

    pScreenWidth=GetDeviceLayoutValues.Width
       
    Activity.AddView(AdView1, 0dip, ScreenHeight, 100%x, 50dip) 'previously the height was 48dip. Now it is 50dip

    AdView1.LoadAd 'loads an ad

    'end of AdMob gubbins

and of course this in the Manifest Editor :

B4X:
AddApplicationText(

 <activity android:name="com.google.ads.AdActivity"

  android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>

  )

but I suspect you've already got both in place.... I guess you're not new to Admob are you? They seem to be a bit more strict on new accounts and verifying them - but they may well have been when I first registered, but that was around 3 years ago for me now, if not more.

I'm using version 1.40 of the Admob Library
 
Upvote 0

andymc

Well-Known Member
Licensed User
Longtime User
Looks like it may have been the wifi network I'm on blocking ad requests, I also switched to the smart banner size option, I wasn't using that before. I switched to my phone network and it seems to be working.

The playstore link is here:

https://play.google.com/store/apps/details?id=uk.co.coffeeinducedgames.invaders

I still have some extra features I want to add, like sharing your score on Facebook and google+ but I think it's okay for a first release.
 
  • Like
Reactions: eps
Upvote 0

andymc

Well-Known Member
Licensed User
Longtime User
Really???? Oh, bad bug!!! Thanks! I'll fix it now. I'm going to alter a few thing like making the levels get harder quicker and the aliens look better with more variety. I'll post the source code on my site in a few days.
 
Upvote 0

eps

Expert
Licensed User
Longtime User
and your exploding bitmap for the users ship needs to be transparent - I think it's background is black. So when the planet is behind the ship and you explode it shows up on a black rectangle.

:)
 
Upvote 0
Top