Open tdounnyy opened 3 years ago
Any updates on this? @jin can you help direct this to the right person?
Hi, the rules do not currently support R8. We'll be adding support, unfortunately I can't give a concrete timeline on that yet.
Any updates? Found a fatal proguard error in androidx.fragment:fragment:1.3.6
Error: Unknown option '-if' in line 16 of file 'bazel-out/android-armeabi-v7a-fastbuild/bin/external/maven/_aar/androidx_fragment_fragment/proguard.txt',
included from argument number 22
The file contents are this:
# The default FragmentFactory creates Fragment instances using reflection
-if public class ** extends androidx.fragment.app.Fragment
-keepclasseswithmembers,allowobfuscation public class <1> {
public <init>();
}
We have an internal implementation that enables R8 flag guarded behind a configuration flag (--experimental_enable_r8). The change rewires the action graph when --experimental_enable_r8 is passed so that proguarding and dexing is all handled by R8 in a single action (from deploy jar to dex classes). All changes are in AndroidBinary (with exception of the flag which lives in AndroidConfiguration). The change also requires an additional binary (proguard_compat) passed via --proguard_top which knows how to invoke R8 correctly with the proguard specs. ATM we have only implemented native multidex (Android version L+ support).
We can contribute our implementation and the proguard_compat binary (thinking it could live in src/tools/android/java/com/google/devtools/build/android/r8/BUILD.tools). Does this sound reasonable or is there some ongoing work in the starlark rules that duplicates? This would also help the R8 team to contribute directly to bazel. @timpeut @ahumesky
https://github.com/bazelbuild/bazel/pull/14741 adds basic support for calling the R8.
Note that the implementation assumes the presence of a shim binary that translates the proguard command line to the proper r8 calls which is not in this pr but amounts to something like:
R8Command.Builder builder = R8Command.builder() .addProguardConfiguration(printConfig, Origin.root()) .addLibraryFiles(libraryJars) .addProgramFiles(input) .setMode(CompilationMode.RELEASE) .setOutput(output, OutputMode.DexIndexed) .setMinApiLevel(NATIVE_MULTIDEX_MIN_SDK);
@mauriciogg can we create a gist that contains an example of the shim binary setup?
FYI @sgjesse here is the patch we've been using for R8 support in Bazel.
FYI @ahumesky, @timpeut and @lizkammer well.
@mauriciogg can we create a gist that contains an example of the shim binary setup?
https://gist.github.com/mauriciogg/6e7217f03a19a40979f23ca1e5eff297
There's some related discussion about Bazel support for r8 in https://github.com/bazelbuild/bazel/pull/14966#issuecomment-1087797565
Didn't find any direct info to this. If support, is there any guideline? If not, is it on schedule?
I found a Bazel compile fail with Proguard 5.3.3, it would be nice if someone would share some suggestions. https://stackoverflow.com/questions/65182300/bazel-build-android-demo-fail-with-proguard Thank you