No resource found that matches given name in main.xml - android

This is really starting to drive me crazy.
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#id+/textview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="#string/hello"/>
Produces the following error message: "Error: no resource found that matches the given name (at 'id' with value '#id+/textview').
This is copy and pasted from the Android hello world
example.

#+id not #id+. Seems the tutorial is wrong!

It's just a small typo; you need to put the '+' after the '#', not after 'id':
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/textview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="#string/hello"/>

Related

No resource identifier found for attribute 'apikey' in package 'android'

<?xml version ="1.0" encoding ="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.google.android.maps.Mapview
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:id="#+id/themap"
android:apikey = "AIzaSyDc9ac67bCYPqhVYz9pxhTJsK9shZH3iQg"/>
</LinearLayout>
it is my activity_main.xml file ...bt it shows the error mentioned above...i have also included android:name="com.google.android.maps" in my manifest file..plz help
Check whether in your project properties you have selected it as Google APIs
follow this if you still facing problem

Android: Error parsing XML: unbound prefix

I would like to implement the color picker library at https://github.com/attenzione/android-ColorPickerPreference:
To setup, in a dialog, the xml is added according to the instruction in website, and is as follows:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center" >
<RelativeLayout
android:id="#+id/message_dialog"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:background="#drawable/layout_round_corners_blue" >
<net.margaritov.preference.colorpicker.ColorPickerPreference // error line
android:layout_width="wrap_content"
android:layout_height="wrap_content"
holo:defaultValue="#color/pumpkin_orange"
holo:key="color1"
holo:summary="#string/color1_summary"
holo:title="#string/color1_title" />
</RelativeLayout>
</RelativeLayout>
Question:
The xml reports error error: Error parsing XML: unbound prefix at the above error line marked.
What is the problem for the above xml?
you have to change this <net.margaritov.preference.colorpicker.ColorPickerPreference to your package where you add this class like
<com.example.yourPackagewhereyouAddThisClass.ColorPickerPreference
like
net.margaritov.preference.colorpicker
change this above to your package Name where you add you ColorPickerPreference Class

include in eclipse for layouts throwing "no resource found"

I am absolutely new to Java and Eclipse. I have two layout-files under /res/layout:
activity_main.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<include layout="#layout/layoutTst" />
</LinearLayout>
layout_test.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/layoutTst"
android:orientation="vertical" >
</LinearLayout>
When I try to compile at the "include" - part I get this message:
Description Resource Path Location Type error: Error: No resource
found that matches the given name (at 'layout' with value
'#layout/layoutTst'). activity_main.xml /YouSherlock/res/layout line
6 Android AAPT Problem
So what is wrong?
You need to include the layout filename (layout_test.xml), not the ID of the root in that layout.
<include layout="#layout/layout_test" />
#layout/layoutTst
should be the name of the file not its android:id
#layout/layout_test

Custom elements and package name

When creating a custom element with attributes in Android I need to put the namespace of the application in the layout.
For example:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:whatever="http://schemas.android.com/apk/res/org.example.mypackage"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<org.example.mypackage.MyCustomView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
whatever:my_custom_attribute="Hello, world!" />
</LinearLayout>
Does this also requires that the structure of my project in Eclipse be the same as the name of the Android package as definied in the Manifest - as per the example?
Would this work too:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:whatever="http://schemas.android.com/apk/res/org.mycompany.myproduct"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<org.example.mypackage.MyCustomView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
whatever:my_custom_attribute="Hello, world!" />
</LinearLayout>
Its the package name of your application that should be reflected. So its correct to use it as you are doing.
For example:
In xmlns:whatever="http://schemas.android.com/apk/res/org.mycompany.myproduct the last part org.mycompany.myproduct should be the same as your package name. And you may change xmlns:whatever to anything like xmlns:theblitz but then make sure you do use theblitz as a prefix for your attributes in the xml.
For more info, read this

Android Application:Error "Found text"

I have been following a book on Android "Beginning Android Application". I have been trying to figure out an application which shows images in a view. But unfortunately I could not run the application because of the following errors:
[2012-04-24 19:37:33 - Gallery] F:\eclipse workspace\Gallery\res\values
\attrs.xml:2:error: Found text "
[2012-04-24 19:37:33 - Gallery] ​​​​ " where item tag is expected
For convenience I am giving here the codes.
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Bilai"
/>
<Gallery
android:id="#+id/gallery1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<ImageView
android:id="#+id/image1"
android:layout_width="320px"
android:layout_height="250px"
android:scaleType="fitXY"
/>
</LinearLayout>
This application requires another xml file. It is named as attrs.xml under res/values.
attrs.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
​<declare-styleable name="Gallery1" >
​​​​<attr name="android:galleryItemBackground" />
​​​</declare-styleable>
</resources>
I think the problem lies within attrs.xml, but I dont know whats going on. And because of this the R.styleable also doesnt work either. Please help. Thanks in advance
I think you have some characters before each line in your attrs.xml due to a copy/past method.
Can you try to reformat your code by placing your text cursor at the beginning of each line and delete to return to previous line ?

Categories

Resources