Skip to content

Commit

Permalink
Migrate to AGP 4.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
topjohnwu committed Oct 17, 2020
1 parent 468796c commit a079966
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 24 deletions.
6 changes: 0 additions & 6 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,6 @@
void onResponse(org.json.JSONObject);
}

# Fragments
# TODO: Remove when AGP 4.1 release
# https://issuetracker.google.com/issues/142601969
-keep,allowobfuscation class * extends androidx.fragment.app.Fragment
-keepnames class androidx.navigation.fragment.NavHostFragment

# Strip Timber verbose and debug logging
-assumenosideeffects class timber.log.Timber.Tree {
public void v(**);
Expand Down
8 changes: 5 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,15 @@ fun Task.applyOptimize() = doLast {
val aapt2 = Paths.get(project.android.sdkDirectory.path,
"build-tools", project.android.buildToolsVersion, "aapt2")
val zip = Paths.get(project.buildDir.path, "intermediates",
"processed_res", "release", "out", "resources-release.ap_")
"shrunk_processed_res", "release", "resources-release-stripped.ap_")
val optimized = File("${zip}.opt")
val cmd = exec {
commandLine(aapt2, "optimize", "--collapse-resource-names",
"--shorten-resource-paths", "-o", optimized, zip)
isIgnoreExitValue = true
}
if (cmd.exitValue == 0) {
zip.toFile().delete()
optimized.renameTo(zip.toFile())
}
}
Expand All @@ -63,6 +64,7 @@ subprojects {
android.apply {
compileSdkVersion(30)
buildToolsVersion = "30.0.2"
ndkPath = "${System.getenv("ANDROID_HOME")}/ndk/magisk"

defaultConfig {
if (minSdkVersion == null)
Expand All @@ -87,8 +89,8 @@ subprojects {
}

tasks.whenTaskAdded {
if (name == "processReleaseResources") {
finalizedBy(tasks.create("optimizeReleaseResources").applyOptimize())
if (name == "shrinkReleaseRes") {
finalizedBy(tasks.create("optimizeReleaseRes").applyOptimize())
}
}

Expand Down
17 changes: 4 additions & 13 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ def vprint(str):
support_targets = ['magisk', 'magiskinit', 'magiskboot', 'magiskpolicy', 'resetprop', 'busybox', 'test']
default_targets = ['magisk', 'magiskinit', 'magiskboot', 'busybox']

ndk_ver = '21c'
ndk_ver_full = '21.2.6472646'
ndk_ver = '21d'
ndk_ver_full = '21.3.6528147'

ndk_root = op.join(os.environ['ANDROID_HOME'], 'ndk')
ndk_path = op.join(ndk_root, 'magisk')
Expand Down Expand Up @@ -285,8 +285,8 @@ def dump_bin_headers():
def build_binary(args):
# Verify NDK install
props = parse_props(op.join(ndk_path, 'source.properties'))
if 'Pkg.Revision.orig' not in props or props['Pkg.Revision.orig'] != ndk_ver_full:
error('Incorrect NDK. Please setup NDK with "build.py ndk"')
if props['Pkg.Revision'] != ndk_ver_full:
error('Incorrect NDK. Please install/upgrade NDK with "build.py ndk"')

if args.target:
args.target = set(args.target) & set(support_targets)
Expand Down Expand Up @@ -550,15 +550,6 @@ def setup_ndk(args):
for path in copy_tree(src_dir, lib_dir):
vprint(f'Replaced {path}')

# Rewrite source.properties
src_prop = op.join(ndk_path, 'source.properties')
props = parse_props(src_prop)
props['Pkg.Revision.orig'] = props['Pkg.Revision']
props['Pkg.Revision'] = '99.99.99'
with open(src_prop, 'w') as p:
for key, val in props.items():
print(f'{key} = {val}', file=p)


def build_all(args):
vars(args)['target'] = []
Expand Down
2 changes: 0 additions & 2 deletions native/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ plugins {

android {

ndkVersion = "99.99.99"

externalNativeBuild {
ndkBuild {
path("jni/Android.mk")
Expand Down

0 comments on commit a079966

Please sign in to comment.