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

Jetifier fails on bcprov-jdk15on-1.68.jar / Robolectric 4.6-alpha-2 #6521

Closed
ogolberg opened this issue May 31, 2021 · 15 comments
Closed

Jetifier fails on bcprov-jdk15on-1.68.jar / Robolectric 4.6-alpha-2 #6521

ogolberg opened this issue May 31, 2021 · 15 comments

Comments

@ogolberg
Copy link
Contributor

ogolberg commented May 31, 2021

Description

When building an Android project with a testImplementation dependency on Robolectric 4.6-alpha-2, the build fails with

Failed to transform bcprov-jdk15on-1.68.jar (org.bouncycastle:bcprov-jdk15on:1.68) to match attributes {artifactType=processed-jar, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.
      > Execution failed for JetifyTransform: /home/runner/.gradle/caches/modules-2/files-2.1/org.bouncycastle/bcprov-jdk15on/1.68/46a080368d38b428d237a59458f9bc915222894d/bcprov-jdk15on-1.68.jar.
         > Failed to transform '/home/runner/.gradle/caches/modules-2/files-2.1/org.bouncycastle/bcprov-jdk15on/1.68/46a080368d38b428d237a59458f9bc915222894d/bcprov-jdk15on-1.68.jar' using Jetifier. Reason: IllegalArgumentException, message: Unsupported class file major version 59. (Run with --stacktrace for more details.)

Note that Bouncycastle was bumped to 1.68 in alpha-2. The error is likely due to Bouncycastle jars being multi-release and Bouncycastle 1.68 including classes targeting Java 15 (and probably Jetifier being unaware of multi-release jars).

As a workaround, It's possible to manually exclude bcprov-jdk15on from jetifying, but I think this still counts as a regression.

Steps to Reproduce

Set up a boilerplate Android project with Robolectric 4.6-alpha-2 and try to build it using JDK 11 or lower.

Robolectric & Android Version

Robolectic 4.6-alpha-2, AGP 7.0-beta3, Java 11 used in the project below

Link to a public git repo demonstrating the problem:

See https://github.com/ogolberg/robolectric-integration-tests/runs/2711507099?check_suite_focus=true

@ogolberg ogolberg changed the title Jetifier fails on bcprov-jdk15on-1.68.jar / Robolectric 3.6.1-alpha-2 Jetifier fails on bcprov-jdk15on-1.68.jar / Robolectric 3.6.0-alpha-2 May 31, 2021
@ogolberg ogolberg changed the title Jetifier fails on bcprov-jdk15on-1.68.jar / Robolectric 3.6.0-alpha-2 Jetifier fails on bcprov-jdk15on-1.68.jar / Robolectric 4.6-alpha-2 May 31, 2021
@utzcoz
Copy link
Member

utzcoz commented May 31, 2021

I will check whether lower version but with CVE fixed commit has the same problem.

@hoisie
Copy link
Contributor

hoisie commented Jun 1, 2021

This is a pretty bad bug in jetifier I believe.

I think to fix this issue you can add to your gradle.properties:

android.jetifier.blacklist=bcprov

or perhaps

android.enableJetifier=false

@hoisie
Copy link
Contributor

hoisie commented Jun 1, 2021

More context:

bcgit/bc-java#762
https://issuetracker.google.com/issues/172784894?pli=1
https://issuetracker.google.com/issues/159151549

@nikitph
Copy link

nikitph commented Jun 4, 2021

I kinda fixed it by upgrading the gradle plugin to latest. may be it will work for u

@ogolberg
Copy link
Contributor Author

ogolberg commented Jun 4, 2021

ok I think we can call it a bug in jetifier and close

@ogolberg ogolberg closed this as completed Jun 4, 2021
@hoisie
Copy link
Contributor

hoisie commented Jun 4, 2021

There are also revived efforts to bump the ASM version in Jetifier (https://issuetracker.google.com/issues/159151549).

mikehardy added a commit to ankidroid/Anki-Android that referenced this issue Jul 5, 2021
- jetifier still needed because of old material dialogs version, pending kotlin migration
- jetifier cannot handle JDK15 bytecode because of some other internal dependency with bcprov
- bcprov does not need jetifier processing though, so skipping it is okay

robolectric/robolectric#6521 (comment)
mikehardy added a commit to ankidroid/Anki-Android that referenced this issue Jul 5, 2021
* Bump lint_version from 27.2.1 to 27.2.2

Bumps `lint_version` from 27.2.1 to 27.2.2.

Updates `lint-api` from 27.2.1 to 27.2.2

Updates `lint` from 27.2.1 to 27.2.2

Updates `lint-tests` from 27.2.1 to 27.2.2

---
updated-dependencies:
- dependency-name: com.android.tools.lint:lint-api
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: com.android.tools.lint:lint
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: com.android.tools.lint:lint-tests
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump robolectric from 4.5.1 to 4.6.1

Bumps [robolectric](https://github.com/robolectric/robolectric) from 4.5.1 to 4.6.1.
- [Release notes](https://github.com/robolectric/robolectric/releases)
- [Commits](robolectric/robolectric@robolectric-4.5.1...robolectric-4.6.1)

---
updated-dependencies:
- dependency-name: org.robolectric:robolectric
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Ignore bcprov during jetifier runs

- jetifier still needed because of old material dialogs version, pending kotlin migration
- jetifier cannot handle JDK15 bytecode because of some other internal dependency with bcprov
- bcprov does not need jetifier processing though, so skipping it is okay

robolectric/robolectric#6521 (comment)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Mike Hardy <github@mikehardy.net>
kim-vde pushed a commit to google/ExoPlayer that referenced this issue Jul 9, 2021
The tests now pass without @DoNotInstrument

I had to tweak the jetification settings due to a bug in the jetifier
shipped with the Android Gradle Plugin. More details:
robolectric/robolectric#6521 (comment)

PiperOrigin-RevId: 382757006
mikehardy added a commit to ankidroid/Anki-Android that referenced this issue Jul 13, 2021
* Bump lint_version from 27.2.1 to 27.2.2

Bumps `lint_version` from 27.2.1 to 27.2.2.

Updates `lint-api` from 27.2.1 to 27.2.2

Updates `lint` from 27.2.1 to 27.2.2

Updates `lint-tests` from 27.2.1 to 27.2.2

---
updated-dependencies:
- dependency-name: com.android.tools.lint:lint-api
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: com.android.tools.lint:lint
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: com.android.tools.lint:lint-tests
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump robolectric from 4.5.1 to 4.6.1

Bumps [robolectric](https://github.com/robolectric/robolectric) from 4.5.1 to 4.6.1.
- [Release notes](https://github.com/robolectric/robolectric/releases)
- [Commits](robolectric/robolectric@robolectric-4.5.1...robolectric-4.6.1)

---
updated-dependencies:
- dependency-name: org.robolectric:robolectric
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Ignore bcprov during jetifier runs

- jetifier still needed because of old material dialogs version, pending kotlin migration
- jetifier cannot handle JDK15 bytecode because of some other internal dependency with bcprov
- bcprov does not need jetifier processing though, so skipping it is okay

robolectric/robolectric#6521 (comment)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Mike Hardy <github@mikehardy.net>
mikehardy added a commit to ankidroid/Anki-Android that referenced this issue Jul 16, 2021
* Bump lint_version from 27.2.1 to 27.2.2

Bumps `lint_version` from 27.2.1 to 27.2.2.

Updates `lint-api` from 27.2.1 to 27.2.2

Updates `lint` from 27.2.1 to 27.2.2

Updates `lint-tests` from 27.2.1 to 27.2.2

---
updated-dependencies:
- dependency-name: com.android.tools.lint:lint-api
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: com.android.tools.lint:lint
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: com.android.tools.lint:lint-tests
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump robolectric from 4.5.1 to 4.6.1 (#9208)

* Bump lint_version from 27.2.1 to 27.2.2

Bumps `lint_version` from 27.2.1 to 27.2.2.

Updates `lint-api` from 27.2.1 to 27.2.2

Updates `lint` from 27.2.1 to 27.2.2

Updates `lint-tests` from 27.2.1 to 27.2.2

---
updated-dependencies:
- dependency-name: com.android.tools.lint:lint-api
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: com.android.tools.lint:lint
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: com.android.tools.lint:lint-tests
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump robolectric from 4.5.1 to 4.6.1

Bumps [robolectric](https://github.com/robolectric/robolectric) from 4.5.1 to 4.6.1.
- [Release notes](https://github.com/robolectric/robolectric/releases)
- [Commits](robolectric/robolectric@robolectric-4.5.1...robolectric-4.6.1)

---
updated-dependencies:
- dependency-name: org.robolectric:robolectric
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Ignore bcprov during jetifier runs

- jetifier still needed because of old material dialogs version, pending kotlin migration
- jetifier cannot handle JDK15 bytecode because of some other internal dependency with bcprov
- bcprov does not need jetifier processing though, so skipping it is okay

robolectric/robolectric#6521 (comment)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Mike Hardy <github@mikehardy.net>

* build(deps): bump jsoup from 1.13.1 to 1.14.1

Bumps [jsoup](https://github.com/jhy/jsoup) from 1.13.1 to 1.14.1.
- [Release notes](https://github.com/jhy/jsoup/releases)
- [Changelog](https://github.com/jhy/jsoup/blob/master/CHANGES)
- [Commits](jhy/jsoup@jsoup-1.13.1...jsoup-1.14.1)

---
updated-dependencies:
- dependency-name: org.jsoup:jsoup
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* build(deps): bump kotlin_version from 1.5.20 to 1.5.21

Bumps `kotlin_version` from 1.5.20 to 1.5.21.

Updates `kotlin-gradle-plugin` from 1.5.20 to 1.5.21
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/commits)

Updates `kotlin-stdlib` from 1.5.20 to 1.5.21
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/commits)

Updates `kotlin-stdlib-jdk7` from 1.5.20 to 1.5.21
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/commits)

---
updated-dependencies:
- dependency-name: org.jetbrains.kotlin:kotlin-gradle-plugin
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: org.jetbrains.kotlin:kotlin-stdlib
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: org.jetbrains.kotlin:kotlin-stdlib-jdk7
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@IgorGanapolsky
Copy link

This error is still occurring in robolectric 4.6.1. What is the fix?

@hoisie
Copy link
Contributor

hoisie commented Aug 19, 2021

@IgorGanapolsky #6521 (comment)

Add
android.jetifier.blacklist=bcprov or
android.enableJetifier=false to gradle.properties. or upgrade to 7.1.x of AGP.

@daniel-waiguru
Copy link

I kinda fixed it by upgrading the gradle plugin to latest. may be it will work for u

This worked for me. Thanks

@cioccarellia
Copy link

Blacklisting it worked: android.jetifier.blacklist=bcprov

@utzcoz
Copy link
Member

utzcoz commented Oct 18, 2021

If you are using AGP 7.0+, you can use android.jetifier.ignorelist=bcprov to replace android.jetifier.blacklist=bcprov, because the old one is removed from AGP 7.0+.

@hoisie
Copy link
Contributor

hoisie commented Oct 18, 2021

I believe that jetifier is basically deprecated now, so I would recommend android.enableJetifier=false, unless you absolutely need it.

@utzcoz
Copy link
Member

utzcoz commented Oct 18, 2021

I believe that jetifier is basically deprecated now, so I would recommend android.enableJetifier=false, unless you absolutely need it.

Agree. Looks like AGP 7.0+ can process bcprov with jetifier enabled from PR KlubJagiellonski/pola-android#189.

Infilong added a commit to Infilong/Location-Reminder that referenced this issue Dec 7, 2021
tendaimusakanye added a commit to tendaimusakanye/TrackBud that referenced this issue Jan 17, 2022
Refactored some variables for improved readability.Updated gradle to fix issue with Roboelectric and Jetifier. See link below
robolectric/robolectric#6521
@JagadishaIncture
Copy link

android.enableJetifier=false

worked

@raoadnanjafar
Copy link

i have face same issue. first you open your build.properties and then add this "android.jetifier.blacklist=bcprov-jdk15on" "android.enableJetifier=true"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants