When I followed the instructions to add an ad into my app by xml, I got the following errors:
Description Resource Path Location Type
error: No resource identifier found for attribute 'adSize' in package 'com.google.example' main.xml /HelloWorld/res/layout line 12 Android AAPT Problem
Description Resource Path Location Type
error: No resource identifier found for attribute 'adUnitId' in package 'com.google.example' main.xml /HelloWorld/res/layout line 12 Android AAPT Problem
I did edit the main.xml
, add attrs.xml
file but the compiler didn’t like it.
einverne
6,2745 gold badges44 silver badges91 bronze badges
asked Apr 28, 2011 at 13:27
1
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"
answered Jan 12, 2013 at 23:45
M_AWADIM_AWADI
4,0861 gold badge18 silver badges12 bronze badges
7
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
the Tin Man
157k41 gold badges211 silver badges300 bronze badges
answered Apr 30, 2011 at 17:45
JamesJames
5,0995 gold badges24 silver badges27 bronze badges
5
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
answered May 14, 2012 at 8:16
ZennichimaroZennichimaro
5,1165 gold badges53 silver badges77 bronze badges
2
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"
answered Dec 4, 2013 at 19:21
Bms270Bms270
1,58615 silver badges18 bronze badges
1
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.
answered Oct 8, 2014 at 16:16
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
answered Jul 16, 2015 at 3:41
BillBill
1,26814 silver badges14 bronze badges
1
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.
Mat
200k40 gold badges389 silver badges404 bronze badges
answered Nov 11, 2011 at 8:09
P-AP-A
1,12112 silver badges16 bronze badges
1
I received this error with regards to the largeHeap Attribute, my application did not run under eclipse but under ant it still built and ran normally.
The android documentation states that:
attributes:
xmlns:android
Defines the Android namespace. This attribute should always be set to «
http://schemas.android.com/apk/res/android
«.
I erased that line in my manifest, saved in eclipse, pasted the line back in and saved again, and it worked. In my case I guess the problem was eclipse, ant and adb not talking to each other correctly and the saving reset something. Interestingly restarting eclipse did not solve this problem (usually with these types of problems restarting eclipse is the first thing you should try, and usually it solves the problem).
qtmfld
2,8562 gold badges20 silver badges36 bronze badges
answered Dec 21, 2011 at 15:48
tjbtjb
11.3k9 gold badges68 silver badges89 bronze badges
2
Make Sure you have included this part in your layout (top below xmlns:android line)
xmlns:ads="http://schemas.android.com/apk/res/com.google.example"
...........blah blah..
Also Check whether you have included attrs.xml in the res/values/
Check here for more details.
http://code.google.com/mobile/ads/docs/android/banner_xml.html
answered Apr 30, 2011 at 6:18
0
I usually embed the xmlns:ads property into the adview properties this way:
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="@string/banner_ad_unit_id"/>
so that you dont need to embed into the parent every and each time you copy the adview.
Just copy and paste the adview above and paste it anywhere and it should work
answered Sep 5, 2016 at 9:22
MBHMBH
16k19 gold badges97 silver badges148 bronze badges
I’ve been searching answer but couldn’t find but finally I could fix this by adding play-service-ads
dependency let’s try this:
*) File -> Project Structure… -> Under the module you can find app and there is a option called dependencies and you can add com.google.android.gms:play-services-ads:x.x.x dependency to your project
I faced this problem when I try to import Eclipse projects into Android Studio.
answered Dec 16, 2016 at 6:14
HashanRHashanR
1943 silver badges15 bronze badges
In my case, I was missing a dependency in the app level build.gradle.
The solution was to add the dependency as google outlines below:
Open the app-level build.gradle file for your app, and look for a «dependencies» section.
dependencies {
implementation ...SOME_IMPLEMENTATION
implementation ...SOME_IMPLEMENTATION
implementation 'com.google.android.gms:play-services-ads:18.1.1'//<---ADD THIS LINE
}
Add the line above, which instruct Gradle to pull in the latest version of the Mobile Ads SDK and additional related dependencies. Once that’s done, save the file and perform a Gradle sync.
answered Aug 25, 2019 at 14:11
jwitt98jwitt98
1,1741 gold badge16 silver badges30 bronze badges
Based on the answer here, I think you need to change the xmlns:ads attribute. For example, change this:
<com.google.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res/com.google.example"
...
/>
to this:
<com.google.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res/com.your.app.namespace"
...
/>
It fixed it for me. If you’re still getting errors, could you elaborate?
qtmfld
2,8562 gold badges20 silver badges36 bronze badges
answered Apr 28, 2011 at 22:07
emceeemcee
8431 gold badge9 silver badges11 bronze badges
I also faced the same problem, I was using GoogleAdMobAdsSDK-4.1.0.jar
then I tried with GoogleAdMobAdsSDK-4.0.4.jar
now it is working fine, It is problem with jar file as per my experience.
biegleux
13.2k11 gold badges44 silver badges52 bronze badges
answered Aug 6, 2012 at 6:42
I had a similar issue on MonoDroid when building a class library with Drawables and Layouts files that have "android:"
attribute in the xml. I get a similar error as the one in the question.
No resource identifier found for attribute ‘textCursorDrawable’ in
package ‘android’
I found from that «android: » attribute is only available in Android API Level 12+ and I was trying to build for an older version. Updating my project to build against Android 4.0 fixed the issue for me.
Here is where I found the answer.
https://groups.google.com/forum/?fromgroups#!topic/android-developers/ocxKphM5MWM
Just make sure that you are building against the right API level if you get a similar issue, and ensure that the missing identifier exists in that API level that you are build against.
answered May 17, 2013 at 0:59
Has AlTaiarHas AlTaiar
4,0002 gold badges35 silver badges37 bronze badges
just change the target sdk right click on project then click on
property select android and select the latest API
answered Nov 19, 2013 at 6:37
The same error was happening to me in the «activity_banner_xml.xml» file inside res/layout folder. What I did to fix it was replace
<com.google.android.gms.samples.ads.AdView
with
<com.google.android.gms.ads.AdView
There was no references to my package name.
Also, be sure you set the adUnitId for ads:adUnitId="@string/banner_ad_unit_id">
The add unit Id is located in your res/Values/Strings folder.
So my final layout file looks like this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/mainLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
ads:adSize="BANNER"
ads:adUnitId="@string/ad_unit_id"/>
answered Sep 21, 2014 at 21:23
GeneGene
10.6k1 gold badge65 silver badges57 bronze badges
If yours is a gradle project replace:
xmlns:android="http://schemas.android.com/apk/res/android"
with:
xmlns:app="http://schemas.android.com/apk/res-auto"
chiwangc
3,52816 gold badges25 silver badges32 bronze badges
answered Jan 22, 2015 at 2:12
Sahana PSahana P
731 silver badge11 bronze badges
I am adding the solution that worked for me for this same error.
I right clicked project > properties > (left panel) Android
Right panel under Library
I removed the faulty library and added it again.
For me this error occurred after a corrupt workspace eclipse file where I had to import all projects again.
answered Oct 12, 2015 at 14:15
OnimushaOnimusha
3,3182 gold badges25 silver badges32 bronze badges
0
My problem was very similar (produces same problem). After refactoring variable name by «refactor -> rename» option in Android Studio (from «value» to «myValue») i found changes in manifest file, too. Meta-data «value» pool has changed to «myValue».
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:myValue="@string/facebook_app_id"/>
After revert file everything seams to be ok again.
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id"/>
I hope, it will help someone!
answered Mar 24, 2017 at 11:23
Add xmlns:ads=»http://schemas.android.com/apk/lib/com.google.ads»,
This will solve your Issue.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.app.activities.Initializer" >
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-123456789/123456789"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
</RelativeLayout>
answered Apr 13, 2017 at 18:09
Replace
xmlns:android="http://schemas.android.com/apk/res/android"
with
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
then Rebuild Project
answered May 9, 2017 at 7:04
ShubhamhackzShubhamhackz
6,9056 gold badges50 silver badges69 bronze badges
I added in android.support.design.widget.NawigationView this parameter:
android:layout_gravity="start"
And problem was solved.
Sᴀᴍ Onᴇᴌᴀ
8,1028 gold badges32 silver badges58 bronze badges
answered Jul 3, 2017 at 22:49
PUT
compile 'de.hdodenhof:circleimageview:2.0.0'
IN Gradle Dependencies and put this code in nav_header_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/lib/org.mainsoft.navigationdrawer"
android:gravity="bottom"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:theme="@style/ThemeOverlay.AppCompat.Dark"
android:layout_width="match_parent"
android:layout_height="160dp"
android:background="@drawable/background_material_red"
android:orientation="vertical">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/profile_image"
android:layout_width="70dp"
android:layout_height="70dp"
android:src="@drawable/profile"
app:border_color="#FF000000"
android:layout_marginLeft="24dp"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginStart="24dp" />
</LinearLayout>
answered Apr 23, 2016 at 19:09
When I followed the instructions to add an ad into my app by xml, I got the following errors:
Description Resource Path Location Type
error: No resource identifier found for attribute 'adSize' in package 'com.google.example' main.xml /HelloWorld/res/layout line 12 Android AAPT Problem
Description Resource Path Location Type
error: No resource identifier found for attribute 'adUnitId' in package 'com.google.example' main.xml /HelloWorld/res/layout line 12 Android AAPT Problem
I did edit the main.xml
, add attrs.xml
file but the compiler didn’t like it.
einverne
6,2745 gold badges44 silver badges91 bronze badges
asked Apr 28, 2011 at 13:27
1
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"
answered Jan 12, 2013 at 23:45
M_AWADIM_AWADI
4,0861 gold badge18 silver badges12 bronze badges
7
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
the Tin Man
157k41 gold badges211 silver badges300 bronze badges
answered Apr 30, 2011 at 17:45
JamesJames
5,0995 gold badges24 silver badges27 bronze badges
5
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
answered May 14, 2012 at 8:16
ZennichimaroZennichimaro
5,1165 gold badges53 silver badges77 bronze badges
2
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"
answered Dec 4, 2013 at 19:21
Bms270Bms270
1,58615 silver badges18 bronze badges
1
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.
answered Oct 8, 2014 at 16:16
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
answered Jul 16, 2015 at 3:41
BillBill
1,26814 silver badges14 bronze badges
1
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.
Mat
200k40 gold badges389 silver badges404 bronze badges
answered Nov 11, 2011 at 8:09
P-AP-A
1,12112 silver badges16 bronze badges
1
I received this error with regards to the largeHeap Attribute, my application did not run under eclipse but under ant it still built and ran normally.
The android documentation states that:
attributes:
xmlns:android
Defines the Android namespace. This attribute should always be set to «
http://schemas.android.com/apk/res/android
«.
I erased that line in my manifest, saved in eclipse, pasted the line back in and saved again, and it worked. In my case I guess the problem was eclipse, ant and adb not talking to each other correctly and the saving reset something. Interestingly restarting eclipse did not solve this problem (usually with these types of problems restarting eclipse is the first thing you should try, and usually it solves the problem).
qtmfld
2,8562 gold badges20 silver badges36 bronze badges
answered Dec 21, 2011 at 15:48
tjbtjb
11.3k9 gold badges68 silver badges89 bronze badges
2
Make Sure you have included this part in your layout (top below xmlns:android line)
xmlns:ads="http://schemas.android.com/apk/res/com.google.example"
...........blah blah..
Also Check whether you have included attrs.xml in the res/values/
Check here for more details.
http://code.google.com/mobile/ads/docs/android/banner_xml.html
answered Apr 30, 2011 at 6:18
0
I usually embed the xmlns:ads property into the adview properties this way:
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="@string/banner_ad_unit_id"/>
so that you dont need to embed into the parent every and each time you copy the adview.
Just copy and paste the adview above and paste it anywhere and it should work
answered Sep 5, 2016 at 9:22
MBHMBH
16k19 gold badges97 silver badges148 bronze badges
I’ve been searching answer but couldn’t find but finally I could fix this by adding play-service-ads
dependency let’s try this:
*) File -> Project Structure… -> Under the module you can find app and there is a option called dependencies and you can add com.google.android.gms:play-services-ads:x.x.x dependency to your project
I faced this problem when I try to import Eclipse projects into Android Studio.
answered Dec 16, 2016 at 6:14
HashanRHashanR
1943 silver badges15 bronze badges
In my case, I was missing a dependency in the app level build.gradle.
The solution was to add the dependency as google outlines below:
Open the app-level build.gradle file for your app, and look for a «dependencies» section.
dependencies {
implementation ...SOME_IMPLEMENTATION
implementation ...SOME_IMPLEMENTATION
implementation 'com.google.android.gms:play-services-ads:18.1.1'//<---ADD THIS LINE
}
Add the line above, which instruct Gradle to pull in the latest version of the Mobile Ads SDK and additional related dependencies. Once that’s done, save the file and perform a Gradle sync.
answered Aug 25, 2019 at 14:11
jwitt98jwitt98
1,1741 gold badge16 silver badges30 bronze badges
Based on the answer here, I think you need to change the xmlns:ads attribute. For example, change this:
<com.google.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res/com.google.example"
...
/>
to this:
<com.google.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res/com.your.app.namespace"
...
/>
It fixed it for me. If you’re still getting errors, could you elaborate?
qtmfld
2,8562 gold badges20 silver badges36 bronze badges
answered Apr 28, 2011 at 22:07
emceeemcee
8431 gold badge9 silver badges11 bronze badges
I also faced the same problem, I was using GoogleAdMobAdsSDK-4.1.0.jar
then I tried with GoogleAdMobAdsSDK-4.0.4.jar
now it is working fine, It is problem with jar file as per my experience.
biegleux
13.2k11 gold badges44 silver badges52 bronze badges
answered Aug 6, 2012 at 6:42
I had a similar issue on MonoDroid when building a class library with Drawables and Layouts files that have "android:"
attribute in the xml. I get a similar error as the one in the question.
No resource identifier found for attribute ‘textCursorDrawable’ in
package ‘android’
I found from that «android: » attribute is only available in Android API Level 12+ and I was trying to build for an older version. Updating my project to build against Android 4.0 fixed the issue for me.
Here is where I found the answer.
https://groups.google.com/forum/?fromgroups#!topic/android-developers/ocxKphM5MWM
Just make sure that you are building against the right API level if you get a similar issue, and ensure that the missing identifier exists in that API level that you are build against.
answered May 17, 2013 at 0:59
Has AlTaiarHas AlTaiar
4,0002 gold badges35 silver badges37 bronze badges
just change the target sdk right click on project then click on
property select android and select the latest API
answered Nov 19, 2013 at 6:37
The same error was happening to me in the «activity_banner_xml.xml» file inside res/layout folder. What I did to fix it was replace
<com.google.android.gms.samples.ads.AdView
with
<com.google.android.gms.ads.AdView
There was no references to my package name.
Also, be sure you set the adUnitId for ads:adUnitId="@string/banner_ad_unit_id">
The add unit Id is located in your res/Values/Strings folder.
So my final layout file looks like this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/mainLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
ads:adSize="BANNER"
ads:adUnitId="@string/ad_unit_id"/>
answered Sep 21, 2014 at 21:23
GeneGene
10.6k1 gold badge65 silver badges57 bronze badges
If yours is a gradle project replace:
xmlns:android="http://schemas.android.com/apk/res/android"
with:
xmlns:app="http://schemas.android.com/apk/res-auto"
chiwangc
3,52816 gold badges25 silver badges32 bronze badges
answered Jan 22, 2015 at 2:12
Sahana PSahana P
731 silver badge11 bronze badges
I am adding the solution that worked for me for this same error.
I right clicked project > properties > (left panel) Android
Right panel under Library
I removed the faulty library and added it again.
For me this error occurred after a corrupt workspace eclipse file where I had to import all projects again.
answered Oct 12, 2015 at 14:15
OnimushaOnimusha
3,3182 gold badges25 silver badges32 bronze badges
0
My problem was very similar (produces same problem). After refactoring variable name by «refactor -> rename» option in Android Studio (from «value» to «myValue») i found changes in manifest file, too. Meta-data «value» pool has changed to «myValue».
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:myValue="@string/facebook_app_id"/>
After revert file everything seams to be ok again.
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id"/>
I hope, it will help someone!
answered Mar 24, 2017 at 11:23
Add xmlns:ads=»http://schemas.android.com/apk/lib/com.google.ads»,
This will solve your Issue.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.app.activities.Initializer" >
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-123456789/123456789"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
</RelativeLayout>
answered Apr 13, 2017 at 18:09
Replace
xmlns:android="http://schemas.android.com/apk/res/android"
with
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
then Rebuild Project
answered May 9, 2017 at 7:04
ShubhamhackzShubhamhackz
6,9056 gold badges50 silver badges69 bronze badges
I added in android.support.design.widget.NawigationView this parameter:
android:layout_gravity="start"
And problem was solved.
Sᴀᴍ Onᴇᴌᴀ
8,1028 gold badges32 silver badges58 bronze badges
answered Jul 3, 2017 at 22:49
PUT
compile 'de.hdodenhof:circleimageview:2.0.0'
IN Gradle Dependencies and put this code in nav_header_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/lib/org.mainsoft.navigationdrawer"
android:gravity="bottom"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:theme="@style/ThemeOverlay.AppCompat.Dark"
android:layout_width="match_parent"
android:layout_height="160dp"
android:background="@drawable/background_material_red"
android:orientation="vertical">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/profile_image"
android:layout_width="70dp"
android:layout_height="70dp"
android:src="@drawable/profile"
app:border_color="#FF000000"
android:layout_marginLeft="24dp"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginStart="24dp" />
</LinearLayout>
answered Apr 23, 2016 at 19:09
Information
- Apktool Version (
apktool -2.2.2
) - Operating System (
Windows
) - APK From? (
ROM
) - ROM Info(
ASUS Padfone S 4.4..2 stock
)
Stacktrace/Logcat
W:brut.androlib.AndrolibException: brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [C:UsersADMINI~1AppDataLocalTempbrut_util_Jar_1576552267211253615.tmp, p, --forced-package-id, 127, --min-sdk-version, 9, --target-sdk-version, 23, --version-code, 10545440, --version-name,0.2.4-81-gb1e98ea, --no-version-vectors, -F, C:UsersADMINI~1AppDataLocalTempAPKTOOL5181806592759903079.tmp, -0, arsc, -0, so, -0, arsc, -I, C:UsersAdministratorAppDataLocalapktoolframework1.apk, -S, D:WayneProgrammingapktoolmicrogres, -M,D:WayneProgrammingapktoolmicrogAndroidManifest.xml] at brut.androlib.Androlib.buildResourcesFull(Androlib.java:477) at brut.androlib.Androlib.buildResources(Androlib.java:411) at brut.androlib.Androlib.build(Androlib.java:310) at brut.androlib.Androlib.build(Androlib.java:263) at brut.apktool.Main.cmdBuild(Main.java:227) at brut.apktool.Main.main(Main.java:84) Caused by: brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [C:UsersADMINI~1AppDataLocalTempbrut_util_Jar_15765 52267211253615.tmp, p, --forced-package-id, 127, --min-sdk-version, 9, --target- sdk-version, 23, --version-code, 10545440, --version-name, 0.2.4-81-gb1e98ea, -- no-version-vectors, -F, C:UsersADMINI~1AppDataLocalTempAPKTOOL518180659275 9903079.tmp, -0, arsc, -0, so, -0, arsc, -I, C:UsersAdministratorAppDataLoca lapktoolframework1.apk, -S, D:WayneProgrammingapktoolmicrogres, -M, D:W ayneProgrammingapktoolmicrogAndroidManifest.xml] at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.jav a:440) at brut.androlib.Androlib.buildResourcesFull(Androlib.java:463) ... 5 more Caused by: brut.common.BrutException: could not exec (exit code = 1): [C:Users ADMINI~1AppDataLocalTempbrut_util_Jar_1576552267211253615.tmp, p, --forced-p ackage-id, 127, --min-sdk-version, 9, --target-sdk-version, 23, --version-code, 10545440, --version-name, 0.2.4-81-gb1e98ea, --no-version-vectors, -F, C:Users ADMINI~1AppDataLocalTempAPKTOOL5181806592759903079.tmp, -0, arsc, -0, so, -0 , arsc, -I, C:UsersAdministratorAppDataLocalapktoolframework1.apk, -S, D:WayneProgrammingapktoolmicrogres, -M, D:WayneProgrammingapktoolmicrogAndroidManifest.xml] at brut.util.OS.exec(OS.java:95) at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.java:434) ... 6 more W: D:WayneProgrammingapktoolmicrogresdrawable-anydpi-v21dots_horizontal.x ml:4: error: No resource identifier found for attribute 'fillColor' in package 'android' W: D:WayneProgrammingapktoolmicrogresdrawable-anydpi-v21dots_horizontal.x ml:4: error: No resource identifier found for attribute 'pathData' in package 'android' W: D:WayneProgrammingapktoolmicrogresdrawable-anydpi-v21gcm_bell.xml:2: e rror: No resource identifier found for attribute 'viewportWidth' in package 'android' W: D:WayneProgrammingapktoolmicrogresdrawable-anydpi-v21gcm_bell.xml:2: e rror: No resource identifier found for attribute 'viewportHeight' in package 'android' W: D:WayneProgrammingapktoolmicrogresdrawable-anydpi-v21gcm_bell.xml:4: e rror: No resource identifier found for attribute 'fillColor' in package 'android' W: D:WayneProgrammingapktoolmicrogresdrawable-anydpi-v21gcm_bell.xml:4: error: No resource identifier found for attribute 'pathData' in package 'android' W: D:WayneProgrammingapktoolmicrogresdrawable-anydpi-v21ic_expand_less.xm l:2: error: No resource identifier found for attribute 'viewportWidth' in package 'android' W: D:WayneProgrammingapktoolmicrogresdrawable-anydpi-v21ic_expand_less.xm l:2: error: No resource identifier found for attribute 'viewportHeight' in package 'android' W: D:WayneProgrammingapktoolmicrogresdrawable-anydpi-v21ic_expand_less.xm l:4: error: No resource identifier found for attribute 'fillColor' in package 'android' W: D:WayneProgrammingapktoolmicrogresdrawable-anydpi-v21ic_expand_less.xm l:4: error: No resource identifier found for attribute 'pathData' in package 'android' W: D:WayneProgrammingapktoolmicrogresdrawable-anydpi-v21ic_expand_more.xm l:2: error: No resource identifier found for attribute 'viewportWidth' in package 'android' W: D:WayneProgrammingapktoolmicrogresdrawable-anydpi-v21ic_expand_more.xm l:2: error: No resource identifier found for attribute 'viewportHeight' in package 'android' W: D:WayneProgrammingapktoolmicrogresdrawable-anydpi-v21ic_expand_more.xm l:4: error: No resource identifier found for attribute 'fillColor' in package 'android' W: D:WayneProgrammingapktoolmicrogresdrawable-anydpi-v21ic_expand_more.xm l:4: error: No resource identifier found for attribute 'pathData' in package 'android' W: D:WayneProgrammingapktoolmicrogresdrawable-anydpi-v21location_marker.x ml:2: error: No resource identifier found for attribute 'viewportWidth' in package 'android' W: D:WayneProgrammingapktoolmicrogresdrawable-anydpi-v21location_marker.x ml:2: error: No resource identifier found for attribute 'viewportHeight' in package 'android' W: D:WayneProgrammingapktoolmicrogresdrawable-anydpi-v21location_marker.x ml:4: error: No resource identifier found for attribute 'fillColor' in package 'android' W: D:WayneProgrammingapktoolmicrogresdrawable-anydpi-v21location_marker.x ml:4: error: No resource identifier found for attribute 'pathData' in package 'android' W: D:WayneProgrammingapktoolmicrogresdrawable-anydpi-v21self_check.xml:2: error: No resource identifier found for attribute 'viewportWidth' in package 'android' W: D:WayneProgrammingapktoolmicrogresdrawable-anydpi-v21self_check.xml:2: error: No resource identifier found for attribute 'viewportHeight' in package 'android' W: D:WayneProgrammingapktoolmicrogresdrawable-anydpi-v21self_check.xml:4: error: No resource identifier found for attribute 'fillColor' in package 'android' W: D:WayneProgrammingapktoolmicrogresdrawable-anydpi-v21self_check.xml:4: error: No resource identifier found for attribute 'pathData' in package 'android'
Steps to Reproduce
apktool if framework-res.apk
apktool d microg.apk
apktool b microg.apk
Frameworks
https://www.dropbox.com/s/q91od465qiy0jt2/framework-res.apk?dl=0
APK
https://microg.org/fdroid/repo/com.google.android.gms-10545440.apk
Questions to ask before submission
- Have you tried
apktool d
,apktool b
without changing anything?Yes
- If you are trying to install a modified apk, did you resign it?
Not doing this.
- Are you using the latest apktool version?
Yes.
Well, there
are many reasons why but I will show you most common errors. Note, i’m talking
about general apk modding, not system apk/framework modding
Assets.dex issue «Class xxx has already been
interned» and «Not a valid dex magic value»
By default,
apktool try to decompile dex from assets folder which would decompile to
smali_assets on a root directory of decompiled apk, and compiled to assets.dex
upon compiling
This can
cause compiling issues
Solution:
To fix the
problem, decompile APK again with the flag [code]—only-main-classes[/code] to
only decompile on main classes in root (classes[0-9].dex) then you can compile
without any problem
Note:
Only for apktool 2.4.1 and up
You can try
to delete .dex from assets folder or smali_assets/assets.dex but it may cause
problems
If you are
using APK Easy Tool 1.57 and above, you can enable the option «Only
disassemble the main dex classes» under Options -> Apktool. Again, only
for apktool 2.4.1 and up
Error: No resource identifier found for attribute
‘manageSpace’ in package ‘android’
The attribute
does not exist in the framework or it could be fake attribute to prevent compiling
Solution:
Remove android:manageSpace=»true» from AndroidManifest.xml
Error: String types not allowed
Issue: https://github.com/iBotPeaches/Apktool/issues/2462
Solution:
In this case:
W: Failed to generate resource table for split »
W: E:(PathToDecompiledAPK)resvaluesdrawables.xml:5: error: Error:
String types not allowed (at ‘APKTOOL_DUMMY_1c2’ with value »).
This error
tells you which xml an error occured and which line
Open the XML file: E:(PathToDecompiledAPK)resvaluesdrawables.xml
Remove drawable name=»APKTOOL_DUMMY_1c2″ /> at line 5 and save the file
You will get another
error about public symbol. See below
Error: Public symbol XXX declared here is not defined.
Public symbol
does not exist in public.xml
Solution:
In this case:
W: E:(PathToDecompiledAPK)resvaluespublic.xml:1133: error: Public
symbol drawable/APKTOOL_DUMMY_1c2 declared here is not defined.
Open the XML
file: (PathToDecompiledAPK)resvaluespublic.xml
Remove <public type=»drawable»
name=»APKTOOL_DUMMY_1c2″ id=»0x7f0601c2″ /> at
line 1133 and save the file
Resource error (APKTOOL_DUMMY) (Split APK)
If you get
APKTOOL_DUMMY that’s generally because apktool can’t decode some of the
information in the original APK and creates a ‘dummy’ value instead. Because
there’s no things called APKTOOL_DUMMY in public.xml, the APK can’t be
recompiled. It’s likely because you try to compile splitted APK with some
missing infomation
Solution:
Merge split
APKs manually
https://platinmods.com/threads/how-to-turn-a-split-apk-into-a-normal-non-split-apk.76683
Or use the
SAP (Split APK Packer) tool
https://platinmods.com/threads/sap-split-apks-packer-by-kirlif-windows-linux-merge-split-apks-into-single-apk.101798/
Other issues
— APK is
protected, encrypted or obfuscated. Reversing of such files is beyond the
scope, so find out yourself
— Invalid syntax
in smali and xml. You may have done something wrong
You can
search for useful infomation on the following sites.
Report your
issues to them if you feel like to
Apktool: iBotPeaches/Apktool
Smali/baksmali: JesusFreke/smali
When I followed the instructions to add an ad into my app by xml, I got the following errors:
Description Resource Path Location Type
error: No resource identifier found for attribute 'adSize' in package 'com.google.example' main.xml /HelloWorld/res/layout line 12 Android AAPT Problem
Description Resource Path Location Type
error: No resource identifier found for attribute 'adUnitId' in package 'com.google.example' main.xml /HelloWorld/res/layout line 12 Android AAPT Problem
I did edit the main.xml
, add attrs.xml
file but the compiler didn’t like it.
25 Answers
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
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.
I received this error with regards to the largeHeap Attribute, my application did not run under eclipse but under ant it still built and ran normally.
The android documentation states that:
attributes:
xmlns:android
Defines the Android namespace. This attribute should always be set to «
http://schemas.android.com/apk/res/android
«.
I erased that line in my manifest, saved in eclipse, pasted the line back in and saved again, and it worked. In my case I guess the problem was eclipse, ant and adb not talking to each other correctly and the saving reset something. Interestingly restarting eclipse did not solve this problem (usually with these types of problems restarting eclipse is the first thing you should try, and usually it solves the problem).
Make Sure you have included this part in your layout (top below xmlns:android line)
xmlns:ads="http://schemas.android.com/apk/res/com.google.example"
...........blah blah..
Also Check whether you have included attrs.xml in the res/values/
Check here for more details.
http://code.google.com/mobile/ads/docs/android/banner_xml.html
I usually embed the xmlns:ads property into the adview properties this way:
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="@string/banner_ad_unit_id"/>
so that you dont need to embed into the parent every and each time you copy the adview.
Just copy and paste the adview above and paste it anywhere and it should work
I’ve been searching answer but couldn’t find but finally I could fix this by adding play-service-ads
dependency let’s try this:
*) File -> Project Structure… -> Under the module you can find app and there is a option called dependencies and you can add com.google.android.gms:play-services-ads:x.x.x dependency to your project
I faced this problem when I try to import Eclipse projects into Android Studio.
In my case, I was missing a dependency in the app level build.gradle.
The solution was to add the dependency as google outlines below:
Open the app-level build.gradle file for your app, and look for a «dependencies» section.
dependencies {
implementation ...SOME_IMPLEMENTATION
implementation ...SOME_IMPLEMENTATION
implementation 'com.google.android.gms:play-services-ads:18.1.1'//<---ADD THIS LINE
}
Add the line above, which instruct Gradle to pull in the latest version of the Mobile Ads SDK and additional related dependencies. Once that’s done, save the file and perform a Gradle sync.
Based on the answer here, I think you need to change the xmlns:ads attribute. For example, change this:
<com.google.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res/com.google.example"
...
/>
to this:
<com.google.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res/com.your.app.namespace"
...
/>
It fixed it for me. If you’re still getting errors, could you elaborate?
I also faced the same problem, I was using GoogleAdMobAdsSDK-4.1.0.jar
then I tried with GoogleAdMobAdsSDK-4.0.4.jar
now it is working fine, It is problem with jar file as per my experience.
I had a similar issue on MonoDroid when building a class library with Drawables and Layouts files that have "android:"
attribute in the xml. I get a similar error as the one in the question.
No resource identifier found for attribute ‘textCursorDrawable’ in
package ‘android’
I found from that «android: » attribute is only available in Android API Level 12+ and I was trying to build for an older version. Updating my project to build against Android 4.0 fixed the issue for me.
Here is where I found the answer.
https://groups.google.com/forum/?fromgroups#!topic/android-developers/ocxKphM5MWM
Just make sure that you are building against the right API level if you get a similar issue, and ensure that the missing identifier exists in that API level that you are build against.
just change the target sdk right click on project then click on
property select android and select the latest API
The same error was happening to me in the «activity_banner_xml.xml» file inside res/layout folder. What I did to fix it was replace
<com.google.android.gms.samples.ads.AdView
with
<com.google.android.gms.ads.AdView
There was no references to my package name.
Also, be sure you set the adUnitId for ads:adUnitId="@string/banner_ad_unit_id">
The add unit Id is located in your res/Values/Strings folder.
So my final layout file looks like this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/mainLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
ads:adSize="BANNER"
ads:adUnitId="@string/ad_unit_id"/>
If yours is a gradle project replace:
xmlns:android="http://schemas.android.com/apk/res/android"
with:
xmlns:app="http://schemas.android.com/apk/res-auto"
I am adding the solution that worked for me for this same error.
I right clicked project > properties > (left panel) Android
Right panel under Library
I removed the faulty library and added it again.
For me this error occurred after a corrupt workspace eclipse file where I had to import all projects again.
My problem was very similar (produces same problem). After refactoring variable name by «refactor -> rename» option in Android Studio (from «value» to «myValue») i found changes in manifest file, too. Meta-data «value» pool has changed to «myValue».
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:myValue="@string/facebook_app_id"/>
After revert file everything seams to be ok again.
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id"/>
I hope, it will help someone!
Add xmlns:ads=»http://schemas.android.com/apk/lib/com.google.ads»,
This will solve your Issue.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.app.activities.Initializer" >
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-123456789/123456789"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
</RelativeLayout>
Replace
xmlns:android="http://schemas.android.com/apk/res/android"
with
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
then Rebuild Project
I added in android.support.design.widget.NawigationView this parameter:
android:layout_gravity="start"
And problem was solved.
PUT
compile 'de.hdodenhof:circleimageview:2.0.0'
IN Gradle Dependencies and put this code in nav_header_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/lib/org.mainsoft.navigationdrawer"
android:gravity="bottom"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:theme="@style/ThemeOverlay.AppCompat.Dark"
android:layout_width="match_parent"
android:layout_height="160dp"
android:background="@drawable/background_material_red"
android:orientation="vertical">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/profile_image"
android:layout_width="70dp"
android:layout_height="70dp"
android:src="@drawable/profile"
app:border_color="#FF000000"
android:layout_marginLeft="24dp"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginStart="24dp" />
</LinearLayout>