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?
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.
To avoid my API keys from getting committed on source control (git) I have made an XML resource file called api_keys.xml under the values directory. This file is listed under .gitignore.
I access these string resources the usual way by using #string/.. or .getString(R.string...). This approach works everywhere but in the manifest.xml file.
I have fabric set-up and in the manifest file this is how I try to pass the key -
<meta-data
android:name="io.fabric.ApiKey"
android:value="#string/FABRIC_API_KEY" />
But, when I try to build the APK I get the following error -
Error:Execution failed for task ':app:fabricGenerateResourcesDebug'.
Crashlytics Developer Tools error.
This error goes away if I replace #string/FABRIC_API_KEY with the actual key.
Is there a way I can fix this? Or any other approach I can use to prevent my API keys form getting published on the source control.
I just started working on android open source project and I am trying to modify the settings application but when I am importing it with android studio and trying to compile I get this error
Error:Execution failed for task ':app:mergeDebugResources'.
/app/src/main/res/values-nl/strings.xml: Error: Found item String/sdcard_unmount more than one time
Seems like there are multiple statements of string such as
<string name="sdcard_format" product="nosdcard" msgid="6285310523155166716">"USB-opslag wissen"</string>
<string name="sdcard_format" product="default" msgid="6713185532039187532">"SD-kaart wissen"</string>
It is causing errors, how can it be fixed?
For anyone looking for answers, this other one in SO is much better: Error:Error: Found item String/photoPickerNotFoundText more than one time
you need to change the package name, because u r installing setting app on device which already have the setting app with same package name. you have to import the code modify it and then copy the new src and res directory in to aosp and create the image of android.
I've got 'no resource found that matches the given name' but everything is set up correctly.
error: Error: No resource found that matches the given name (at 'text' with value '#string/labReminderClear').
In AndroidManifest.xml:
<application android:label="MyName"
.....
In Strings.xml:
<string name="app_name">MyName</string>
...
<string name="labReminderClear">Clear</string>
What could be wrong?
The project you've mentiond contains errors in strings.xml file. It is connected with % sign used for example in following line (NOTE: there are multiple in that file):
<string name="msgYouHaveASTS">You have %d appointment(s)\n..and %d task(s)</string>
This is due to aapt (Android Asset Packaging Tool) becoming strict and being used for all versions of Android. See detailed explanation in this answer.
If you want to fix the code so that it works correctly, you have to add info about parameters positions. For example line from above should become:
<string name="msgYouHaveASTS">You have %1$d appointment(s)\n..and %2$d task(s)</string>
If you're using Eclipse try using (from menus above):
Project->Clean....
Select project, in which you have problem, to be rebuilt.
If that doesn't help Error Log view might help you nail what is the real issue here. From Eclipse menus choose:
Window->Show view->ErrorLog
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.