When I add the code
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/LinearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#F0F8FF"
android:orientation="vertical" >
<ListView
android:id="#+id/lvHienThi"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
<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_gravity="bottom|center"
ads:adSize="BANNER"
ads:adUnitId="#string/ad_unit_id" />
it show me :"No resource identifier found for attribute 'adSize' in package '....'"
How can I fix it ? Please help me. Thank you !
Replace /res/ with /lib/ in your custom layout nampespace
xmlns:android="http://schemas.android.com/apk/res/android"
will be
xmlns:yourApp="http://schemas.android.com/apk/lib/com.yourAppPackege.yourClass"
i hope it help :)
instead of
xmlns:ads="http://schemas.android.com/apk/res-auto"
add
xmlns:ads="http://schemas.android.com/apk/res/your.package.name"
replacing "your.package.name" with your actual package name
Related
I am stuck in a problem and search alot but could'nt find the solution here is my code
<com.google.ads.AdView
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="#+id/adView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
app:adSize="BANNER"
app:adUnitId="xxxxxxxxxx" >
</com.google.ads.AdView>
This code show
Error parsing XML:unbound prefix
when i remove app:adUnitId and app:adsize it do not give any error, how can i remove this error?
Your error is typographical, you're setting:
app:adSize="BANNER"
app:adUnitId="xxxxxxxxxx"
But it should be:
ads:adSize="BANNER"
ads:adUnitId="xxxxxxxxxx"
xmlns:ads="http://schemas.android.com/apk/res-auto"
Add this to your parent tag.
In my case.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="#+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/background"
android:orientation="vertical" >
Hope this will work.
I'm trying to fix this so badly but I couldn't find where I've gone wrong.
The message:
Element type "LinearLayout" must be followed by either attribute specifications, ">" or "/>".
Why do I get this? Any ideas?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:weightSum="100"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
**<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_weight="70"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#0000FF"
android:padding="20dp"
android:paddingBottom="10dp"
android:gravity="center_horizontal">
</LinearLayout>
</LinearLayout>
It's a pretty self-explanatory error message.
You didn't close your LinearLayout tag. Add a > after android:orientation="vertical".
You missed a ">" at the end:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:weightSum="100"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
Your first LinearLayout tag isn't closed. Add a > to the end of it, like this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:weightSum="100"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
^
Error clearly states that you missed the closing tag. Every Layout and its attribute needs to have their own opening and closing tag. Add
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_weight="70"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
or
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_weight="70"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</LinearLayout>
Here is the snippet of main.xml.Although android:layout_width is used its giving attribute is missing.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView android:id="#+id/eventlabel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10px"
android:layout_weight="1"
android:paddingBottom="10px"/>
</LinearLayout>
Could someone point out the mistake?Thanks
You have:
<LinearLayout xmlns="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools
Change it to:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
<!-- rest is the same -->
You only had xmlns=... and didn't actually specify the android part of it. Also, your tools XMLNS was missing a closing "
Try cleaning your solution and then build it again.
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 :(
Probably a namespace issue. You have to define the namespace.
try adding
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
New Admob SDK (Google Play services) requiried another namespace
xmlns:ads="http://schemas.android.com/apk/res-auto"
<?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-admobThanks Pragna
I am getting an "Error parsing XML file: Unbound prefix" when I try to put my AdMob ad reference above a tabbed view. Any ideas how to fix that?
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#android:id/tabhost" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:padding="5dp">
<com.admob.android.ads.AdView android:id="#+id/ad"
android:layout_width="fill_parent" android:layout_height="wrap_content"
myapp:backgroundColor="#000000" myapp:primaryTextColor="#FFFFFF"
myapp:secondaryTextColor="#CCCCCC" />
<TabWidget android:id="#android:id/tabs"
android:layout_width="fill_parent" android:layout_height="wrap_content" />
<FrameLayout android:id="#android:id/tabcontent"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:padding="5dp" />
</LinearLayout>
</TabHost>
You're using this:
myapp:backgroundColor
but I don't see any declaration of the 'myapp' prefix. so that might be the source of the error.
Just like the "android" namespace is declared in the xml like this:
xmlns:android="http://schemas.android.com/apk/res/android"
the 'myapp' namespace should have a declaration somewhere also
This answer seems related.
You need both the xmlns set correctly, as Nanne said, as well as your attributes defined in res/style/attrs.xml.
The xmlns appears to be:
xmlns:admob="http://schemas.android.com/apk/res/com.example.package"
For an example attrs.xml, check out the answer above.