diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..ed851e91 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,35 @@ +name: Build +on: + push: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + name: Build apktool.jar + + steps: + - uses: actions/cache@v2 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ matrix.java }}-${{ hashFiles('**/*.gradle*') }} + restore-keys: ${{ runner.os }}-${{ matrix.java }}-gradle- + + - uses: actions/checkout@v2 + + - name: Set up JDK 10 + uses: actions/setup-java@v1 + with: + java-version: 10 + + - name: Build + run: ./gradlew build shadowJar proguard + + - name: Upload + uses: actions/upload-artifact@v2 + with: + name: apktool.jar + path: brut.apktool/apktool-cli/build/libs/apktool-*-small.jar diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index aa906fbd..8c358d86 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,6 +15,7 @@ on: jobs: build-and-test-with-Java-8-and-later: + runs-on: ${{ matrix.os }} name: Build/Test (JDK ${{ matrix.java }}, ${{ matrix.os }}) strategy: fail-fast: false @@ -22,24 +23,27 @@ jobs: matrix: os: [ubuntu-latest, macOS-latest, windows-latest] java: [8, 9, 10, 11, 12, 13, 14] - runs-on: ${{ matrix.os }} + steps: - uses: actions/cache@v2 with: path: | ~/.gradle/caches ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} - restore-keys: | - ${{ runner.os }}-gradle- + key: ${{ runner.os }}-gradle-${{ matrix.java }}-${{ hashFiles('**/*.gradle*') }} + restore-keys: ${{ runner.os }}-${{ matrix.java }}-gradle- + - uses: actions/checkout@v2 + - name: Set up JDK ${{ matrix.java }} uses: actions/setup-java@v1 with: java-version: ${{ matrix.java }} + - name: Build and test - run: ./gradlew.bat build shadowJar proguard if: startsWith(matrix.os, 'windows') == true + run: ./gradlew.bat build shadowJar proguard + - name: Build and test + if: startsWith(matrix.os, 'windows') != true run: ./gradlew build shadowJar proguard - if: startsWith(matrix.os, 'windows') != true \ No newline at end of file diff --git a/README.md b/README.md index 41c360ca..15d7db2e 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ It is NOT intended for piracy and other non-legal uses. It could be used for loc #### Support - [Project Page](https://ibotpeaches.github.io/Apktool/) -- [#apktool on freenode](http://webchat.freenode.net/?channels=apktool) +- [#apktool on libera.chat](https://web.libera.chat/) #### Sponsored by @@ -32,7 +32,7 @@ If you discover a security vulnerability within Apktool, please send an e-mail t - [Documentation](https://ibotpeaches.github.io/Apktool/documentation/) - [Bug Reports](https://github.com/iBotPeaches/Apktool/issues) - [Chat on Gitter](https://gitter.im/iBotPeaches/Apktool) -- [Changelog/Information](http://ibotpeaches.github.io/Apktool/changes/) +- [Changelog/Information](https://ibotpeaches.github.io/Apktool/changes/) - [XDA Post](https://forum.xda-developers.com/t/util-dec-2-2020-apktool-tool-for-reverse-engineering-apk-files.1755243/) - [Source (Github)](https://github.com/iBotPeaches/Apktool) - [Source (Bitbucket)](https://bitbucket.org/iBotPeaches/apktool/) diff --git a/brut.apktool/apktool-lib/build.gradle b/brut.apktool/apktool-lib/build.gradle index d5f1aa1d..6d3e260b 100644 --- a/brut.apktool/apktool-lib/build.gradle +++ b/brut.apktool/apktool-lib/build.gradle @@ -28,14 +28,12 @@ processResources { include '**/*.jar' duplicatesStrategy = DuplicatesStrategy.INCLUDE } - + includeEmptyDirs = false } dependencies { - testImplementation("junit:junit:4.10") { - exclude(module: 'hamcrest-core') - } + testImplementation depends.junit api project(':brut.j.dir'), project(':brut.j.util'), @@ -50,4 +48,4 @@ dependencies { depends.commons_io testImplementation depends.xmlunit -} \ No newline at end of file +} diff --git a/brut.apktool/apktool-lib/src/main/java/brut/androlib/err/CantFindFrameworkResException.java b/brut.apktool/apktool-lib/src/main/java/brut/androlib/err/CantFindFrameworkResException.java index 4a81dc6f..3c5d879b 100644 --- a/brut.apktool/apktool-lib/src/main/java/brut/androlib/err/CantFindFrameworkResException.java +++ b/brut.apktool/apktool-lib/src/main/java/brut/androlib/err/CantFindFrameworkResException.java @@ -27,5 +27,10 @@ public class CantFindFrameworkResException extends AndrolibException { return mPkgId; } + @Override + public String getMessage() { + return String.format("Can't find framework resources for package of id: %d", this.getPkgId()); + } + private final int mPkgId; } diff --git a/brut.apktool/apktool-lib/src/main/resources/brut/androlib/android-framework.jar b/brut.apktool/apktool-lib/src/main/resources/brut/androlib/android-framework.jar index 64facf2b..7f9d07de 100644 Binary files a/brut.apktool/apktool-lib/src/main/resources/brut/androlib/android-framework.jar and b/brut.apktool/apktool-lib/src/main/resources/brut/androlib/android-framework.jar differ diff --git a/brut.apktool/apktool-lib/src/test/java/brut/androlib/BaseTest.java b/brut.apktool/apktool-lib/src/test/java/brut/androlib/BaseTest.java index ec78bd6f..42590884 100644 --- a/brut.apktool/apktool-lib/src/test/java/brut/androlib/BaseTest.java +++ b/brut.apktool/apktool-lib/src/test/java/brut/androlib/BaseTest.java @@ -31,9 +31,8 @@ import java.util.Map; import java.util.Set; import java.util.logging.Logger; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; +import static org.junit.Assert.*; public class BaseTest { @@ -45,16 +44,16 @@ public class BaseTest { Map controlFiles = control.unknownFiles; Map testFiles = test.unknownFiles; - assertTrue(controlFiles.size() == testFiles.size()); + assertEquals(controlFiles.size(), testFiles.size()); // Make sure that the compression methods are still the same for (Map.Entry controlEntry : controlFiles.entrySet()) { - assertTrue(controlEntry.getValue().equals(testFiles.get(controlEntry.getKey()))); + assertEquals(controlEntry.getValue(), testFiles.get(controlEntry.getKey())); } } protected void compareBinaryFolder(String path, boolean res) throws BrutException, IOException { - Boolean exists = true; + boolean exists = true; String prefixPath = ""; if (res) { diff --git a/brut.apktool/apktool-lib/src/test/java/brut/androlib/aapt1/BuildAndDecodeTest.java b/brut.apktool/apktool-lib/src/test/java/brut/androlib/aapt1/BuildAndDecodeTest.java index d6afe3eb..35da287a 100644 --- a/brut.apktool/apktool-lib/src/test/java/brut/androlib/aapt1/BuildAndDecodeTest.java +++ b/brut.apktool/apktool-lib/src/test/java/brut/androlib/aapt1/BuildAndDecodeTest.java @@ -495,7 +495,7 @@ public class BuildAndDecodeTest extends BaseTest { MetaInfo metaInfo = new Androlib().readMetaFile(sTestNewDir); for (String item : metaInfo.doNotCompress) { - assertFalse(item.equals("jpg")); + assertNotEquals("jpg", item); } } diff --git a/brut.apktool/apktool-lib/src/test/java/brut/androlib/decode/Empty9PatchTest.java b/brut.apktool/apktool-lib/src/test/java/brut/androlib/decode/Empty9PatchTest.java index 9d2f762c..25953fa4 100644 --- a/brut.apktool/apktool-lib/src/test/java/brut/androlib/decode/Empty9PatchTest.java +++ b/brut.apktool/apktool-lib/src/test/java/brut/androlib/decode/Empty9PatchTest.java @@ -29,6 +29,7 @@ import org.junit.Test; import java.io.File; import java.io.IOException; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; public class Empty9PatchTest extends BaseTest { @@ -58,6 +59,6 @@ public class Empty9PatchTest extends BaseTest { File aPng = new File(sTestOrigDir,"res/drawable-xhdpi/empty.9.png"); assertTrue(aPng.isFile()); - assertTrue(aPng.length() == 0); + assertEquals(0, aPng.length()); } } \ No newline at end of file diff --git a/brut.apktool/apktool-lib/src/test/java/brut/androlib/decode/ForceManifestDecodeNoResourcesTest.java b/brut.apktool/apktool-lib/src/test/java/brut/androlib/decode/ForceManifestDecodeNoResourcesTest.java index ab521e8a..b792a27b 100644 --- a/brut.apktool/apktool-lib/src/test/java/brut/androlib/decode/ForceManifestDecodeNoResourcesTest.java +++ b/brut.apktool/apktool-lib/src/test/java/brut/androlib/decode/ForceManifestDecodeNoResourcesTest.java @@ -30,12 +30,11 @@ import java.io.File; import java.io.IOException; import java.util.Arrays; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; public class ForceManifestDecodeNoResourcesTest extends BaseTest { - private byte[] xmlHeader = new byte[] { + private final byte[] xmlHeader = new byte[] { 0x3C, // < 0x3F, // ? 0x78, // x @@ -68,7 +67,7 @@ public class ForceManifestDecodeNoResourcesTest extends BaseTest { // lets probe filetype of manifest, we should detect XML File manifestFile = new File(output + File.separator + "AndroidManifest.xml"); byte[] magic = TestUtils.readHeaderOfFile(manifestFile, 6); - assertTrue(Arrays.equals(this.xmlHeader, magic)); + assertArrayEquals(this.xmlHeader, magic); // confirm resources.arsc still exists, as its raw File resourcesArsc = new File(output + File.separator + "resources.arsc"); @@ -87,7 +86,7 @@ public class ForceManifestDecodeNoResourcesTest extends BaseTest { // lets probe filetype of manifest, we should detect XML File manifestFile = new File(output + File.separator + "AndroidManifest.xml"); byte[] magic = TestUtils.readHeaderOfFile(manifestFile, 6); - assertTrue(Arrays.equals(this.xmlHeader, magic)); + assertArrayEquals(this.xmlHeader, magic); // confirm resources.arsc does not exist File resourcesArsc = new File(output + File.separator + "resources.arsc"); @@ -106,7 +105,7 @@ public class ForceManifestDecodeNoResourcesTest extends BaseTest { // lets probe filetype of manifest, we should detect XML File manifestFile = new File(output + File.separator + "AndroidManifest.xml"); byte[] magic = TestUtils.readHeaderOfFile(manifestFile, 6); - assertTrue(Arrays.equals(this.xmlHeader, magic)); + assertArrayEquals(this.xmlHeader, magic); // confirm resources.arsc does not exist File resourcesArsc = new File(output + File.separator + "resources.arsc"); diff --git a/brut.apktool/apktool-lib/src/test/java/brut/androlib/decode/MissingVersionManifestTest.java b/brut.apktool/apktool-lib/src/test/java/brut/androlib/decode/MissingVersionManifestTest.java index 4bba6ceb..7065e7f0 100644 --- a/brut.apktool/apktool-lib/src/test/java/brut/androlib/decode/MissingVersionManifestTest.java +++ b/brut.apktool/apktool-lib/src/test/java/brut/androlib/decode/MissingVersionManifestTest.java @@ -21,8 +21,8 @@ import brut.androlib.ApkDecoder; import brut.androlib.BaseTest; import brut.androlib.TestUtils; import brut.androlib.meta.MetaInfo; -import brut.directory.ExtFile; import brut.common.BrutException; +import brut.directory.ExtFile; import brut.util.OS; import org.junit.AfterClass; import org.junit.BeforeClass; @@ -31,7 +31,7 @@ import org.junit.Test; import java.io.File; import java.io.IOException; -import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; public class MissingVersionManifestTest extends BaseTest { @@ -58,6 +58,6 @@ public class MissingVersionManifestTest extends BaseTest { apkDecoder.decode(); MetaInfo metaInfo = new Androlib().readMetaFile(decodedApk); - assertEquals(null, metaInfo.versionInfo.versionName); + assertNull(metaInfo.versionInfo.versionName); } } \ No newline at end of file diff --git a/build.gradle b/build.gradle index c61a09b2..84cdda13 100644 --- a/build.gradle +++ b/build.gradle @@ -16,12 +16,31 @@ import java.nio.charset.StandardCharsets * limitations under the License. */ buildscript { + ext { + year = '2010' + brut = 'Ryszard Wiśniewski' + brutEmail = 'brut.alll@gmail.com' + ibot = 'Connor Tumbleson' + ibotEmail = 'connor.tumbleson@gmail.com' + + depends = [ + baksmali : 'org.smali:baksmali:2.5.2', + commons_cli : 'commons-cli:commons-cli:1.4', + commons_io : 'commons-io:commons-io:2.8.0', + commons_lang : 'org.apache.commons:commons-lang3:3.12.0', + guava : 'com.google.guava:guava:30.1.1-jre', + junit : 'junit:junit:4.13.2', + proguard_gradle: 'com.guardsquare:proguard-gradle:7.0.1', + snakeyaml : 'org.yaml:snakeyaml:1.28:android', + smali : 'org.smali:smali:2.5.2', + xmlpull : 'xpp3:xpp3:1.1.4c', + xmlunit : 'xmlunit:xmlunit:1.6', + ] + } + repositories { mavenCentral() } - tasks.withType(JavaCompile) { - options.encoding = StandardCharsets.UTF_8.toString() - } dependencies { classpath 'com.github.jengelman.gradle.plugins:shadow:6.1.0' } @@ -53,21 +72,18 @@ allprojects { java = 'SLASHSTAR_STYLE' } strictCheck true - - ext.year = '2010' - ext.brut = 'Ryszard Wiśniewski' - ext.brutEmail = 'brut.alll@gmail.com' - ext.ibot = 'Connor Tumbleson' - ext.ibotEmail = 'connor.tumbleson@gmail.com' - } - - tasks.withType(JavaCompile) { - options.compilerArgs += ["-Xlint:-options"] } // license plugin automatically fires these tasks, disable them and run them during releases - gradle.startParameter.excludedTaskNames += "licenseMain" - gradle.startParameter.excludedTaskNames += "licenseTest" + gradle.startParameter.excludedTaskNames += [ + "licenseMain", + "licenseTest" + ] +} + +tasks.withType(JavaCompile).configureEach { + options.encoding = StandardCharsets.UTF_8.toString() + options.compilerArgs += ["-Xlint:-options"] } def mavenVersion = 'unspecified' @@ -82,7 +98,7 @@ if (!('release' in gradle.startParameter.taskNames)) { project.ext.set("hash", hash) project.ext.set("apktool_version", version + "-" + hash + "-SNAPSHOT") mavenVersion = version + "-SNAPSHOT" - println "Building SNAPSHOT (" + getCheckedOutBranch() + "): " + hash + println "Building SNAPSHOT (${getCheckedOutBranch()}): $hash" } } else { project.ext.set("hash", "") @@ -92,7 +108,7 @@ if (!('release' in gradle.startParameter.taskNames)) { project.ext.set("apktool_version", version) } mavenVersion = version - println "Building RELEASE (" + getCheckedOutBranch() + "): " + project.ext.apktool_version + println "Building RELEASE (${getCheckedOutBranch()}): $project.ext.apktool_version" } build.doFirst { @@ -119,22 +135,6 @@ task snapshot { subprojects { apply plugin: 'java' - ext { - depends = [ - baksmali: 'org.smali:baksmali:2.5.2', - commons_cli: 'commons-cli:commons-cli:1.4', - commons_io: 'commons-io:commons-io:2.4', - commons_lang: 'org.apache.commons:commons-lang3:3.12.0', - guava: 'com.google.guava:guava:30.1.1-jre', - junit: 'junit:junit:4.13.2', - proguard_gradle: 'com.guardsquare:proguard-gradle:7.1.0-beta2', - snakeyaml: 'org.yaml:snakeyaml:1.28:android', - smali: 'org.smali:smali:2.5.2', - xmlpull: 'xpp3:xpp3:1.1.4c', - xmlunit: 'xmlunit:xmlunit:1.6', - ] - } - repositories { mavenCentral() }