Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error: No resource identifier found for attribute 'adSize' in package 'com.google.example' main.xml

Tags:

android

admob

Replace /res/ with /lib/ in your custom layout nampespace.

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

in your case, would be:

xmlns:yourApp="http://schemas.android.com/apk/lib/com.yourAppPackege.yourClass"

I hope it helps.


I had the same problem. I copied the example code from Google code, and could not compile.

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

Finally, I figured it out. The last part of the code "com.google.example", is their package name, so you need to replace it with your project package.

For example, my project package is "com.jms.AdmobExample", so my ads naming space is:

xmlns:ads="http://schemas.android.com/apk/res/com.jms.AdmobExample"

Check my example, it works fine. You can download the APK to try. I also put my source code here: Add Google Admob in Android Application


for me, I have to add

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

right after:

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

in res/layout/main.xml


You can also use http://schemas.android.com/apk/res-auto that would take care of it automatically. Use it like this:

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

I had the same problem, but while using a library project. The issue has been solved in r17: Instead of using the package's namespace:

xmlns:app="http://schemas.android.com/apk/res/hu.droidium.exercises"

One has to use a dummy namespace:

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

This will fix the problem of the attributes not being accessible from the referencing project.


i download the same custom-demo from Android.com and get the same complie problem.

at frist ,i change

xmlns:custom="http://schemas.android.com/apk/res/com.example.android.customviews"

to

xmlns:custom="http://schemas.android.com/apk/lib/com.example.android.customviews"

it work . then i get another solution

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

it also work, but there are some differencies. The second solution has prefect function . i am finding the reason , may be you can have a hand in. thanks


As you specify in your attrs.xml your adSize attribute belongs to the namespace com.google.ads.AdView. Try to change:

android:adUnitId="a14bd6d2c63e055"         android:adSize="BANNER"

to

ads:adUnitId="a14bd6d2c63e055"         ads:adSize="BANNER"

and it should work.