Commit Graph

526 Commits

Author SHA1 Message Date
Igor Eisberg
8084762274
Fix recompile of miui.apk by allowing package renaming
This old issue prevented the package to be renamed from com.miui.core to miui, making it impossible to recompile, as all attributes are refefred to as miui:*/*. This fixes it permanently.
2019-07-14 06:54:32 -04:00
Connor Tumbleson
25a1cb02ef
fix: License 2019 update 2019-07-13 12:19:41 -04:00
Shaheen Gandhi
2bc8feb549 Add attr resource type handling 2019-07-02 19:23:33 -04:00
Connor Tumbleson
5f43a1fbca
style: cleanup formatting 2019-06-01 09:27:41 -04:00
Adib Faramarzi
61088302e3 Add unit tests
- add APK file containing a simple app that tries to use coroutines every 2 seconds, and would fail with earlier versions of APKTool
- add unit test for decoding the app
- add unit test for building a decoded app
2019-05-30 22:18:04 +04:30
Adib Faramarzi
cfd50acd1d Add unit tests
- add APK file containing a simple app that tries to use coroutines every 2 seconds, and would fail with earlier versions of APKTool
- add unit test for decoding the app
2019-05-30 22:12:57 +04:30
Adib Faramarzi
fa99bdd19d Fix removal of META-INF/services folder
- copy the META-INF/services folder to the destination APK folder so it does not get dropped
2019-05-30 19:08:21 +04:30
Adib Faramarzi
154da4c643 Fix removal of META-INF/services folder
- copy the META-INF/services folder to the destination APK folder so it does not get dropped
2019-05-30 18:46:59 +04:30
Connor Tumbleson
adbde1745f fix: "qpm" can exist without 9patch, and use new "copyToDir" 2019-04-26 11:14:31 -04:00
Connor Tumbleson
73ac0d96fb
Merge pull request #2066 from iBotPeaches/issue-2045
Support for SDK_Q shorthand
2019-04-24 19:56:15 -04:00
Connor Tumbleson
f3f634f010 fix: add SDK_Q (test) value of 10,000 2019-04-24 18:46:48 -04:00
Connor Tumbleson
2e75f7b799 fix: create directory if doesn't exist, before error 2019-04-24 18:45:57 -04:00
Connor Tumbleson
8e00de38a0
Merge branch 'master' into patch-1 2019-02-27 18:26:02 -05:00
Igor Eisberg
400a463286
Fix APKs with SDK versions being reference values
This non-standard behavior is rare, but quite annoying.
The solution is simple - replacing the reference value with the actual value from integers.xml, just like Apktool already does for versionName.
2019-02-20 08:26:17 -05:00
Igor Eisberg
49e55f522f
Fix APKs with SDK versions being reference values
This non-standard behavior is rare, but quite annoying.
The solution is simple - replacing the reference value with the actual value from integers.xml, just like Apktool already does for versionName.
2019-02-20 08:26:14 -05:00
Igor Eisberg
be1aea76fe
Fix reference values not being resolved against frameworks
This Apktool issue has existed for a long time and is especially prevalent with ROMs with multiple frameworks.
The issue happens because Apktool treats reference values inside XMLs (like layouts) as raw text values, and doesn't resolve them during decompile time. This causes some values to be misformed, but more importantly, this causes values referencing to secondary frameworks to not be resolved with their source frameworks, which also means the framework ID won't be added to usesFramework.ids in apktool.yml, and that breaks recompiling.
The interesting thing is that reference values are actually being resolved when they are located in value resources, like styles, thus presenting an inconsistent behavior.
This simple mod eliminates the "rawValue" for reference values, and that forces the "value" (resource ID) to resolve against the respective frameworks, fixing misformed values in the process.

BEFORE:
I: Using Apktool 2.4.0-896569-SNAPSHOT on Notes.apk
I: Loading resource table...
I: Decoding Shared Library (miui), pkgId: 16
I: Decoding Shared Library (miui.system), pkgId: 18
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: bin\framework\1.apk
I: Regular manifest package...
I: Decoding file-resources...
I: Loading resource table from file: bin\framework\16.apk
I: Decoding Shared Library (androidhwext), pkgId: 15
I: Decoding values */* XMLs...
I: Baksmaling classes.dex...
I: Copying assets and libs...
I: Copying unknown files...
I: Copying original files...

Some comparisons before and after the fix:
https://i.imgur.com/2gTllT0.png
https://i.imgur.com/KzJUeQt.png

AFTER:
I: Using Apktool 2.4.0-896569-SNAPSHOT on Notes.apk
I: Loading resource table...
I: Decoding Shared Library (miui), pkgId: 16
I: Decoding Shared Library (miui.system), pkgId: 18
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: bin\framework\1.apk
I: Regular manifest package...
I: Decoding file-resources...
I: Loading resource table from file: bin\framework\16.apk
I: Decoding Shared Library (androidhwext), pkgId: 15
I: Loading resource table from file: bin\framework\18.apk
I: Decoding Shared Library (miui), pkgId: 16
I: Decoding Shared Library (android.miui), pkgId: 17
I: Decoding values */* XMLs...
I: Baksmaling classes.dex...
I: Copying assets and libs...
I: Copying unknown files...
I: Copying original files...
2019-02-18 06:47:09 -05:00
IgorEisberg
1e68bb0ede
feat: Fill missing 9patch lines to fix recompile
Somehow Google manages to compile MiuiSystemUI.apk (and a few other APKs I encountered) with a misformed pip_dismiss_scrim.9.png.
Either way, every time I encountered such 9.patch images, the missing lines always indicated a single full div or padding.
Apktool already fills missing padding lines, now it can also fill missing divs.
2019-02-16 18:52:34 -05:00
IgorEisberg
0efccc2d93
feat: allow configurable api-level for smali 2019-02-16 18:43:25 -05:00
Vincent Barthelemy
13e356f2ef fix: use the res type spec name to create res bag value
Starting with the version 28.0.3 of the Android SDK build tools,
the internal ids of the items of an array bag seems to have changed.

Because of those changes, array resources were no longer decoded correctly.
They were decoded as style resources.

Instead of using the id of the first item within a resource bag,
the name of the res type spec is now used to choose the correct
resource bag value to create.

Note: a list of "legal names" for resource types  can be found in the source code of aapt2.
2019-01-29 10:07:40 +01:00
Connor Tumbleson
016dc25fa9
Merge branch 'master' into master 2019-01-09 17:18:19 -05:00
Connor Tumbleson
45152c269a refactor: use specific exceptions when decoding raw xml 2019-01-09 17:11:51 -05:00
Connor Tumbleson
c1f50a2810 style: remove unused LOGGER for PullStreamDecoder 2019-01-09 17:11:32 -05:00
Connor Tumbleson
6bb73b509d fix: throw specific errors during XMLPullParser error 2019-01-09 17:10:56 -05:00
Connor Tumbleson
ac3518e098 feat: add new exception types 2019-01-09 17:10:21 -05:00
Sebastian Rasmussen
b01dce7f3a Adapt AXMLResourceParser to handle broken headers.
Fixes #1976.
2019-01-08 21:20:50 +01:00
Connor Tumbleson
7cd8946849 fix: fallback to raw decoder if xml decoder failed
- prevents injection of false value
2019-01-04 18:00:19 -05:00
Connor Tumbleson
f997e0aff1 fix: patch out bools on ResBooleans, as they must be empty
- refs: #1918
2019-01-03 16:57:23 -05:00
Connor Tumbleson
e82537e340 Merge branch 'no-crunch-aapt-option' of https://github.com/Novex/Apktool 2018-12-18 16:24:27 -05:00
a-bahmani
db553ebe8d
Fix null pointer
When I am decompiling an apk, I got this exception:
Exception in thread "main" java.lang.NullPointerException
        at brut.androlib.res.data.ResResSpec.<init>(ResResSpec.java:42)
2018-12-17 23:42:28 +03:30
Connor Tumbleson
3f85dfa6c9 fix: revert change that enforced "STRINGPOOL_TYPE" on StringPool
- fixes: #1876
2018-08-23 17:14:38 -04:00
Seb Patane
b0fd764df4 feat: Expose the aapt --no-crunch option
- Add a --no-crunch/-nc flag to apktool which gets passed through to aapt
- This allows apktool to make a byte-for-byte copy of resource files
- refs: #1232
2018-07-24 13:54:37 +10:00
Alexei Khlebnikov
564b285126 fix: add file extension to doNotCompress only if the file size is not 0 2018-07-19 18:14:48 +02:00
Connor Tumbleson
061ddb8ee6 fix: remove hardcoded list of no-compressed assets
- We no longer use aapt for building assets, so this code is never ran
 in aapt1/2. So we can no longer skip these assets.
2018-04-12 11:45:29 -04:00
Connor Tumbleson
6554881606 Revert "options: deprecate "doNotCompress", introduce "noCompressAssets""
This reverts commit cb6b6dfda8.
2018-04-06 14:59:10 -04:00
Connor Tumbleson
d755724ed8 Revert "decode: only store full relative path to uncompressed assets"
This reverts commit bd9c9c7cec.
2018-04-06 14:59:03 -04:00
Connor Tumbleson
4d89228686 Revert "decode: store uncompressed assets to new property"
This reverts commit 14eedde165.
2018-04-06 14:58:42 -04:00
Connor Tumbleson
0700c684b6 Revert "build: introduce "buildUnknownAndUncompressedAssets""
This reverts commit e35f66b0e0.
2018-04-06 14:58:35 -04:00
Connor Tumbleson
72196f3544 Revert "fix: normalize paths for uncompressed assets & unknown files"
This reverts commit ca25a26944.
2018-04-06 14:58:11 -04:00
Connor Tumbleson
46ebcb0fab Revert "fix: don't use deprecated property "doNotCompress""
This reverts commit 258fb82fe2.
2018-04-06 14:57:24 -04:00
Connor Tumbleson
bb42ef068e Revert "fix: Applications with implicit sdk versioning lose that information"
This reverts commit 25a164dd10.
2018-04-06 14:57:09 -04:00
Connor Tumbleson
db59f93e36 fix: ignore package "FFFFFFFFFFFFFFFFFFFFFF" to prevent wrong renaming
- refs: #1752 / #1471
2018-04-06 14:46:39 -04:00
Connor Tumbleson
041659c43f style: output "built apk" when task is completed 2018-04-06 14:03:42 -04:00
Connor Tumbleson
25a164dd10 fix: Applications with implicit sdk versioning lose that information
- This is a temporary hack to keep application building, but will not
 work due to missing nearly all resources.
 - refs: #1761
2018-04-06 14:02:41 -04:00
Connor Tumbleson
2d190d019c fix: remove 6 year old experimental smali resource tagger
- refs: #244
 - Regular expressions are not the way to fix this. Too many situations
 in smali where patterns won't work. Correct fix would be to hook dexlib
2018-04-06 12:03:08 -04:00
Connor Tumbleson
258fb82fe2 fix: don't use deprecated property "doNotCompress" 2018-04-06 10:49:08 -04:00
Connor Tumbleson
ca25a26944 fix: normalize paths for uncompressed assets & unknown files 2018-04-06 10:31:28 -04:00
Connor Tumbleson
e35f66b0e0 build: introduce "buildUnknownAndUncompressedAssets"
- processes assets that are stored (uncompressed)
 - additionally process unknown files
 - modifies application after build process
 - prevents "too long" execution command
 - fixes #1272
2018-04-05 17:07:55 -04:00
Connor Tumbleson
14eedde165 decode: store uncompressed assets to new property 2018-04-05 17:07:55 -04:00
Connor Tumbleson
bd9c9c7cec decode: only store full relative path to uncompressed assets 2018-04-05 17:07:55 -04:00
Connor Tumbleson
cb6b6dfda8 options: deprecate "doNotCompress", introduce "noCompressAssets" 2018-04-05 17:07:55 -04:00
Connor Tumbleson
7621fdb79c Assume Android P will be API 28
- refs: #1742
2018-03-12 15:34:32 -04:00
Connor Tumbleson
3f8d9fa835 aapt2: patch system for decoding pkgId between 0x7f - 0xff 2018-03-05 10:28:50 -05:00
Connor Tumbleson
448d14592f aapt2: don't rebuild compile stage unless needed 2018-02-28 18:40:13 -05:00
Connor Tumbleson
d2c808dd7d aapt2: refactor loading of aapt/aapt2 binaries
- change: die out if invalid aapt path is provided
2018-02-28 11:25:56 -05:00
Connor Tumbleson
f05bd31e59 aapt2: sparse resource pulling from yaml 2018-02-28 11:05:07 -05:00
Connor Tumbleson
3c84590a1a aapt2: treat verbose output as fine 2018-02-28 10:58:38 -05:00
Connor Tumbleson
5d95b388aa aapt2: beginning use of aapt2 vs aapt1 params 2018-02-22 11:22:40 -05:00
Connor Tumbleson
5a8bc45653 aapt2: aapt2 is a staged build (compile and link).
- we destroy the "compile" stage item after a link, but keep the pending directory
 - apktool then cannot complete link stage
 - if aapt2 is used, lie to system and re-process
 - todo: rethink this
2018-02-22 11:22:40 -05:00
Connor Tumbleson
a8bdad628a aapt2: wire up zipPackage() instead of using aapt1 for final apk package 2018-02-22 11:22:40 -05:00
Connor Tumbleson
f5caccbc2e aapt2: flag for aapt2 and sparse resources to meta-info/apkOptions 2018-02-22 11:22:40 -05:00
Connor Tumbleson
0827b2b7a2 aapt2: read the type spec and infer if sparsely packed 2018-02-22 11:22:40 -05:00
Connor Tumbleson
88987e60b3 aapt2: Add a flag to determine if sparse resources or not 2018-02-22 11:22:40 -05:00
Connor Tumbleson
34a2d03b31
Support for applications with an empty resources.arsc file
- fixes #1730
2018-02-19 06:45:48 -05:00
Connor Tumbleson
b7b449eaaf
We are ignoring typeIdOffset
- missing sample that experiences this
 - needs tests
 - samples requested: https://github.com/iBotPeaches/Apktool/issues/1728
 - refs: f90f2f8dc3
2018-02-16 08:38:07 -05:00
Connor Tumbleson
9fc1ede991
License 2018 update 2018-02-16 08:26:53 -05:00
Connor Tumbleson
1d485d21e9
cleanup formatting in smali-res-tagger
- experiment rewriting resIds in smali to remove need of public.xml
2018-02-16 08:25:34 -05:00
Connor Tumbleson
65fb5c25c2
Revert "switch to "startsWith" to stop AndroResGuard tricks"
This reverts commit c7f4dfe1db.
2018-02-13 08:47:43 -05:00
Connor Tumbleson
085e8f66ef
Switch to loop for checking extensions we are treating as raw
- 9patch (samsung)
 - regular (apple)
 - I imagine this list will grow over time
2018-02-13 08:47:02 -05:00
Connor Tumbleson
c7f4dfe1db
switch to "startsWith" to stop AndroResGuard tricks 2018-02-13 08:46:52 -05:00
Connor Tumbleson
e7d511adf8 Remove unused line
- refs: no issue
2018-02-08 15:17:51 -05:00
Connor Tumbleson
d1857102dd Add spaces where missing to make logic easier to read
- refs: no issue
2018-02-08 15:14:19 -05:00
Connor Tumbleson
bca474272e Support for rebuilding root depth kotlin folder
- refs: #1703
2018-02-07 09:42:56 -05:00
Connor Tumbleson
7d22fc66b5 Initial testing of private namespace
- added sample (removed attribute names)
2017-12-14 10:55:35 -05:00
Connor Tumbleson
b525f235f8 code style cleanup 2017-12-08 16:38:31 -05:00
Connor Tumbleson
a0cd772205 Remove duplicate manifest-only parameter 2017-12-08 16:31:25 -05:00
Nic Allen
88eed24625 Patch APKTool to allow repeated entry offsets to appear 2017-12-07 15:38:25 -08:00
Ruben Anagua
dd81dbfc9c Add ability to force decoding of manifest 2017-12-07 11:33:04 +00:00
Connor Tumbleson
2b9728e9f3 Prevent ugly "Content is not allowed in prolog" warning
- fixes: #1634
2017-12-01 15:21:47 -05:00
Connor Tumbleson
3264f142cb
Remove useless null warning 2017-11-29 07:56:24 -05:00
Matt Insko
5e1a47a827 Treat fonts as raw data, fixes #1662 2017-11-16 09:35:16 -05:00
Connor Tumbleson
c23c1303dd Merge branch 'master' into issue-1639 2017-10-24 15:39:28 -04:00
Connor Tumbleson
0271e55370
Fix regression when --frame-path points to non existing directory
- fixes #1639
2017-10-14 12:36:54 -04:00
Connor Tumbleson
41018a81b8
Remove .exit() falls from library code
- fixes #1640
2017-10-14 12:36:07 -04:00
Connor Tumbleson
3ec4f360ab
Add support for shorthand SDK for bounding check
- fixes #1630
2017-09-28 08:23:02 -04:00
Connor Tumbleson
bc00cce9bd Add support for 4 non-positional attributes
- adds tests
 - fixes #1611
2017-09-19 17:02:42 -04:00
Connor Tumbleson
f0f87c844e Adds ability to skip asset files
- fixes #1605
 - prevents rebuild
2017-09-19 15:51:04 -04:00
Connor Tumbleson
dc33533d76 add tests, make public method 2017-09-19 15:09:25 -04:00
Connor Tumbleson
21e9dd514c cs cleanup 2017-09-19 14:42:14 -04:00
Jan Vidar Krey
5f0d53ba20 Support bounding targetSdkVersion between minSdkVersion and maxSdkVersion
It is possible to create a an AndroidStudio project that uses the following
nonsense settings:

    defaultConfig {
        minSdkVersion 15
        maxSdkVersion 19
        targetSdkVersion 25
    }

The application is successfully built by Android Studio, and the APK
works when installed on the relevant devices, however the app cannot
be re-built with Apktool afterwards.

This patch works around the problem by explicitly setting the
targetSdkVersion to the max of the maxSdkVersion and min of the minSdkVersion
only if these are specified.
2017-09-15 16:24:39 +02:00
Connor Tumbleson
1c33fba646
close reader as well if syntax error 2017-08-27 09:57:32 -04:00
Connor Tumbleson
d6e676c583
Merge branch 'patch-1' of https://github.com/footpatch/Apktool into footpatch-patch-1 2017-08-27 09:56:39 -04:00
Connor Tumbleson
78a80d14b0 Merge pull request #1601 from xpirt/master
fix potential class cast exceptions
2017-08-27 09:55:13 -04:00
Connor Tumbleson
e9618fae6b
Windows binary is still 32 bit 2017-08-27 09:54:36 -04:00
Andrei Conache
9abaa4ee30 fix potential class cast exceptions
- fixes #1444
2017-08-27 15:23:08 +02:00
footpatch
1fddb05b71 Close input stream in SmaliMod.java 2017-08-25 20:47:31 +02:00
Connor Tumbleson
fa966d2d66 Drop 32 bit binaries
- update unix/win/mac 64 bit binaries
 - fixes #1598
 - refs #1594
2017-08-24 15:53:52 -04:00
Connor Tumbleson
0f4cfcb892 Tweak colorimetry to colorMode 2017-08-23 17:03:51 -04:00
Connor Tumbleson
68a7eb7a74 example applications (sparse & not) tests
- update ARSCDecoder to detail sparse applications
2017-08-23 14:43:57 -04:00
Connor Tumbleson
6473611d47 Initial work for Sparsed Resource Types
- die out if encountered
2017-08-23 14:14:48 -04:00
Connor Tumbleson
bf44f9b809 Support for Color HDR & Gamut 2017-08-23 13:53:30 -04:00