Skip to content

Commit

Permalink
Merge branch 'upstream'
Browse files Browse the repository at this point in the history
# Conflicts:
#	brut.apktool/apktool-lib/src/main/java/brut/androlib/AaptInvoker.java
#	brut.apktool/apktool-lib/src/main/java/brut/androlib/ApkDecoder.java
#	brut.apktool/apktool-lib/src/main/java/brut/androlib/res/ResourcesDecoder.java
#	brut.apktool/apktool-lib/src/test/java/brut/androlib/decode/MissingDiv9PatchTest.java
#	brut.j.util/src/main/java/brut/util/BrutIO.java
#	brut.j.util/src/main/java/brut/util/OSDetection.java
#	build.gradle.kts
  • Loading branch information
oSumAtrIX committed Dec 17, 2024
2 parents b0f3957 + 542b66c commit 8f166d5
Show file tree
Hide file tree
Showing 209 changed files with 5,056 additions and 4,778 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/analyze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ jobs:
uses: actions/checkout@v4

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: java
languages: java-kotlin

- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
31 changes: 23 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,16 @@ jobs:
with:
distribution: 'zulu'
java-version: ${{ matrix.java }}
- name: Build and test
uses: gradle/[email protected]
with:
arguments: build shadowJar proguard

- uses: gradle/actions/[email protected]

- name: Build (Linux/Mac)
if: runner.os != 'Windows'
run: ./gradlew build shadowJar proguard

- name: Build (Windows)
if: runner.os == 'Windows'
run: ./gradlew.bat build shadowJar proguard

upload-artifact:
runs-on: ubuntu-latest
Expand All @@ -91,17 +97,26 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
- name: Build
uses: gradle/[email protected]

- uses: gradle/actions/[email protected]
with:
dependency-graph: generate-and-submit
arguments: build shadowJar proguard

- name: Build (Linux/Mac)
if: runner.os != 'Windows'
run: ./gradlew build shadowJar proguard

- name: Build (Windows)
if: runner.os == 'Windows'
run: ./gradlew.bat build shadowJar proguard

- name: Upload
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: apktool.jar
path: brut.apktool/apktool-cli/build/libs/apktool-v*
2 changes: 1 addition & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ jobs:
with:
distribution: 'zulu'
java-version: 17
- uses: gradle/wrapper-validation[email protected]
- uses: gradle/actions/wrapper-validation@v4.2.1
44 changes: 25 additions & 19 deletions INTERNAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ _Currently broken after movement to kotlin dsl._

Inside `build.gradle` there are two lines.

apktoolversion_major
apktoolversion_minor
version
suffix

The major variable should be left unchanged. If done correctly, it will already be the version
you are about to release. In this case `2.2.2`. The minor variable should read `SNAPSHOT` as
The version variable should be left unchanged. If done correctly, it will already be the version
you are about to release. In this case `2.2.2`. The suffix variable should read `SNAPSHOT` as
the `2.2.2` release up until this point was `SNAPSHOT` releases (Unofficial).

We need to remove the `SNAPSHOT` portion and leave the minor version blank. An example can be
Expand All @@ -26,11 +26,11 @@ with the commit message - `version bump (x.x.x)`.

At this point we now have the commit of the release, but we need to tag it using the following message.

git tag -a vx.x.x -m "changed version to vx.x.x"
git tag -a vx.x.x -m "changed version to vx.x.x" -s

For example for the `2.2.1` release.

git tag -a v2.2.1 -m "changed version to v2.2.1"
git tag -a v2.2.1 -m "changed version to v2.2.1" -s

### Prepare for publishing.

Expand Down Expand Up @@ -219,9 +219,12 @@ where the release post was and send that link to Twitter, Google and whatever el

Relax and watch the bug tracker.

# Building aapt binaries.
# Building aapt2 binaries.

The steps taken for building our modified aapt binaries for apktool.
> [!WARNING]
> aapt (aapt1) is deprecated and no longer receives updates.
The steps taken for building our modified aapt2 binaries for apktool.

### Getting the modified `frameworks/base` repo.
First step is using the [platform_frameworks_base](https://github.com/iBotPeaches/platform_frameworks_base) repo.
Expand Down Expand Up @@ -249,10 +252,10 @@ Some optimization techniques for a smaller clone:
After that, you need to build AOSP via this [documentation](https://source.android.com/source/building.html) guide. Now
we aren't building the entire AOSP package, the initial build is to just see if you are capable of building it.

We check out a certain tag or branch. Currently we use
We check out a certain tag or branch. Currently, we use

* aapt2 - `android-14.0.0_r2`.
* aapt1 - `android-14.0.0_r2`.
* aapt2 - `android-14.0.0_r54`
* aapt1 - `android-14.0.0_r2` (deprecated)

### Including our modified `frameworks/base` package.

Expand All @@ -277,7 +280,7 @@ The steps below are different per flavor and operating system.

#### Linux / Windows
1. `source build/envsetup.sh`
2. `lunch sdk-eng`
2. `lunch aosp_arm64-trunk_staging-eng`
3. `m aapt`
4. `strip out/host/linux-x86/bin/aapt`
5. `strip out/host/linux-x86/bin/aapt_64`
Expand All @@ -296,17 +299,20 @@ The steps below are different per flavor and operating system.
The steps below are different per flavor and operating system.

#### Linux / Windows
1. `source build/envsetup.sh`
1. `lunch aosp_arm64-trunk_staging-eng`
1. `m aapt2`
2. `strip out/host/linux-x86/bin/aapt2`
3. `strip out/host/linux-x86/bin/aapt2_64`
4. `strip out/host/windows-x86/bin/aapt2.exe`
5. `strip out/host/windows-x86/bin/aapt2_64.exe`
1. `strip out/host/linux-x86/bin/aapt2`
1. `strip out/host/linux-x86/bin/aapt2_64`
1. `strip out/host/windows-x86/bin/aapt2.exe`
1. `strip out/host/windows-x86/bin/aapt2_64.exe`

#### Mac
1. `export ANDROID_JAVA_HOME=/Path/To/Jdk`
2. `source build/envsetup.sh`
3. `m aapt2`
4. `strip out/host/darwin-x86/bin/aapt2_64`
1. `source build/envsetup.sh`
1. `lunch aosp_arm64-trunk_staging-eng`
1. `m aapt2`
1. `strip out/host/darwin-x86/bin/aapt2_64`

#### Confirming aapt/aapt2 builds are static

Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
### Apktool
**This is the repository for Apktool. If you are looking for the Apktool website. Click [here](https://github.com/iBotPeaches/Apktool/tree/docs).**
**This is the repository for Apktool. The website is on the [Apktool docs branch](https://github.com/iBotPeaches/Apktool/tree/docs).**

[![CI](https://github.com/iBotPeaches/Apktool/actions/workflows/build.yml/badge.svg)](https://github.com/iBotPeaches/Apktool/actions/workflows/test.yml)
[![Software License](https://img.shields.io/badge/license-Apache%202.0-brightgreen.svg)](https://github.com/iBotPeaches/Apktool/blob/master/LICENSE)
[![Software License](https://img.shields.io/badge/license-Apache%202.0-brightgreen.svg)](https://github.com/iBotPeaches/Apktool/blob/master/LICENSE.md)

It is a tool for reverse engineering 3rd party, closed, binary Android apps. It can decode resources to nearly original form and rebuild them after making some modifications; it makes possible to debug smali code step by step. Also it makes working with app easier because of project-like files structure and automation of some repetitive tasks like building apk, etc.
Apktool is a tool for reverse engineering third-party, closed, binary, Android apps. It can decode resources to nearly original form and rebuild them after making some modifications; it makes it possible to debug smali code step-by-step. It also makes working with apps easier thanks to project-like file structure and automation of some repetitive tasks such as building apk, etc.

It is NOT intended for piracy and other non-legal uses. It could be used for localizing, adding some features or support for custom platforms and other GOOD purposes. Just try to be fair with authors of an app, that you use and probably like.
Apktool is **NOT** intended for piracy and other non-legal uses. It could be used for localizing and adding features, adding support for custom platforms, and other GOOD purposes. Just try to be fair with the authors of an app, that you use and probably like.

#### Support
- [Project Page](https://ibotpeaches.github.io/Apktool/)
Expand Down
97 changes: 57 additions & 40 deletions brut.apktool/apktool-cli/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,25 +1,15 @@
import proguard.gradle.ProGuardTask

val apktoolVersion: String by rootProject.extra

plugins {
alias(libs.plugins.shadow)
application
}

// Buildscript is deprecated, but the alternative approach does not support expanded properties
// https://github.com/gradle/gradle/issues/9830
// So we must hard-code the version here.
buildscript {
dependencies {
// Proguard doesn't support plugin DSL - https://github.com/Guardsquare/proguard/issues/225
classpath(libs.proguard)
}
}
val r8: Configuration by configurations.creating

dependencies {
implementation(libs.commons.cli)
implementation(project(":brut.apktool:apktool-lib"))
r8(libs.r8)
}

application {
Expand All @@ -28,46 +18,73 @@ application {
tasks.run.get().workingDir = file(System.getProperty("user.dir"))
}

tasks.withType<Jar> {
manifest {
attributes["Main-Class"] = "brut.apktool.Main"
}
tasks.withType<AbstractArchiveTask>().configureEach {
isPreserveFileTimestamps = false
isReproducibleFileOrder = true
}

tasks.register<Delete>("cleanOutputDirectory") {
delete(fileTree("build/libs") {
exclude("apktool-cli-sources.jar")
exclude("apktool-cli-javadoc.jar")
exclude("apktool-cli-all.jar")
})
}

tasks.register<ProGuardTask>("proguard") {
val shadowJar = tasks.create("shadowJar", Jar::class) {
dependsOn("build")
dependsOn("cleanOutputDirectory")

group = "build"
description = "Creates a single executable JAR with all dependencies"
manifest.attributes["Main-Class"] = "brut.apktool.Main"
duplicatesStrategy = DuplicatesStrategy.EXCLUDE

val dependencies = configurations
.runtimeClasspath
.get()
.map(::zipTree)

from(dependencies)
with(tasks.jar.get())
}

tasks.register<JavaExec>("proguard") {
dependsOn("shadowJar")
injars(tasks.named("shadowJar").get().outputs.files)

val javaHome = System.getProperty("java.home")
if (JavaVersion.current() <= JavaVersion.VERSION_1_8) {
libraryjars("$javaHome/lib/jce.jar")
libraryjars("$javaHome/lib/rt.jar")
} else {
libraryjars(mapOf("jarfilter" to "!**.jar", "filter" to "!module-info.class"),
{
"$javaHome/jmods/"
}
)

onlyIf {
JavaVersion.current().isJava11Compatible
}

dontobfuscate()
dontoptimize()
val proguardRules = file("proguard-rules.pro")
val originalJar = shadowJar.outputs.files.singleFile

inputs.files(originalJar.toString(), proguardRules)
outputs.file("build/libs/apktool-$apktoolVersion.jar")

classpath(r8)
mainClass.set("com.android.tools.r8.R8")

args = mutableListOf(
"--release",
"--classfile",
"--no-minification",
"--map-diagnostics:UnusedProguardKeepRuleDiagnostic", "info", "none",
"--lib", javaLauncher.get().metadata.installationPath.toString(),
"--output", outputs.files.singleFile.toString(),
"--pg-conf", proguardRules.toString(),
originalJar.toString()
)
}

tasks.withType<org.gradle.api.publish.maven.tasks.PublishToMavenRepository> {
dependsOn(tasks.named("shadowJar"))
}

keep("class brut.apktool.Main { public static void main(java.lang.String[]); }")
keepclassmembers("enum * { public static **[] values(); public static ** valueOf(java.lang.String); }")
dontwarn("com.google.common.base.**")
dontwarn("com.google.common.collect.**")
dontwarn("com.google.common.util.**")
dontwarn("javax.xml.xpath.**")
dontnote("**")
tasks.withType<org.gradle.plugins.signing.Sign> {
dependsOn(tasks.named("shadowJar"))
}

val outPath = "build/libs/apktool-$apktoolVersion.jar"
outjars(outPath)
tasks.withType<org.gradle.api.publish.tasks.GenerateModuleMetadata> {
dependsOn(tasks.named("shadowJar"))
}
11 changes: 11 additions & 0 deletions brut.apktool/apktool-cli/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-keep class brut.apktool.Main {
public static void main(java.lang.String[]);
}
-keepclassmembers enum * {
static **[] values();
static ** valueOf(java.lang.String);
}

# https://github.com/iBotPeaches/Apktool/pull/3670#issuecomment-2296326878
-dontwarn com.google.j2objc.annotations.Weak
-dontwarn com.google.j2objc.annotations.RetainedWith
Loading

0 comments on commit 8f166d5

Please sign in to comment.