desword / android-apktool

Automatically exported from code.google.com/p/android-apktool
Other
1 stars 0 forks source link

Recompile APK file errors #660

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Recompile APK file 

2.command used: apktool b App_one(this is an application I am trying to 
decompile, make changes and recompile it back)

3. I modified the string file :
<string name="app_name">Hacked</string>

path :C:\apktool-install-windows-r05-ibot\App_one\res\values\strings

What is the expected output? What do you see instead?
expected output is an modified APK

What I am getting is:

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\apktool-install-windows-r05-ibot>apktool b App_one
I: Checking whether sources has changed...
I: Smaling...
I: Checking whether resources has changed...
I: Building resources...

C:\apktool-install-windows-r05-ibot\App_one\res\values\styles.xml:59: error: 
Error retrieving parent for item: No resource found that matches the given name 
'Widget.AppCompat.Base'.
C:\apktool-install-windows-r05-ibot\App_one\res\values\styles.xml:99: error: 
Error retrieving parent for item: No resource found that matches the given name 
'Widget.AppCompat.Base'.
C:\apktool-install-windows-r05-ibot\App_one\res\values\styles.xml:146: error: 
Error retrieving parent for item: No resource found that matches the given name 
'widget.AppCompat.Base'.
C:\apktool-install-windows-r05-ibot\App_one\res\values\styles.xml:176: error: 
Error retrieving parent for item: No resource found that matches the given name 
'widget.AppCompat.Base'.
C:\apktool-install-windows-r05-ibot\App_one\res\values\styles.xml:192: error: 
Error retrieving parent for item: No resource found that matches the given name 
'widget.AppCompat.Base.DropDownItem'.
C:\apktool-install-windows-r05-ibot\App_one\res\values\styles.xml:218: error: 
Error retrieving parent for item: No resource found that matches the given name 
'widget.AppCompat.Base'.
C:\apktool-install-windows-r05-ibot\App_one\res\values\styles.xml:225: error: 
Error retrieving parent for item: No resource found that matches the given name 
'widget.AppCompat.Light.Base'.
C:\apktool-install-windows-r05-ibot\App_one\res\values\styles.xml:242: error: 
Error retrieving parent for item: No resource found that matches the given name 
'textAppearance.AppCompat.Base'.
C:\apktool-install-windows-r05-ibot\App_one\res\values\styles.xml:275: error: 
Error retrieving parent for item: No resource found that matches the given name 
' widget.AppCompat.Base'.
C:\apktool-install-windows-r05-ibot\App_one\res\values-v14\styles.xml:50: error
 Error retrieving parent for item: No resource found that matches the given name  'Widget.AppCompat.Base'.
C:\apktool-install-windows-r05-ibot\App_one\res\values\styles.xml:467: error: 
Error retrieving parent for item: No resource found that matches the given name 
'Theme.AppCompat.Base'.
Exception in thread "main" brut.androlib.AndrolibException: 
brut.androlib.AndroibException: brut.common.BrutException: could not exec 
command: [aapt, p, --min
sdk-version, 8, --target-sdk-version, 18, -F, 

C:\Users\..\AppData\Local\Tem
\APKTOOL510202042987499910.tmp, -0, arsc, -I, C:\Users\..\apktool\framework 
1.apk, -S, 
C:\apktool-install-windows-r05-ibot\App_one\res, -M, C:\apktool-inst
ll-windows-r05-ibot\App_one\AndroidManifest.xml]
        at brut.androlib.Androlib.buildResourcesFull(Androlib.java:358)
        at brut.androlib.Androlib.buildResources(Androlib.java:283)
        at brut.androlib.Androlib.build(Androlib.java:206)
        at brut.androlib.Androlib.build(Androlib.java:176)
        at brut.apktool.Main.cmdBuild(Main.java:228)
        at brut.apktool.Main.main(Main.java:79)
Caused by: brut.androlib.AndrolibException: brut.common.BrutException: could no
 exec command: [aapt, p, --min-sdk-version, 8, --target-sdk-version, 18, -F, C:
Users\..\AppData\Local\Temp\APKTOOL510202042987499910.tmp, -0, arsc, -I, C:
Users\..\apktool\framework\1.apk, -S, C:\apktool-install-windows-r05-ibot\A
p_one\res, -M, C:\apktool-install-windows-r05-ibot\App_one\AndroidManifest.xml]
        at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.ja
a:357)
        at brut.androlib.Androlib.buildResourcesFull(Androlib.java:336)
        ... 5 more
Caused by: brut.common.BrutException: could not exec command: [aapt, p, --min-s
k-version, 8, --target-sdk-version, 18, -F, C:\Users\..\AppData\Local\Temp\
PKTOOL510202042987499910.tmp, -0, arsc, -I, C:\Users\..\apktool\framework\1
apk, -S, 
C:\apktool-install-windows-r05-ibot\App_one\res, -M, C:\apktool-instal
-windows-r05-ibot\App_one\AndroidManifest.xml]
        at brut.util.OS.exec(OS.java:89)
        at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.ja
a:355)
        ... 6 more

What version of the product are you using? On what operating system?
1.5.2 and Windows 7 64 bit

C:\Users\..>java -version
java version "1.7.0_55"
Java(TM) SE Runtime Environment (build 1.7.0_55-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.55-b03, mixed mode)

Please provide any additional information below.
This issue was touched in topic #256, but I guess this is somewhat different. I 
am trying to do Mobile application security testing. to see if can Modify the 
application. 

I have all the correct files required for APK tool as follows:
1.appt
2.apktool(bat file)
3.apktool jar
4.baksmali-2.0.3
5.smali-2.0.3 

Can anyone please help me understand where am I going wrong?
am I missing on any installation?

The application source code is using progaurd, Am I getting this error because 
the its using proguard? 

and one more question:
The windows requirements instructions for APK tool says:
aapt command in a PATH

does that mean to add the path for aapt in the environment settings?
(I did that as well just to see if makes any difference, but no luck)

Original issue reported on code.google.com by vju...@gmail.com on 24 Jul 2014 at 6:30

GoogleCodeExporter commented 9 years ago
Its actually a style problem. Whether its

1) The style isn't in the frameworks included
2) Invalid resources on decode which are those resources
3) A bug

I'm inclined its either 1 or 2, like the other times this bug has come up. It 
would help to have the APK though. You may email it to me or attach it.

Original comment by connor.tumbleson on 24 Jul 2014 at 6:48

GoogleCodeExporter commented 9 years ago
Thank you so much for the prompt reply, unfortunately I cannot email/attach the 
apk file due to Non-disclosure agreement. 

Can you possibly let me know that how can I add the particular style to the 
framework?
when you mean by framework, are you talking about the APK tool framework(i.e 
1.apk)?
Can you also elaborate on "Invalid resources on decode which are those 
resources"?

Original comment by vju...@gmail.com on 24 Jul 2014 at 6:58

GoogleCodeExporter commented 9 years ago
1) Adding styles is as easy as finding the styles.xml from AOSP / other roms 
and adding them to the local res/values/styles.xml (in order to add missing 
styles)

2) Yes, the resources apktool makes in $HOME/apktool/frameworks/

3) Run "aapt d resources name_of_apk.apk > file" Grep file for "INVALID". If 
you find something like this

"INVALID TYPE CONFIG FOR RESOURCE 0x7f0200ba" then aapt or apktool couldn't 
identify the configuration of the resource. So apktool replaces it with a dummy 
value of false. If this happens to be a style, then you no longer have it. I 
don't know a way around this problem, except finding the styles via 1) and 
adding them in.

Original comment by connor.tumbleson on 24 Jul 2014 at 7:07

GoogleCodeExporter commented 9 years ago
when I enter the command you mentioned I get the following list:
.Widget.Base.ActionBar.Menu: <bag>
        resource 0x7f0b0053 com.app_one.ida.android:style/TextAppearance.AppCompat
.Widget.Base.ActionBar.Title: <bag>
        resource 0x7f0b0054 com.app_one.ida.android:style/TextAppearance.AppCompat
...
...and so on

so does that mean I don't have the style?

Original comment by vju...@gmail.com on 24 Jul 2014 at 7:26

GoogleCodeExporter commented 9 years ago
Thats the expected list, there is no problem with those two resources. Are 
there any lines that are "INVALID TYPE CONFIG FOR RESOURCE" in there?

Original comment by connor.tumbleson on 24 Jul 2014 at 7:27

GoogleCodeExporter commented 9 years ago
I checked thoroughly, there are such line that say "INVALID TYPE CONFIG FOR 
RESOURCE" .

Original comment by vju...@gmail.com on 24 Jul 2014 at 7:31

GoogleCodeExporter commented 9 years ago
My apologies, I meant there No such lines.

Original comment by vju...@gmail.com on 24 Jul 2014 at 7:32

GoogleCodeExporter commented 9 years ago
Finally it worked, I used the beta version of the Apt tool, just made changes 
in the apktool batch file :
@echo off
set PATH=%CD%;%PATH%;
java -jar "%~dp0\apktool_2.0.0b9.jar" %1 %2 %3 %4 %5 %6 %7 %8 %9

And I was able to recompile with no errors.

Original comment by vju...@gmail.com on 25 Jul 2014 at 2:14

GoogleCodeExporter commented 9 years ago
Issue 663 has been merged into this issue.

Original comment by connor.tumbleson on 4 Aug 2014 at 11:53

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Issue 665 has been merged into this issue.

Original comment by connor.tumbleson on 7 Aug 2014 at 12:06

GoogleCodeExporter commented 9 years ago
Issue 669 has been merged into this issue.

Original comment by connor.tumbleson on 16 Aug 2014 at 3:11

GoogleCodeExporter commented 9 years ago
Issue 678 has been merged into this issue.

Original comment by connor.tumbleson on 24 Sep 2014 at 12:20

GoogleCodeExporter commented 9 years ago
Same issue with com.greenbeansoft.CheckmarkLite application.

Apktool v2.0.0-RC3 - a tool for reengineering Android apk files
with smali v2.0.3 and baksmali v2.0.3
AAPT extracted from apktool

Had to add 11 style definitions for APK to compile

Original comment by fr0st.br...@gmail.com on 8 Dec 2014 at 4:10

GoogleCodeExporter commented 9 years ago
I will add a Wiki entry explaining the process of adding themes internally to 
an APK, since app developers utilized private resources :(

Since I don't believe its Apktool's job to identify missing themes and find 
them / install them. I will close this.

Original comment by connor.tumbleson on 26 Dec 2014 at 12:36