Flush with success on getting "hello Android" to run, I'm working on the tutorial at link text using Eclipse. When I create the android_button.xml file in res/drawable/, I get errors for each of the in
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#drawable/android_pressed"
android:state_pressed="true" />
<item android:drawable="#drawable/android_focused"
android:state_focused="true" />
<item android:drawable="#drawable/android_normal" />
</selector>
The errors (repeated for each item) are:
Description Resource Location Type Path
error: Error: No resource found that matches the given name (at 'drawable' with value '#drawable/android_focused'). android_button.xml line 5 Android AAPT Problem /HelloFormStuff/res/drawable
error: Error: No resource found that matches the given name (at 'drawable' with value '#drawable/android_focused'). android_button.xml line 5 Android AAPT Problem /HelloFormStuff/res/drawable
I'm afraid I don't know which resource should match the names or if I have overlooked something or misnamed something. Help resolving this is greatly appreciated!
You probably missed this line in the instructions:
Copy the images on the right into the res/drawable/ directory of your project. These will be used for the different button states.
Just copy those little android icons into the directory and it should work
On the link you gave there are three android icons near
android_button.xml code. Just right click them and "save as"
Save them in your res/drawable directory along with android_button.xml.
note that I assume you are creating that xml file in res/drawable directory
and note in drawable-XXXX directory created by eclipse. You will have to manually
create a new folder drawable in res directory, since its not default eclipse stuff.
Related
I decided to upgrade Android Studio today against my own better judgment. After upgrading, building the project failed due to
Android resource compilation failed
Output: /home/username/AndroidStudioProjects/project/mobile/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:841: error: <item> inner element must either be a resource reference or empty.
Line 841 was an <item>.
So I removed all the <item> bodies in values.xml like so:
<item name="item_1" type="id">Item 1</item>
to
<item name="item_1" type="id"/>
This did not fix the problem, as the same error is being thrown. The traceback now refers to a <string> resource in my values.xml file. There are no <item>s in the file that aren't fixed, so now I'm stuck. I've also tried the usual invalidate caches & restart, sync with Gradle files, clean and build stuff to no avail.
Edit:
I quickly noticed that upon building the project, line 841 (from the first traceback) is dynamically changed to the old <item> style, thus throwing the Exception. The source code XML file is free of the bodies, but the build-generated XML file generates it with a body in the item elements.
Removing the body from these tags does nothing, as the body is re-added on runtime every single time.
Hi,I have a dimens resource files with different screen densities,everything worked just fine,I tested it,but suddenly I got an error:
Error: Invalid resource directory name
res\values-(xxxhdpi): Error: Invalid resource directory name
Any advice and suggestion will be greatly appreciated.Thx.
Switch to Project view instead of Android view and remove the parenthesis in the folder. It should only be values-xxxhdpi
You need to create different values folder for different screens.
Then, inside the values directory, you have to place your dimens.
I decompiled an app using an online tool (www.decompileandroid.com) then, after I downloaded the zipped source code (assets + java code), I extracted it in a folder and finally I imported the folder in android studio (File>New>Import Project).
Then, without editing any file, I tried to run the project but I got this error:
Error: Found item ###/ITEM-NAME more than one time
Error:Execution failed for task ':app:mergeDebugResources'. > C:\Users\Fabrizio\AndroidStudioProjects\com.hwlogos.ytstars\app\src\main\res\values\public.xml: Error: Found item ###/ITEM.NAME more than one time
I searched the web for hours but I can't find any useful answer...
Please help!
PS: I tried also with other applications but I always get the same error...
UPDATE:
Now I tried to decompile a simple app i created with android studio and when I reimported it in android studio I got the same error.
it seems there are two resources with the same name, one declared as string and the other as id.
Here's a part of my public.xml, which i never wrote when I made my application!!!
<public type="string" name="action_settings" id="0x7f070006" />
<public type="id" name="action_settings" id="0x7f09000a" />
Create a new xml ids.xml in values with all the id values which are to be constant.
<resources>
<item type="id" name="index_row_search" />
</resources>
I think its better if you copy the resource ids to public.xml from the R.java, the first time to avoid errors like entry index is larger than available symbols and also to keep the type of resource to be consistent.
visit here for more help How to add id to public.xml?
My application supports a minimum of API 8 (platform version 2.2). But borderless buttons require API 11. So when I try to make a button like:
<button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="displayText"
style="?android:attr/borderlessButtonStyle" ></button>
Reference: Borderless button subsection in this developer guide
I get an error ?android:attr/borderlessButtonStyle requires API level 11 (current min is 8)
I have the support library android-support-v4.jar in the libs folder of my project. So I removed the android namespace and changed it to style="?attr/borderlessButtonStyle" (suggested in some comment here) and now I get this error:
No resource found that matches the given name (at 'style' with value '?attr/borderlessButtonStyle').
I could not either find a "BorderlessButtonStyle" mention, or even that of a "button" in this, or this document?
What should I do? Which support library should I use?
EDIT 1 On suggestion by #NaveenTamatar in the comment:
res/drawable/selector_transparent_button.xml
Problem 1:-
Attribute "exitFadeDuration" is only used in API level 11 and higher (current min is 8)
So I tried this with a slight change:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:color="#227EC9" ></item>
<item android:state_selected="true" android:color="#227EC9"></item>
<item android:state_enabled="false" android:color="#ADADAD"></item>
<item android:color="#2E2E2E"/>
</selector>
in a file named selector_transparent_button.xml in res/drawable/ (I created drawable directory myself, those like drawable-hdpi, drawable-ldpi were there but no drawable, a quick web search revealed I could create it, if this matters at all).
Problem 2:-
error: Error: No resource found that matches the given name (at 'drawable' with value '#drawable/button_pressed').
error: Error: No resource found that matches the given name (at 'drawable' with value '#drawable/button_focused').
error: Error: No resource found that matches the given name (at 'drawable' with value '#drawable/button_default').
I'v just started building my first Android project with eclipse, according to Lynda's course Up and Running with PhoneGap.
When i try to run the project (like the demonstration on Lynda), i get the following error message:
"your project contains error(s), please fix them befor running your application."
Description Resource Path Location Type
error: Error: No resource found that matches the given name (at 'label' with value
'#string/app_name'). AndroidManifest.xml /android_project line 49
Android AAPT Problem error: Error: No resource found that matches the given name (at 'label'
with value '#string/app_name'). AndroidManifest.xml /android_project line 52 Android
AAPT Problem
The import org.apache.cordova cannot be resolved android_project.java
/android_project/src/com/example/android line 23 Java Problem
DroidGap cannot be resolved to a type android_project.java
/android_project/src/com/example/android line 25 Java Problem
The method onCreate(Bundle) of type android_project must override or implement a supertype
method android_project.java /android_project/src/com/example/android line 28 Java
Problem DroidGap cannot be resolved to a type android_project.java
android_project/src/com/example/android line 30 Java Problem
Config cannot be resolved android_project.java /android_project/src/com/example/android
line 32 Java Problem
Attached the error screenshot
I can guess what some of the error messages means, but i don't know how to solve them.
Any suggestion?
I'm using windows 8.
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)
Thanks,
Liron
Check your strings.xml inside your project>res>values and add the string values you are going to use in your project.
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<resources>
<string name="app_name">AppName</string>
</resources>
Plus, I think you need to update your .jar file of cordova.
You can download it from the phonegap github repo.
You can find the lib in the lib/android/ folder.
To create a new project, you can use the lilb/andoird/bin/create.bat file.
Don't forget to clean the project.
Hope this helps you.
I think You forgot to set the string values. I havenĀ“t read that tutorial, but there are some strings missin. Check the tutorial, You have to set some strings inside strings.xml in Your res/values folder
EDIT
go to folder inside Your project "res/values" and open strings.xml. Then begin a new line and put
<string name="example_string">This is an example!</string>
The first part "example_string" is the name of the string. This is to refer to this for example inside an xml layout. imagine You have a button in any xml layout:
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/example_button"
android:text="#string/example_string"/> <-- here you refer to that string inside strings.xml
The second part "This is an example" is what will be appear on that button.
But I think it would be better if You learn the basics instead of starting with PhoneGap.
http://developer.android.com/training/basics/firstapp/index.html