Skip to content
Snippets Groups Projects
Commit 371e7f75 authored by Remi NGUYEN VAN's avatar Remi NGUYEN VAN
Browse files

Run R8 with the necessary classpath classes

R8 emits "missing class" warnings when optimizing service-connectivity
because service-connectivity combines several already built static_libs
(service-connectivity, service-connectivity-t, service-nearby), but does
not specify any classpath library, which are actually needed for R8.

This causes wrong optimizations, where R8 would sometimes strip out code
that it thinks is unused (because it considers it unreachable due to the
missing class, or it does not know the superclass of a callback and
thinks the overridden methods cannot be called).

Add the necessary classpath libraries to remove the warnings.

Bug: 226127213
Bug: 239990030
Test: m service-connectivity, see no "Missing class" warnings
Change-Id: I1eaa39b70da4b540e3a3e8e798bec1359b5bf533
parent 9c8cda23
No related branches found
No related tags found
No related merge requests found
......@@ -116,6 +116,7 @@ java_sdk_library {
"//packages/modules/Connectivity/Tethering/apex",
// In preparation for future move
"//packages/modules/Connectivity/apex",
"//packages/modules/Connectivity/service", // For R8 only
"//packages/modules/Connectivity/service-t",
"//packages/modules/Nearby/service",
"//frameworks/base",
......
......@@ -225,12 +225,27 @@ java_defaults {
// This library combines system server jars that have access to different bootclasspath jars.
// Lower SDK service jars must not depend on higher SDK jars as that would let them
// transitively depend on the wrong bootclasspath jars. Sources also cannot be added here as
// they would transitively depend on bootclasspath jars that may not be available.
// they would depend on bootclasspath jars that may not be available.
static_libs: [
"service-connectivity-pre-jarjar",
"service-connectivity-tiramisu-pre-jarjar",
"service-nearby-pre-jarjar",
],
// The below libraries are not actually needed to build since no source is compiled
// (only combining prebuilt static_libs), but they are necessary so that R8 has the right
// references to optimize the code. Without these, there will be missing class warnings and
// code may be wrongly optimized.
// R8 runs after jarjar, so the framework-X libraries need to be the post-jarjar artifacts
// (.impl), if they are not just stubs, so that the name of jarjared classes match.
libs: [
"androidx.annotation_annotation",
"framework-annotations-lib",
"framework-connectivity.impl",
"framework-connectivity-t.impl",
"framework-tethering.stubs.module_lib",
"framework-wifi.stubs.module_lib",
"libprotobuf-java-nano",
],
jarjar_rules: ":connectivity-jarjar-rules",
apex_available: [
"com.android.tethering",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment