mirror of
https://github.com/revanced/Apktool.git
synced 2024-12-04 18:12:54 +01:00
Merge pull request #1960 from iBotPeaches/android-9.0.0_r22
Sync aapt binaries with aapt1/aapt2 + no-crunch
This commit is contained in:
commit
261e163bc9
@ -194,7 +194,7 @@ is just a guideline but helps me to release a new version every 3 months.
|
||||
### Social Spam
|
||||
|
||||
The final step is to send this release into the wild via some social posting. Head to the blog
|
||||
where the release post was and send that link to Twiter, Google and whatever else you use.
|
||||
where the release post was and send that link to Twitter, Google and whatever else you use.
|
||||
|
||||
Relax and watch the bug tracker.
|
||||
|
||||
@ -225,8 +225,8 @@ we aren't building the entire AOSP package, the initial build is to just see if
|
||||
|
||||
We check out a certain tag. Currently we use
|
||||
|
||||
* aapt2 - `android-9.0.0_r3`.
|
||||
* aapt1 - `android-9.0.0_r3`.
|
||||
* aapt2 - `android-9.0.0_r22`.
|
||||
* aapt1 - `android-9.0.0_r22`.
|
||||
|
||||
### Including our modified `frameworks/base` package.
|
||||
|
||||
@ -254,6 +254,7 @@ we lose the ability to quickly build just the aapt binary. So the Windows proced
|
||||
1. `source build/envsetup.sh`
|
||||
2. `lunch sdk-eng`
|
||||
3. `make OUT_DIR=out-x64 LOCAL_MULTILIB=64 USE_NINJA=false aapt`
|
||||
4. `strip out-x64/host/darwin-x86/bin/aapt_64`
|
||||
|
||||
As of Android Oreo (API 26) all aapt binaries are 64 bit (With exception of Windows).
|
||||
|
||||
@ -274,7 +275,7 @@ we lose the ability to quickly build just the aapt2 binary. So the Windows proce
|
||||
1. `export ANDROID_JAVA_HOME=/Path/To/Jdk`
|
||||
2. `source build/envsetup.sh`
|
||||
3. `make OUT_DIR=out-x64 LOCAL_MULTILIB=64 USE_NINJA=false aapt2`
|
||||
4. `strip out-x64/host/darwin-x86/bin/aapt2`
|
||||
4. `strip out-x64/host/darwin-x86/bin/aapt2_64`
|
||||
|
||||
#### Confirming aapt/aapt2 builds are static
|
||||
|
||||
|
@ -218,6 +218,9 @@ public class Main {
|
||||
if (cli.hasOption("p") || cli.hasOption("frame-path")) {
|
||||
apkOptions.frameworkFolderLocation = cli.getOptionValue("p");
|
||||
}
|
||||
if (cli.hasOption("nc") || cli.hasOption("no-crunch")) {
|
||||
apkOptions.noCrunch = true;
|
||||
}
|
||||
|
||||
// Temporary flag to enable the use of aapt2. This will tranform in time to a use-aapt1 flag, which will be
|
||||
// legacy and eventually removed.
|
||||
@ -397,6 +400,11 @@ public class Main {
|
||||
.desc("Copies original AndroidManifest.xml and META-INF. See project page for more info.")
|
||||
.build();
|
||||
|
||||
Option noCrunchOption = Option.builder("nc")
|
||||
.longOpt("no-crunch")
|
||||
.desc("Disable crunching of resource files during the build step.")
|
||||
.build();
|
||||
|
||||
Option tagOption = Option.builder("t")
|
||||
.longOpt("tag")
|
||||
.desc("Tag frameworks using <tag>.")
|
||||
@ -439,6 +447,7 @@ public class Main {
|
||||
BuildOptions.addOption(aaptOption);
|
||||
BuildOptions.addOption(originalOption);
|
||||
BuildOptions.addOption(aapt2Option);
|
||||
BuildOptions.addOption(noCrunchOption);
|
||||
}
|
||||
|
||||
// add global options
|
||||
@ -492,6 +501,7 @@ public class Main {
|
||||
allOptions.addOption(verboseOption);
|
||||
allOptions.addOption(quietOption);
|
||||
allOptions.addOption(aapt2Option);
|
||||
allOptions.addOption(noCrunchOption);
|
||||
}
|
||||
|
||||
private static String verbosityHelp() {
|
||||
|
@ -28,6 +28,7 @@ public class ApkOptions {
|
||||
public boolean isFramework = false;
|
||||
public boolean resourcesAreCompressed = false;
|
||||
public boolean useAapt2 = false;
|
||||
public boolean noCrunch = false;
|
||||
public Collection<String> doNotCompress;
|
||||
|
||||
public String frameworkFolderLocation = null;
|
||||
|
@ -350,6 +350,10 @@ final public class AndrolibResources {
|
||||
cmd.add("-v");
|
||||
}
|
||||
|
||||
if (apkOptions.noCrunch) {
|
||||
cmd.add("--no-crunch");
|
||||
}
|
||||
|
||||
try {
|
||||
OS.exec(cmd.toArray(new String[0]));
|
||||
LOGGER.fine("aapt2 compile command ran: ");
|
||||
@ -485,6 +489,9 @@ final public class AndrolibResources {
|
||||
if (apkOptions.debugMode) { // inject debuggable="true" into manifest
|
||||
cmd.add("--debug-mode");
|
||||
}
|
||||
if (apkOptions.noCrunch) {
|
||||
cmd.add("--no-crunch");
|
||||
}
|
||||
// force package id so that some frameworks build with correct id
|
||||
// disable if user adds own aapt (can't know if they have this feature)
|
||||
if (mPackageId != null && ! customAapt && ! mSharedLibrary) {
|
||||
|
@ -83,6 +83,13 @@ public abstract class ResScalarValue extends ResIntBasedValue implements
|
||||
}
|
||||
}
|
||||
|
||||
// Android does not allow values (false) for ids.xml anymore
|
||||
// https://issuetracker.google.com/issues/80475496
|
||||
// But it decodes as a ResBoolean, which makes no sense. So force it to empty
|
||||
if (type.equalsIgnoreCase("id") && !body.isEmpty()) {
|
||||
body = "";
|
||||
}
|
||||
|
||||
// check for using attrib as node or item
|
||||
String tagName = item ? "item" : type;
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
BIN
brut.apktool/apktool-lib/src/main/resources/prebuilt/linux/aapt
Executable file
BIN
brut.apktool/apktool-lib/src/main/resources/prebuilt/linux/aapt
Executable file
Binary file not shown.
BIN
brut.apktool/apktool-lib/src/main/resources/prebuilt/linux/aapt2
Executable file
BIN
brut.apktool/apktool-lib/src/main/resources/prebuilt/linux/aapt2
Executable file
Binary file not shown.
BIN
brut.apktool/apktool-lib/src/main/resources/prebuilt/linux/aapt2_64
Executable file
BIN
brut.apktool/apktool-lib/src/main/resources/prebuilt/linux/aapt2_64
Executable file
Binary file not shown.
BIN
brut.apktool/apktool-lib/src/main/resources/prebuilt/linux/aapt_64
Executable file
BIN
brut.apktool/apktool-lib/src/main/resources/prebuilt/linux/aapt_64
Executable file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
brut.apktool/apktool-lib/src/main/resources/prebuilt/windows/aapt2_64.exe
Executable file
BIN
brut.apktool/apktool-lib/src/main/resources/prebuilt/windows/aapt2_64.exe
Executable file
Binary file not shown.
BIN
brut.apktool/apktool-lib/src/main/resources/prebuilt/windows/aapt_64.exe
Executable file
BIN
brut.apktool/apktool-lib/src/main/resources/prebuilt/windows/aapt_64.exe
Executable file
Binary file not shown.
@ -198,6 +198,11 @@ public class BuildAndDecodeTest extends BaseTest {
|
||||
compareXmlFiles("res/xml/references.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void xmlIdsEmptyTest() throws BrutException {
|
||||
compareXmlFiles("res/values/ids.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void xmlReferenceAttributeTest() throws BrutException {
|
||||
compareXmlFiles("res/layout/issue1040.xml");
|
||||
|
@ -77,8 +77,8 @@ public class DebugTagRetainedTest extends BaseTest {
|
||||
|
||||
String expected = TestUtils.replaceNewlines("<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>" +
|
||||
"<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\" android:compileSdkVersion=\"23\" " +
|
||||
"android:compileSdkVersionCodename=\"6.0-2438415\" package=\"com.ibotpeaches.issue1235\" platformBuildVersionCode=\"23\" " +
|
||||
"platformBuildVersionName=\"6.0-2438415\"> <application android:debuggable=\"true\"/></manifest>");
|
||||
"android:compileSdkVersionCodename=\"6.0-2438415\" package=\"com.ibotpeaches.issue1235\" platformBuildVersionCode=\"20\" " +
|
||||
"platformBuildVersionName=\"4.4W.2-1537038\"> <application android:debuggable=\"true\"/></manifest>");
|
||||
|
||||
byte[] encoded = Files.readAllBytes(Paths.get(sTmpDir + File.separator + apk + File.separator + "AndroidManifest.xml"));
|
||||
String obtained = TestUtils.replaceNewlines(new String(encoded));
|
||||
|
@ -72,7 +72,7 @@ public class ProviderAttributeTest extends BaseTest {
|
||||
apkDecoder.decode();
|
||||
|
||||
String expected = TestUtils.replaceNewlines("<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n" +
|
||||
"<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\" android:compileSdkVersion=\"23\" android:compileSdkVersionCodename=\"6.0-2438415\" package=\"com.ibotpeaches.issue636\" platformBuildVersionCode=\"23\" platformBuildVersionName=\"6.0-2438415\">\n" +
|
||||
"<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\" android:compileSdkVersion=\"23\" android:compileSdkVersionCodename=\"6.0-2438415\" package=\"com.ibotpeaches.issue636\" platformBuildVersionCode=\"22\" platformBuildVersionName=\"5.1-1756733\">\n" +
|
||||
" <application android:allowBackup=\"true\" android:debuggable=\"true\" android:icon=\"@mipmap/ic_launcher\" android:label=\"@string/app_name\" android:theme=\"@style/AppTheme\">\n" +
|
||||
" <provider android:authorities=\"com.ibotpeaches.issue636.Provider\" android:exported=\"false\" android:grantUriPermissions=\"true\" android:label=\"@string/app_name\" android:multiprocess=\"false\" android:name=\"com.ibotpeaches.issue636.Provider\"/>\n" +
|
||||
" <provider android:authorities=\"com.ibotpeaches.issue636.ProviderTwo\" android:exported=\"false\" android:grantUriPermissions=\"true\" android:label=\"@string/app_name\" android:multiprocess=\"false\" android:name=\"com.ibotpeaches.issue636.ProviderTwo\"/>\n" +
|
||||
|
@ -84,6 +84,11 @@ public class BuildAndDecodeTest extends BaseTest {
|
||||
compareXmlFiles("res/navigation/nav_graph.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void xmlIdsEmptyTest() throws BrutException {
|
||||
compareXmlFiles("res/values/ids.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void leadingDollarSignResourceNameTest() throws BrutException {
|
||||
compareXmlFiles("res/drawable/$avd_hide_password__0.xml");
|
||||
|
@ -64,7 +64,7 @@ public class ExternalEntityTest extends BaseTest {
|
||||
|
||||
String expected = TestUtils.replaceNewlines("<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
|
||||
"<manifest android:versionCode=\"1\" android:versionName=\"1.0\" android:compileSdkVersion=\"23\" android:compileSdkVersionCodename=\"6.0-2438415\" " +
|
||||
"hardwareAccelerated=\"true\" package=\"com.ibotpeaches.doctype\" platformBuildVersionCode=\"23\" platformBuildVersionName=\"6.0-2438415\" " +
|
||||
"hardwareAccelerated=\"true\" package=\"com.ibotpeaches.doctype\" platformBuildVersionCode=\"24\" platformBuildVersionName=\"6.0-2456767\" " +
|
||||
"xmlns:android=\"http://schemas.android.com/apk/res/android\"> <supports-screens android:anyDensity=\"true\" android:smallScreens=\"true\" " +
|
||||
"android:normalScreens=\"true\" android:largeScreens=\"true\" android:resizeable=\"true\" android:xlargeScreens=\"true\" /></manifest>");
|
||||
|
||||
|
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<resources>
|
||||
<item type="id" name="test_attr1" />
|
||||
</resources>
|
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<resources>
|
||||
<attr format="integer" name="test_attr1"/>
|
||||
</resources>
|
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<resources>
|
||||
<item type="id" name="test_attr1" />
|
||||
</resources>
|
@ -35,17 +35,20 @@ public class AaptManager {
|
||||
File aaptBinary;
|
||||
String aaptVersion = getAaptBinaryName(version);
|
||||
|
||||
if (! OSDetection.is64Bit() && ! OSDetection.isWindows()) {
|
||||
if (! OSDetection.is64Bit() && OSDetection.isMacOSX()) {
|
||||
throw new BrutException("32 bit OS detected. No 32 bit binaries available.");
|
||||
}
|
||||
|
||||
// Set the 64 bit flag
|
||||
aaptVersion += OSDetection.is64Bit() ? "_64" : "";
|
||||
|
||||
try {
|
||||
if (OSDetection.isMacOSX()) {
|
||||
aaptBinary = Jar.getResourceAsFile("/prebuilt/" + aaptVersion + "/macosx/" + aaptVersion, AaptManager.class);
|
||||
aaptBinary = Jar.getResourceAsFile("/prebuilt/macosx/" + aaptVersion, AaptManager.class);
|
||||
} else if (OSDetection.isUnix()) {
|
||||
aaptBinary = Jar.getResourceAsFile("/prebuilt/" + aaptVersion + "/linux/" + aaptVersion, AaptManager.class);
|
||||
aaptBinary = Jar.getResourceAsFile("/prebuilt/linux/" + aaptVersion, AaptManager.class);
|
||||
} else if (OSDetection.isWindows()) {
|
||||
aaptBinary = Jar.getResourceAsFile("/prebuilt/" + aaptVersion + "/windows/" + aaptVersion + ".exe", AaptManager.class);
|
||||
aaptBinary = Jar.getResourceAsFile("/prebuilt/windows/" + aaptVersion + ".exe", AaptManager.class);
|
||||
} else {
|
||||
throw new BrutException("Could not identify platform: " + OSDetection.returnOS());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user