I'm looking for a lib to extract ids and values which stored in res/values/strings.xml, for example app_name. I unzipped the apk, however strings.xml cannot be found. I use aapt to extract string values, however the corresponding ids are missing. I have tried apktool to decompile the apk and then parse the xml file to get the keys and values. However, it's not an efficient way, almost 12 seconds per apk. I have more than 10,000 android malwares to be processed. This method really cost me too much time.
I found that all the ids and values in res/values/strings.xml is encoded into the file resources.arsc. I wonder if there is lib to extract ids and values from resources.arsc?
Use appt for android-sdk (ex:- /build-tools/27.0.3/aapt )
./aapt dump resources ./debug.apk
Package Groups (1)
Package Group 0 id=0x7f packageCount=1 name=com.dianping.example.activity
Package 0 id=0x7f name=com.dianping.example.activity
type 1 configCount=3 entryCount=1
spec resource 0x7f020000 com.example.activity:drawable/ic_launcher: flags=0x00000100
config mdpi-v4:
resource 0x7f020000 com.example.activity:drawable/ic_launcher: t=0x03 d=0x00000000 (s=0x0008 r=0x00)
config hdpi-v4:
resource 0x7f020000 com.example.activity:drawable/ic_launcher: t=0x03 d=0x00000001 (s=0x0008 r=0x00)
config xhdpi-v4:
resource 0x7f020000 com.example.activity:drawable/ic_launcher: t=0x03 d=0x00000002 (s=0x0008 r=0x00)
type 2 configCount=1 entryCount=1
spec resource 0x7f030000 com.dianping.example.activity:string/app_name: flags=0x00000000
config (default):
resource 0x7f030000 com.dianping.example.activity:string/app_name: t=0x03 d=0x00000003 (s=0x0008 r=0x00)
This link might help http://elinux.org/Android_aapt
It's not a proper library, but you can borrow code from an official Google project called ArscBlamer:
https://github.com/google/android-arscblamer
Related
I am creating unit tests where I check if the Resource ID of where a navigation flow ends up matches the Resource ID of the fragment I'm expecting.
Right now the test fails, and unfortunately that leaves me with a cryptic Resource ID error: Value is different: expected <XXXXXXXXXX> but was: <YYYYYYYYYY> where is a number.
How I decode these Resource IDs into human-readable file names?
One idea was to build the APK and grep the (hexadecimal) Resource ID using aapt2 [1]. But running grep 'fragment' apk_dump_resources.txt, etc. shows the fragment resources probably aren't even in this file (as does grepping the Resources IDs directly, e.g. grep <hexadecimal> apk_dump_resources.txt)
Any other ideas?
[1] e.g. aapt2 dump resources <apk file path> > apk_dump_resources.txt
I use Android Studio 3.2. When I clean/rebuild project I see these warnings in build tool window:
W/ResourceType( 6139): For resource 0x0101053d, entry index(1341) is beyond type entryCount(1155)
W/ResourceType( 6139): For resource 0x0101053e, entry index(1342) is beyond type entryCount(1155)
W/ResourceType( 6139): For resource 0x0101053b, entry index(1339) is beyond type entryCount(1155)
W/ResourceType( 6139): For resource 0x0101053c, entry index(1340) is beyond type entryCount(1155)
As you can see there is no address to any file to be checked out. I also try Google and saw this and this questions, but I could not find any thing that helps me. How I can solve this problem?
To better understand your problem take your compiled APK.
In it, there is a file called "resources.arsc". This is compressed and compiled resource file.
To be able to read it run:
aapt dump --values resources myAPK.apk > c:\my-res.txt
So now you'll have a text file with a description of all the resources in your app.
In it, there are a lot of segments looking like this:
type 3 configCount=2 entryCount=5
spec resource 0x7f040000 com.LTS.NVMS7000:bool/abc_action_bar_embed_tabs: flags=0x00000080
spec resource 0x7f040001 com.LTS.NVMS7000:bool/abc_allow_stacked_button_bar: flags=0x00000000
spec resource 0x7f040002 com.LTS.NVMS7000:bool/abc_config_actionMenuItemAllCaps: flags=0x00000000
spec resource 0x7f040003 com.LTS.NVMS7000:bool/abc_config_closeDialogWhenTouchOutside: flags=0x00000000
spec resource 0x7f040004 com.LTS.NVMS7000:bool/abc_config_showMenuShortcutsWhenKeyboardPresent: flags=0x00000000
config (default):
resource 0x7f040000 com.LTS.NVMS7000:bool/abc_action_bar_embed_tabs: t=0x12 d=0xffffffff (s=0x0008 r=0x00)
(color) #ffffffff
resource 0x7f040001 com.LTS.NVMS7000:bool/abc_allow_stacked_button_bar: t=0x12 d=0x00000000 (s=0x0008 r=0x00)
(color) #00000000
resource 0x7f040002 com.LTS.NVMS7000:bool/abc_config_actionMenuItemAllCaps: t=0x12 d=0xffffffff (s=0x0008 r=0x00)
(color) #ffffffff
resource 0x7f040003 com.LTS.NVMS7000:bool/abc_config_closeDialogWhenTouchOutside: t=0x12 d=0xffffffff (s=0x0008 r=0x00)
(color) #ffffffff
resource 0x7f040004 com.LTS.NVMS7000:bool/abc_config_showMenuShortcutsWhenKeyboardPresent: t=0x12 d=0x00000000 (s=0x0008 r=0x00)
(color) #00000000
config port:
resource 0x7f040000 com.LTS.NVMS7000:bool/abc_action_bar_embed_tabs: t=0x12 d=0x00000000 (s=0x0008 r=0x00)
(color) #00000000
In this section, you can see there are 2 configurations and 5 entries expected.
What you should do to get a hint of what's going on is to look for example at:
resource 0x0101053d
That appears in your log and see where is in the section.
It should give you a hint of what resource group in your app is causing it.
I would guess you are linking with a package that is very old and so the compiler is not linking the resources of that package properly to your app because they are intended for different Android SDK versions for example.
I'm sorry that I can't help much more.
If you have more info leave a comment for this answer and I'll try to help.
I think Itamar is right pointing the finger on "...the compiler is not linking the resources of that package properly to your app because they are intended for different Android SDK versions..."
I had same issue, but following AS' hint I found the solution here: https://chris.banes.me/2016/02/25/appcompat-vector/#enabling-the-flag
androidstudio screenshot
Generally, AAPT is packaging an application with fixed resource id, and the id value is starting with "0x7f".
I want to replace this integer value with other value, like "0x6f" or something.
I found the code line to handle this, and modified the aapt code. (path : /frameworks/base/tools/aapt/)
But, when building an application, I got the build error message like:
/apps/myapps/AndroidManifest.xml:9: error: Error: No resource found that matches the given name (at 'icon' with value '#drawable/ic_launcher_app')."\
Is there any way to solve this build error ?
According to this Android resources dev page you should never modify the R file yourself as it is generated automatically
Caution: You should never modify the R.java file by hand—it is generated by the aapt tool when your project is compiled. Any changes are overridden next time you compile.
That means ic_launcher_app image not in your drawable folder. And also if you change image format manually like .jpg to save as .Png without using any software that AAPT(while compile resources into binary assets) issue will occur.so use proper image formats.
This will probably sound silly but I have no idea how to make the application work.
tutorial for in-app billing
Just like the tutorial says I downloaded the package, I found the files. The problem is there's no project file and I can't get it to work in eclipse.
Anyone used the example app?
I've used it successfully...what seems to be the problem? Once you download the files, bring the project into Eclipse by select "Newn Android Project", "Create project form existing source" and the "Finish." From there, follow the directions regarding changing the package name, etc...
As far as I can determine, the sample Dungeons in-app billing project that I downloaded via Android SDK Manager, does not even compile (this seems to have been fixed, see my comments later in this message..).
As a check, I ran a find command to search for one of the missing resources:
/cygdrive/k/android-sdk-windows/extras/google/play_billing $ find . -name '*.xml' -exec grep edit_payload_title {} \; -print
android:text="#string/edit_payload_title" />
./res/layout/edit_payload.xml
/cygdrive/k/android-sdk-windows/extras/google/play_billing $
As you can see, the resource #string_edit_payload_title is referenced once, but never defined in any of the xml files..
Description Resource Path Location Type
error: Error: No resource found that matches the given name (at 'background' with value '#color/screen_background'). item_row.xml /Dungeons/res/layout line 20 Android AAPT Problem
error: Error: No resource found that matches the given name (at 'background' with value '#color/screen_background'). main.xml /Dungeons/res/layout line 20 Android AAPT Problem
error: Error: No resource found that matches the given name (at 'prompt' with value '#string/select_item'). main.xml /Dungeons/res/layout line 52 Android AAPT Problem
error: Error: No resource found that matches the given name (at 'text' with value '#string/buy'). main.xml /Dungeons/res/layout line 47 Android AAPT Problem
error: Error: No resource found that matches the given name (at 'text' with value '#string/edit_payload_title'). edit_payload.xml /Dungeons/res/layout line 25 Android AAPT Problem
error: Error: No resource found that matches the given name (at 'text' with value '#string/edit_payload'). main.xml /Dungeons/res/layout line 58 Android AAPT Problem
error: Error: No resource found that matches the given name (at 'text' with value '#string/items_for_sale'). main.xml /Dungeons/res/layout line 34 Android AAPT Problem
error: Error: No resource found that matches the given name (at 'text' with value '#string/items_you_own'). main.xml /Dungeons/res/layout line 64 Android AAPT Problem
error: Error: No resource found that matches the given name (at 'text' with value '#string/recent_transactions'). main.xml /Dungeons/res/layout line 80 Android AAPT Problem
error: Error: No resource found that matches the given name (at 'textColor' with value '#color/error_message'). main.xml /Dungeons/res/layout line 28 Android AAPT Problem
** UPDATE ** I just downloaded it again and it seems to be resolved. At least, it builds and deploys now.. And the string definitions seem to be in place now..
/cygdrive/k/android-sdk-windows/extras/google/play_billing $ find . -name '*.xml' -exec grep edit_payload_title {} \; -print
android:text="#string/edit_payload_title" />
./res/layout/edit_payload.xml
<string name="edit_payload_title">Edit the developer payload associated with this purchase</string>
./res/values/strings.xml
I am testing localization example given on http://developer.android.com/resources/tutorials/localization/index.html. For this i have created android 2.3.3 level 10 application.
There is a step mentioned in the tutorial:
Localize the Images
As shown in Table 2, the application needs six more drawable folders, each containing a flag.png icon. Add the needed icons and folders to your project:
Save this German flag icon as res/drawable-de-rDE/flag.png in the application's project workspace.
For example:
1. Click the link to open the flag image.
2. Save the image in your-workspace/HelloL10N/res/drawable-de-rDE/ .
But in the res folder i have three folders drawable-hdpi, drawable-mdpi and drawable-ldpi.
I know that it is for different screen resolutions. Similarly i have values-dr folder containing strings.xml file.
I have made drawable-hdpi-de-rDE folder for german and similar folders for other languages. But i am getting error:
[2011-04-04 14:34:32 - HelloL10N] (skipping index file 'C:\Documents and Settings\abc\workspace\HelloL10N\res\drawable-hdpi\Thumbs.db')
[2011-04-04 14:34:32 - HelloL10N] C:\Documents and Settings\abc\workspace\HelloL10N\res\values-fr\strings.xml:4: error: Apostrophe not preceded by \ (in Irai-je te comparer au jour d'été?)
[2011-04-04 14:35:14 - HelloL10N] (skipping index file 'C:\Documents and Settings\abc\workspace\HelloL10N\res\drawable-hdpi\Thumbs.db')
[2011-04-04 14:35:14 - HelloL10N] invalid resource directory name: C:\Documents and Settings\abc\workspace\HelloL10N\res/drawable-hdpi-de-rDE
[2011-04-04 14:35:14 - HelloL10N] invalid resource directory name: C:\Documents and Settings\abc\workspace\HelloL10N\res/drawable-hdpi-en-rCA
[2011-04-04 14:35:14 - HelloL10N] invalid resource directory name: C:\Documents and Settings\abc\workspace\HelloL10N\res/drawable-hdpi-fr-rCA
[2011-04-04 14:35:14 - HelloL10N] invalid resource directory name: C:\Documents and Settings\abc\workspace\HelloL10N\res/drawable-hdpi-fr-rFR
[2011-04-04 14:35:14 - HelloL10N] invalid resource directory name: C:\Documents and Settings\abc\workspace\HelloL10N\res/drawable-hdpi-ja-rJP
I am unable to understand the reason for such an issue.
One more thing i am curious to know whether i have to create three resources in place of one for e.g. i have one image file so i have to upload it in drawable-hdpi, drawable-mdpi and drawable-ldpi with different screen resolutions?
Please help me on this
Thanks
Pankaj
To do what you want, you must create folders named like this :
drawable-de-rDE-hdpi,
drawable-de-rDE-mdpi,
drawable-de-rDE-ldpi, ...
I hope will be helpful
use drawable-de-rDE-mdpi instead of drawable-hdpi-de-rDE .
I was experiencing the same problem in another Android example then I deleted those Thumds.db files, and that fixed it.