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

proguard does not work with android-24 and above #3777

Closed
aj-michael opened this issue Sep 20, 2017 · 8 comments
Closed

proguard does not work with android-24 and above #3777

aj-michael opened this issue Sep 20, 2017 · 8 comments
Assignees
Labels
P1 I'll work on this now. (Assignee required)

Comments

@aj-michael
Copy link
Contributor

Starting with android-24, the android.jar contains class files with version 52.0. when an android_binary has the proguard_specs attribute, we end up passing android.jar to proguard which chokes because the versions of proguard included in the android sdk do not have support for java 8.

$ bazel build //examples/android/java/bazel:hello_world --android_sdk=@androidsdk//:sdk-24
INFO: Found 1 target...
ERROR: /usr/local/google/home/ajmichael/bazel/bazel2/examples/android/java/bazel/BUILD:12:1: Trimming binary with Proguard failed (Exit 1).
ProGuard, version 4.7
Reading program jar [/usr/local/google/home/ajmichael/.cache/bazel/_bazel_ajmichael/35e62ee2c576f0884e321f960b1f1655/execroot/io_bazel/bazel-out/local-fastbuild/bin/examples/android/java/bazel/hello_world_deploy.jar]
Reading library jar [/usr/local/google/home/ajmichael/sdk/platforms/android-24/android.jar]
Error: Can't read [/usr/local/google/home/ajmichael/sdk/platforms/android-24/android.jar] (Can't process class [java/text/CollationElementIterator.class] (Unsupported class version number [52.0] (maximum 51.0, Java 1.7)))
Target //examples/android/java/bazel:hello_world failed to build

$ bazel build //examples/android/java/bazel:hello_world --android_sdk=@androidsdk//:sdk-23
INFO: Found 1 target...
INFO: From Trimming binary with Proguard:
ProGuard, version 4.7
Reading program jar [/usr/local/google/home/ajmichael/.cache/bazel/_bazel_ajmichael/35e62ee2c576f0884e321f960b1f1655/execroot/io_bazel/bazel-out/local-fastbuild/bin/examples/android/java/bazel/hello_world_deploy.jar]
Reading library jar [/usr/local/google/home/ajmichael/sdk/platforms/android-23/android.jar]
Preparing output jar [/usr/local/google/home/ajmichael/.cache/bazel/_bazel_ajmichael/35e62ee2c576f0884e321f960b1f1655/bazel-sandbox/5578460277401154143/execroot/io_bazel/bazel-out/local-fastbuild/bin/examples/android/java/bazel/hello_world_proguard.jar]
  Copying resources from program jar [/usr/local/google/home/ajmichael/.cache/bazel/_bazel_ajmichael/35e62ee2c576f0884e321f960b1f1655/execroot/io_bazel/bazel-out/local-fastbuild/bin/examples/android/java/bazel/hello_world_deploy.jar]
Target //examples/android/java/bazel:hello_world up-to-date:
  bazel-bin/examples/android/java/bazel/hello_world_proguard.jar
  bazel-bin/examples/android/java/bazel/hello_world_proguard.seeds
  bazel-bin/examples/android/java/bazel/hello_world_proguard.usage
  bazel-bin/examples/android/java/bazel/hello_world_proguard.config
  bazel-bin/examples/android/java/bazel/hello_world_deploy.jar
  bazel-bin/examples/android/java/bazel/hello_world_unsigned.apk
  bazel-bin/examples/android/java/bazel/hello_world.apk
INFO: Elapsed time: 2.046s, Critical Path: 1.66s
@aj-michael aj-michael added breakage category: rules > android P1 I'll work on this now. (Assignee required) labels Sep 20, 2017
@aj-michael
Copy link
Contributor Author

It appears that the proguard in the Android SDK is 4.7, while java8 support was not added until proguard 5.0.

It seems gradle does not use proguard from the SDK, instead it gets a newer version elsewhere.

@aj-michael
Copy link
Contributor Author

Our choices are:

  1. Desugar the android.jar
  2. Bundle a newer proguard with Bazel (or possibly require that the user provides it via maven_jar or something)

@ahumesky , do you have a preference?

@aj-michael aj-michael self-assigned this Sep 21, 2017
@aj-michael
Copy link
Contributor Author

On second thought #1 will not work, because if there are static interface methods in the android.jar, there will be a mismatch between what the methods present when proguarding and the methods present on the device.

@aj-michael
Copy link
Contributor Author

Bundling proguard.jar would add about 800k to the Bazel binary size

@ahumesky
Copy link
Contributor

Ideally we would just get an updated proguard in the SDK, but in the meantime we can just bundle it. If the SDK gets an updated version then we can unbundle it and switch to that one.

@aj-michael
Copy link
Contributor Author

Updating proguard in the Android SDK is in the public android issue tracker: https://issuetracker.google.com/issues/37047494

@damienmg damienmg removed the breakage label Sep 22, 2017
@damienmg
Copy link
Contributor

[breakage label is for regression observed on ci to help sheriff triage new failure]

@aj-michael
Copy link
Contributor Author

Ah ok, I’ll keep that in mind. Unfortunately we don’t have integration test coverage for proguard I’m bazel. Otherwise this would have been observed on ci

bazel-io pushed a commit that referenced this issue Oct 4, 2017
See #3777

The Android SDK provides a very old proguard and will be removing it
soon, so we need to bundle our own.

Change-Id: I054c54130bef1befc8591598768184fe23f76161
RELNOTES: None
buildbreaker pushed a commit to envoyproxy/envoy-mobile that referenced this issue Jun 18, 2020
Fixing android's api to 29 since it seems like api 30 has some bazel proguard issues which are similar to: bazelbuild/bazel#3777

For an explanation of how to fill out the fields, please see the relevant section
in [PULL_REQUESTS.md](https://github.com/envoyproxy/envoy/blob/master/PULL_REQUESTS.md)

Description: android: fixate api_level to be 29
Risk Level: low
Testing: ci
Docs Changes: n/a
Release Notes: n/a
[Optional Fixes #Issue]
[Optional Deprecated:]
jpsim pushed a commit to envoyproxy/envoy that referenced this issue Nov 28, 2022
Fixing android's api to 29 since it seems like api 30 has some bazel proguard issues which are similar to: bazelbuild/bazel#3777

For an explanation of how to fill out the fields, please see the relevant section
in [PULL_REQUESTS.md](https://github.com/envoyproxy/envoy/blob/master/PULL_REQUESTS.md)

Description: android: fixate api_level to be 29
Risk Level: low
Testing: ci
Docs Changes: n/a
Release Notes: n/a
[Optional Fixes #Issue]
[Optional Deprecated:]

Signed-off-by: JP Simard <jp@jpsim.com>
jpsim pushed a commit to envoyproxy/envoy that referenced this issue Nov 29, 2022
Fixing android's api to 29 since it seems like api 30 has some bazel proguard issues which are similar to: bazelbuild/bazel#3777

For an explanation of how to fill out the fields, please see the relevant section
in [PULL_REQUESTS.md](https://github.com/envoyproxy/envoy/blob/master/PULL_REQUESTS.md)

Description: android: fixate api_level to be 29
Risk Level: low
Testing: ci
Docs Changes: n/a
Release Notes: n/a
[Optional Fixes #Issue]
[Optional Deprecated:]

Signed-off-by: JP Simard <jp@jpsim.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 I'll work on this now. (Assignee required)
Projects
None yet
Development

No branches or pull requests

3 participants