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

v.0.1.10 Gradle 7.0.0 Android Studio Artic Fox. #69

Open
wants to merge 22 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions
name: Build

on:
push:
branches:
- '**'
tags-ignore:
- '**'
pull_request:
workflow_dispatch:
# https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/

defaults:
run:
shell: bash

jobs:

build:
runs-on: ubuntu-latest
steps:
- name: Git Checkout
uses: actions/checkout@v2 #https://github.com/actions/checkout

- name: Set up JDK 11
uses: actions/setup-java@v2 # https://github.com/actions/setup-java
with:
distribution: 'zulu'
java-version: 11

- name: "Cache: Local Maven Repository"
uses: actions/cache@v2
with:
path: |
~/.m2/repository
!~/.m2/com/bytedance
key: ${{ runner.os }}-mvnrepo-${{ hashFiles('**/build.gradle') }}
restore-keys: |
${{ runner.os }}-mvnrepo-

- name: Build with Gradle
run: |
set -eux

bash ./gradlew publishToMavenLocal

- name: Deploy Maven Repo
run: |
set -eux

if git checkout --orphan mvn-repo; then
git rm -rf .
git clean -fxd
fi

# https://github.community/t/github-actions-bot-email-address/17204
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"

mkdir -p com/bytedance/android
cp -rf ~/.m2/repository/com/bytedance/android/* com/bytedance/android

git add --all
git commit -am "deploy to maven repo"
git push origin mvn-repo --force
38 changes: 27 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# AabResGuard
# AabResGuard - Artic Fox Edition
<h1 align="center">
<img src="wiki/images/logo.png" height="220" width="460"/>
<p align="center" style="font-size: 0.3em">The tool of obfuscated aab resources</p>
</h1>

[ ![Download](https://api.bintray.com/packages/yeoh/maven/aabresguard-core/images/download.svg) ](https://bintray.com/yeoh/maven/aabresguard-plugin/)
[![License](https://img.shields.io/badge/license-Apache2.0-brightgreen)](LICENSE)
[![Bundletool](https://img.shields.io/badge/Dependency-Bundletool/0.10.0-blue)](https://github.com/google/bundletool)
[Download V.0.1.10](https://github.com/martinloren/mvn-repo/raw/main/AabResGuard_0.1.10.zip)

[![License](https://img.shields.io/badge/license-Apache2.0-brightgreen)](LICENSE) [![Bundletool](https://img.shields.io/badge/Dependency-Bundletool/0.10.0-blue)](https://github.com/google/bundletool)

**[English](README.md)** | [简体中文](wiki/zh-cn/README.md)

Expand All @@ -23,8 +23,8 @@
- **???:** Looking ahead, there will be more feature support, welcome to submit PR & issue.

## [Data of size savings](wiki/en/DATA.md)
**AabResGuard** is a resource obfuscation tool powered by the douyin Android team. It has been launched at the end of July 2018 in several overseas products, such as **Tiktok, Vigo**, etc.
There is no feedback on related resource issues.
**AabResGuard** is a resource obfuscation tool powered by the douyin Android team. It has been launched at the end of July 2018 in several overseas products, such as **Tiktok, Vigo**, etc.
There is no feedback on related resource issues.
For more data details, please go to **[Data of size savings](wiki/en/DATA.md)**.

## Quick start
Expand All @@ -37,11 +37,12 @@ Configured in `build.gradle(root project)`
buildscript {
repositories {
mavenCentral()
jcenter()
mavenLocal()
google()
maven { url 'https://raw.githubusercontent.com/martinloren/AabResGuard/mvn-repo' }
}
dependencies {
classpath "com.bytedance.android:aabresguard-plugin:0.1.0"
classpath "com.bytedance.android:aabresguard-plugin:0.1.10"
}
}
```
Expand All @@ -50,10 +51,24 @@ Configured in `build.gradle(application)`
```gradle
apply plugin: "com.bytedance.android.aabResGuard"
aabResGuard {
mappingFile = file("mapping.txt").toPath() // Mapping file used for incremental obfuscation
//mappingFile = file("mapping.txt").toPath() // Mapping file used for incremental obfuscation
whiteList = [ // White list rules
"*.R.raw.*",
"*.R.drawable.icon"
"*.R.drawable.icon",
// Google-services & Firebase
"*.R.string.google_app_id",
"*.R.string.gcm_defaultSenderId",
"*.R.string.default_web_client_id",
"*.R.string.ga_trackingId",
"*.R.string.firebase_database_url",
"*.R.string.google_api_key",
"*.R.string.google_crash_reporting_api_key",
"*.R.string.default_web_client_id",
"*.R.string.gcm_defaultSenderId",
"*.R.string.google_app_id",
"*.R.string.google_crash_reporting_api_key",
"*.R.string.google_storage_bucket",
"*.R.string.project_id"
]
obfuscatedBundleFileName = "duplicated-app.aab" // Obfuscated file name, must end with '.aab'
mergeDuplicatedRes = true // Whether to allow the merge of duplicate resources
Expand All @@ -62,7 +77,7 @@ aabResGuard {
"*/arm64-v8a/*",
"META-INF/*"
]

enableFilterStrings = false // switch of filter strings
unusedStringPath = file("unused.txt").toPath() // strings will be filtered in this file
languageWhiteList = ["en", "zh"] // keep en,en-xx,zh,zh-xx etc. remove others.
Expand Down Expand Up @@ -104,6 +119,7 @@ Read the details to learn how to participate in the improvement **AabResGuard**.
* [Zilai Jiang](https://github.com/Zzzia)
* [Zhiqian Yang](https://github.com/yangzhiqian)
* [Xiaoshuang Bai (Designer)](https://www.behance.net/shawnpai)
* [Martinloren](https://github.com/martinloren)

## Thanks
* [AndResGuard](https://github.com/shwenzhang/AndResGuard/)
Expand Down
6 changes: 2 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ buildscript {
apply from: rootProject.file("gradle/config.gradle")
repositories {
google()
jcenter()
if ("true".equalsIgnoreCase(System.getProperty('useLocalMaven', "false"))) {
println "use local repo"
println "Using local repo."
mavenLocal()
} else {
println "use remove repo"
println "Using remote repo."
maven { url findProperty("RELEASE_REPOSITORY_URL") }
maven { url findProperty("SNAPSHOT_REPOSITORY_URL") }
}
Expand All @@ -33,7 +32,6 @@ buildscript {
allprojects {
repositories {
google()
jcenter()
if ("true".equalsIgnoreCase(System.getProperty('useLocalMaven', "false"))) {
mavenLocal()
} else {
Expand Down
15 changes: 7 additions & 8 deletions core/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
buildscript {
repositories {
jcenter()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "com.google.protobuf:protobuf-gradle-plugin:0.8.8"
classpath "com.google.protobuf:protobuf-gradle-plugin:0.8.13"
}
}

Expand All @@ -30,24 +29,24 @@ dependencies {

compileOnly "com.android.tools.build:aapt2-proto:0.4.0"
compileOnly gradleApi()
// compile deps.gradle.agp
// compile deps.gradle.agp

implementation "com.android.support:support-annotations:24.2.0"
shadow 'commons-io:commons-io:2.6'
shadow 'commons-io:commons-io:2.7'
shadow 'commons-codec:commons-codec:1.5'
shadow "com.google.guava:guava:27.0.1-jre"
shadow "com.google.guava:guava:30.0-jre"

annotationProcessor "com.google.auto.value:auto-value:1.5.2"
implementation "com.google.auto.value:auto-value:1.5.2"
shadow group: 'org.dom4j', name: 'dom4j', version: '2.1.0'
shadow group: 'org.dom4j', name: 'dom4j', version: '2.1.1'
shadow deps.bundletool

testImplementation deps.gradle.agp
testImplementation "com.android.tools.build:aapt2-proto:0.4.0"
testImplementation group: 'org.dom4j', name: 'dom4j', version: '2.1.0'
testImplementation group: 'org.dom4j', name: 'dom4j', version: '2.1.1'
testImplementation "junit:junit:4.12"
testImplementation "org.junit.jupiter:junit-jupiter-api:5.2.0"
testImplementation "com.google.guava:guava:27.0.1-jre"
testImplementation "com.google.guava:guava:30.0-jre"
testImplementation "org.mockito:mockito-core:2.18.3"
testImplementation "com.google.truth.extensions:truth-java8-extension:0.45"
testImplementation "com.google.truth.extensions:truth-proto-extension:0.45"
Expand Down
1 change: 1 addition & 0 deletions core/gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public AppBundle analyze() throws IOException {
TimeClock timeClock = new TimeClock();
ZipFile bundleZip = new ZipFile(bundlePath.toFile());
AppBundle appBundle = AppBundle.buildFromZip(bundleZip);
System.out.println(String.format("analyze bundle file done, const %s", timeClock.getCoast()));
System.out.println(String.format("analyze bundle file done, const %s", timeClock.getCost()));
return appBundle;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ public void execute() throws IOException {
AppBundleSerializer appBundleSerializer = new AppBundleSerializer();
appBundleSerializer.writeToDisk(appBundle, output);

System.out.println(String.format("package bundle done, coast: %s", timeClock.getCoast()));
System.out.println(String.format("package bundle done, cost: %s", timeClock.getCost()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import java.io.IOException;
import java.nio.file.Path;
import java.util.logging.Logger;

/**
* Created by YangJing on 2019/10/11 .
Expand Down Expand Up @@ -41,6 +40,6 @@ public void execute() throws IOException, InterruptedException {
bundleSignature.keyPassword
);
new JarSigner().sign(bundleFile.toFile(), signature);
System.out.println(String.format("[sign] sign done, coast: %s", timeClock.getCoast()));
System.out.println(String.format("[sign] sign done, cost: %s", timeClock.getCost()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,11 @@ storeFile, getStorePassword().get(), getKeyAlias().get(), getKeyPassword().get()
long rawSize = FileOperation.getFileSizes(getBundlePath().toFile());
long filteredSize = FileOperation.getFileSizes(getOutputPath().toFile());
System.out.println(String.format(
"duplicate resources done, coast %s\n" +
"duplicate resources done, cost %s\n" +
"-----------------------------------------\n" +
"Reduce bundle file size: %s, %s -> %s\n" +
"-----------------------------------------",
timeClock.getCoast(),
timeClock.getCost(),
getNetFileSizeDescription(rawSize - filteredSize),
getNetFileSizeDescription(rawSize),
getNetFileSizeDescription(filteredSize)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,11 @@ storeFile, getStorePassword().get(), getKeyAlias().get(), getKeyPassword().get()
long rawSize = FileOperation.getFileSizes(getBundlePath().toFile());
long filteredSize = FileOperation.getFileSizes(getOutputPath().toFile());
System.out.println(String.format(
"filter bundle files done, coast %s\n" +
"filter bundle files done, cost %s\n" +
"-----------------------------------------\n" +
"Reduce bundle file size: %s, %s -> %s\n" +
"-----------------------------------------",
timeClock.getCoast(),
timeClock.getCost(),
getNetFileSizeDescription(rawSize - filteredSize),
getNetFileSizeDescription(rawSize),
getNetFileSizeDescription(filteredSize)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import java.util.Set;
import java.util.logging.Logger;

import static com.android.tools.build.bundletool.model.utils.files.FilePreconditions.checkFileDoesNotExist;
import static com.android.tools.build.bundletool.model.utils.files.FilePreconditions.checkFileExistsAndReadable;
import static com.bytedance.android.aabresguard.utils.FileOperation.getNetFileSizeDescription;
import static com.bytedance.android.aabresguard.utils.exception.CommandExceptionPreconditions.checkFlagPresent;
Expand Down Expand Up @@ -234,11 +233,11 @@ storeFile, getStorePassword().get(), getKeyAlias().get(), getKeyPassword().get()
long rawSize = FileOperation.getFileSizes(getBundlePath().toFile());
long filteredSize = FileOperation.getFileSizes(getOutputPath().toFile());
System.out.println(String.format(
"obfuscate resources done, coast %s\n" +
"obfuscate resources done, cost %s\n" +
"-----------------------------------------\n" +
"Reduce bundle file size: %s, %s -> %s\n" +
"-----------------------------------------",
timeClock.getCoast(),
timeClock.getCost(),
getNetFileSizeDescription(rawSize - filteredSize),
getNetFileSizeDescription(rawSize),
getNetFileSizeDescription(filteredSize)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,11 @@ storeFile, getStorePassword().get(), getKeyAlias().get(), getKeyPassword().get()
long rawSize = FileOperation.getFileSizes(getBundlePath().toFile());
long filteredSize = FileOperation.getFileSizes(getOutputPath().toFile());
System.out.println(String.format(
"filter bundle strings done, coast %s\n" +
"filter bundle strings done, cost %s\n" +
"-----------------------------------------\n" +
"Reduce bundle string size: %s, %s -> %s\n" +
"-----------------------------------------",
timeClock.getCoast(),
timeClock.getCost(),
getNetFileSizeDescription(rawSize - filteredSize),
getNetFileSizeDescription(rawSize),
getNetFileSizeDescription(filteredSize)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ public AppBundle filter() throws IOException {
.setModules(ImmutableMap.copyOf(bundleModules))
.build();
System.out.println(String.format(
"filter bundle files done, coast %s" +
"filter bundle files done, cost %s\n" +
"-----------------------------------------\n" +
"Reduce file count: %s\n" +
"Reduce file size: %s\n" +
"-----------------------------------------",
timeClock.getCoast(),
"-----------------------------------------\n",
timeClock.getCost(),
filterTotalCount,
getNetFileSizeDescription(filterTotalSize)
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ public AppBundle filter() throws IOException {
.build();

System.out.println(String.format(
"filtering strings done, coast %s\n",
timeClock.getCoast()
"filtering strings done, cost %s\n",
timeClock.getCost()
));

return appBundle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
Expand Down Expand Up @@ -72,12 +74,12 @@ public AppBundle merge() throws IOException {
);

System.out.println(String.format(
"merge duplicated resources done, coast %s\n" +
"merge duplicated resources done, cost %s\n" +
"-----------------------------------------\n" +
"Reduce file count: %s\n" +
"Reduce file size: %s\n" +
"-----------------------------------------",
timeClock.getCoast(),
timeClock.getCost(),
mergeDuplicatedTotalCount,
getNetFileSizeDescription(mergeDuplicatedTotalSize)
));
Expand All @@ -89,7 +91,11 @@ public AppBundle merge() throws IOException {
*/
private BundleModule mergeBundleModule(BundleModule bundleModule) throws IOException {
File logFile = new File(outputLogLocationDir.toFile(), bundleModule.getName().getName() + SUFFIX_FILE_DUPLICATED_LOGGER);
checkFileDoesNotExist(logFile.toPath());
//checkFileDoesNotExist(logFile.toPath());
if (Files.exists(logFile.toPath(), new LinkOption[0])) {
logger.warning("Log file: "+logFile.toPath()+" already existing! Deleting...");
Files.delete(logFile.toPath());
}

Resources.ResourceTable table = bundleModule.getResourceTable().orElse(Resources.ResourceTable.getDefaultInstance());
if (table.getPackageList().isEmpty() || bundleModule.getEntries().isEmpty()) {
Expand Down
Loading