Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rebuilding of APK is failing when I am using AAPT2 externally with APKTOOL. #1918

Closed
tohaidar2005 opened this issue Oct 11, 2018 · 13 comments · Fixed by #1960

Comments

@tohaidar2005
Copy link

commented Oct 11, 2018

Information

Apktool Version (apktool_2.3.4) -
Operating System (Linux CentOS 7.x) -
APK built with gradle version 3.0-

stacktrace here

W: /home/KonyEMM/apache-tomcat-7.0.42/temp/wrap-build/7839384485809358568/1000000000000/luavmandroid/res/values/ids.xml:3: error: <item> inner element must either be a resource reference or empty.
W: /home/KonyEMM/apache-tomcat-7.0.42/temp/wrap-build/7839384485809358568/1000000000000/luavmandroid/res/values/ids.xml:4: error: <item> inner element must either be a resource reference or empty.
W: /home/KonyEMM/apache-tomcat-7.0.42/temp/wrap-build/7839384485809358568/1000000000000/luavmandroid/res/values/ids.xml:5: error: <item> inner element must either be a resource reference or empty.
W: /home/KonyEMM/apache-tomcat-7.0.42/temp/wrap-build/7839384485809358568/1000000000000/luavmandroid/res/values/ids.xml:6: error: <item> inner element must either be a resource reference or empty.
.
.
.
.
brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [/mnt/emm_config/tools/apktool/aapt2, compile, --dir, /home/KonyEMM/apache-tomcat-7.0.42/temp/wrap-build/7839384485809358568/1000000000000/luavmandroid/res, --legacy, -o, /home/KonyEMM/apache-tomcat-7.0.42/temp/wrap-build/7839384485809358568/1000000000000/luavmandroid/build/resources.zip]
2018-10-09, 17:55:31 ERROR [] : com.kony.mam.wrap.AntLoggerListener - Result: 1
2018-10-09, 17:55:31 ERROR [] : com.kony.mam.wrap.AntLoggerListener - Task &quot;fail&quot; finished with error.
org.apache.tools.ant.BuildException: 300
	at org.apache.tools.ant.taskdefs.Exit.execute(Exit.java:164) ~[ant-1.9.1.jar:?]
	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292) ~[ant-1.9.1.jar:1.9.1]
	at sun.reflect.GeneratedMethodAccessor272.invoke(Unknown Source) ~[?:?]

Steps to Reproduce

I am trying below command to rebuild the apk, This apk is built from gradle version >3.0
• $apktool d -f -s -a aapt2 --frame-path /logs <sampleApp.apk>: Using this command to decode the APK
•$apktool b -a aapt2 --frame-path /logs -f inputDir -o out.apk : Using this command to bind the APK back.

Decoding of APK is working as expected but whenever trying to bind it again it is throwing error as above.

Just I wanted to know that using above commands are recommended?
I am trying to use these command because same commands already implemented with AAPT and it were working fine.

Please find the attached APK from this location : https://www.dropbox.com/s/7l1dyf5f3xfxndn/TestApp.apk?dl=0

@tohaidar2005 tohaidar2005 changed the title Rebuilding of APK is failing when I am using external AAPT2 with APKTOOL. Rebuilding of APK is failing when I am using AAPT2 externally with APKTOOL. Oct 11, 2018

@tohaidar2005

This comment has been minimized.

Copy link
Author

commented Oct 11, 2018

For AAPT, we are using the above commands and it's working fine...I am not sure whether I am using correct command or not in case of AAPT2. Please guide me if anything is wrong there in the command.

@gino247

This comment has been minimized.

Copy link

commented Oct 15, 2018

Hi,

I have the same issue with aapt2.
I am not sure if the decompiling is adding information to the res/ids.xml file.
I must still dig a bit.
If you check your res/ids.xml file, then you'll notice that the <item> has a value in the tag.
For me it was
<item type="..." name="...">false</item>
I removed the false and it built fine.

Regards,

@tohaidar2005

This comment has been minimized.

Copy link
Author

commented Oct 15, 2018

I am also getting the same content under the res/ids.xml
Are you removing false manually from the ids.xml??

Regards,

@gino247

This comment has been minimized.

Copy link

commented Oct 15, 2018

Hi,
Yes just to test if aapt2 works.
Will try and have a look as to why later tonight.
Regards,

@gino247

This comment has been minimized.

Copy link

commented Oct 16, 2018

Hi,
Ok so this link will explain what is happening, https://stackoverflow.com/a/26073822/2527077.
I have created a fix on the apktool itself, not sure it's the best place.
Will wait for iBotPeaches to come back and confirm all is good, then hopefully there will be a release soon.
In the meantime you can pull the branch issues-1918 from my repo and build the jar. It's a gradle project so not much to change if any.

Regards,

@tohaidar2005

This comment has been minimized.

Copy link
Author

commented Oct 16, 2018

Thank you gino247 for the response.

Rebuilding of APK is working fine when I am running the below commands without passing AAPT2 but not sure that whether this is recommended or not? Looking response from iBotPeaches on this.

$apktool d -f -s --frame-path /logs <sampleApp.apk>
$apktool b --frame-path /logs -f inputDir -o out.apk

I am using latest APKTOOL version i.e. 2.3.4 for rebuilding the apk. Actually both the version of aapt2 (one which already incorporated in the APKTOOL and other which I am using externally) are the same version. Conceptually it should work externally as well if it is working with above commands.

@gino247

This comment has been minimized.

Copy link

commented Oct 16, 2018

Hi,

We have been using aapt for a while now and Playstore was accepting without issues, until August when the Android Gods decided to promote the minimum api level from 23 to 26. This was when we found the bug in aapt.

No worries just trying to help.

Regards,

@iBotPeaches

This comment has been minimized.

Copy link
Owner

commented Oct 16, 2018

Am I understanding correctly the root problem is

source

    <item name="test_id" type="id"/>

apktool

    <item name="test_id" type="id">false</item>

Where apktool should NOT place "false" for empty ids and instead do an empty item block like -

    <item name="test_id" type="id"/>
or
    <item name="test_id" type="id"></item>
@gino247

This comment has been minimized.

Copy link

commented Oct 16, 2018

Yes.

The one pull request I created filter's it out on file creation.
I'm not sure where the res table get's populated to stop it happening there.

Regards,

@tohaidar2005

This comment has been minimized.

Copy link
Author

commented Oct 16, 2018

Thanks gino247 for help.

Lets wait further response from iBotPeaches.

Regards,

@tohaidar2005

This comment has been minimized.

Copy link
Author

commented Oct 18, 2018

Sorry to interrupt here...
@iBotPeaches : Just wanted to know that when can expect next release with this fix?

Regards,

@iBotPeaches

This comment has been minimized.

Copy link
Owner

commented Oct 18, 2018

@tohaidar2005 I always do a New Years / Holiday release. So look for last week of December.

@tohaidar2005

This comment has been minimized.

Copy link
Author

commented Oct 19, 2018

Thanks a lot for response.

iBotPeaches added a commit that referenced this issue Jan 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.