4

I am trying to implement AdMob in my Application. But dont know somehow its showing this error and my R.java file is not being generated due to it. I have tried all the ways to solve this problem, like Clean,Build, Build All. But non is working for me. Following my code snippet in which its showing error "Error in parsing XML: Unbound prefix"

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:background="@color/bgcolor"> <LinearLayout android:id="@+id/Linearlayout1" android:layout_width="fill_parent" android:layout_height="wrap_content" > <com.google.ads.AdView android:id="@+id/adView" android:layout_width="wrap_content" android:layout_height="wrap_content" ads:adSize="BANNER" ads:adUnitId="XXX" ads:refreshInterval="60"/> </LinearLayout> 

Please help me out. I am stuck here :(

3 Answers 3

17

Probably a namespace issue. You have to define the namespace.

try adding

xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"

Sign up to request clarification or add additional context in comments.

3 Comments

I tried adding above line, but then also its not working. For above to work, do I also have to make 'lib' folder in 'res' directory and copy the AdMob jar into it??
Later when I again rebuild and clean the project, the above solution worked for me. Thanks for Eren
One more thing to be done here is that, when I was trying the above code using 'libs' folder, the ads were not getting displayed. But when I changed it to 'lib' then its working without hassle.
6

New Admob SDK (Google Play services) requiried another namespace

xmlns:ads="http://schemas.android.com/apk/res-auto" 

Comments

3
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" android:layout_width="fill_parent" android:id="@+id/rltvLayoutPromote" android:layout_height="fill_parent"> <LinearLayout android:id="@+id/linearLayoutwebview" android:layout_height="wrap_content" android:layout_width="wrap_content" android:orientation="vertical"> <WebView android:id="@+id/webViewPromote" android:layout_width="fill_parent" android:layout_height="fill_parent" android:fitsSystemWindows="true" /> </LinearLayout> <LinearLayout android:layout_width="fill_parent" android:id="@+id/ad_layout" android:layout_height="wrap_content" android:gravity="bottom" android:layout_alignParentBottom="true" android:layout_alignBottom="@+id/home_layout"> <com.google.ads.AdView android:layout_width="wrap_content" android:layout_height="wrap_content" ads:adUnitId="XXXXXXXXXX" ads:adSize="BANNER" android:id="@+id/adView" ads:refreshInterval="60" /> <!-- put 3 if not working--> </LinearLayout> </RelativeLayout> 

and put this lines in manifest.xml file

 <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <meta-data android:value="true" android:name="ADMOB_ALLOW_LOCATION_FOR_ADS" /> 

the above code is working perfectly for me... visit this site for complete reference help forandroid-admob
Thanks Pragna

7 Comments

What I am trying to do is little snippet as follows. Can you check it and tell me where I am doing mistake?
As I am a beginner, I am not permissible to add comments more then the character limits I've permitted. So I've edited my question and included little more code in it
which apk version u r using for this?let me know
yes your code is working for me i've tried using android 1.4 i think you are missing to add jar file visit this site code.google.com/mobile/ads/docs/android/fundamentals.html for complete reference
I m trying this on Android 1.6. Also I've added GoogleAdMobAdsSDK .jar file. But den also the ads are not being displayed when I run my app in the emulator
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.