Commit dc8f3c0a authored by Eric Stevenson's avatar Eric Stevenson Committed by Commit Bot

Android: Allow proguard to strip unused native methods.

This CL changes Monochrome APKs to allow proguard to strip out Java
native methods that aren't used.

For APKs that use explicit JNI registration, this isn't possible since
RegisterNatives ends up trying to load classes that are unused and
removed by proguard.

Bug: 688465
Cq-Include-Trybots: luci.chromium.try:ios-simulator-cronet;master.tryserver.chromium.android:android_cronet_tester
Change-Id: I6816bd68ce47e59bfc9f75dace1b34ab3c200222
Reviewed-on: https://chromium-review.googlesource.com/1244605Reviewed-by: default avatarPaul Jensen <pauljensen@chromium.org>
Reviewed-by: default avataragrieve <agrieve@chromium.org>
Commit-Queue: Eric Stevenson <estevenson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#594743}
parent 8ba9303d
......@@ -38,9 +38,6 @@
-keepclasseswithmembers class * {
@org.chromium.base.annotations.UsedByReflection <fields>;
}
-keepclasseswithmembers,includedescriptorclasses class * {
native <methods>;
}
# Remove methods annotated with this if their return value is unused.
-assumenosideeffects class ** {
......
# Copyright 2018 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# -keepclasseswithmembers rather than -keepclasseswithmembernames to avoid
# shrinking of unused native methods. Explicit JNI registration requires even
# unused classes to be present during RegisterNatives().
-keepclasseswithmembers,includedescriptorclasses class * {
native <methods>;
}
# Copyright 2018 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# -keepclasseswithmembernames rather than -keepclasseswithmembers to allow
# shrinking of unused native methods.
-keepclasseswithmembernames,includedescriptorclasses class * {
native <methods>;
}
......@@ -2400,6 +2400,13 @@ if (enable_java_templates) {
if (_enable_multidex) {
proguard_configs += [ "//build/android/multidex.flags" ]
}
if (_use_chromium_linker) {
proguard_configs +=
[ "//base/android/proguard/explicit_jni_registration.flags" ]
} else {
proguard_configs +=
[ "//base/android/proguard/implicit_jni_registration.flags" ]
}
proguard_output_jar_path = _proguard_output_jar_path
}
......
......@@ -471,6 +471,7 @@ action("cronet_combine_proguard_flags") {
script = "//components/cronet/tools/generate_proguard_file.py"
sources = [
"//base/android/proguard/chromium_code.flags",
"//base/android/proguard/explicit_jni_registration.flags",
"//components/cronet/android/cronet_impl_native_proguard.cfg",
]
outputs = [
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment