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

Hilt plugin crash with android gradle plugin 7 beta04 #2700

Closed
mtomczynski opened this issue Jun 16, 2021 · 8 comments · Fixed by #2719
Closed

Hilt plugin crash with android gradle plugin 7 beta04 #2700

mtomczynski opened this issue Jun 16, 2021 · 8 comments · Fixed by #2719

Comments

@mtomczynski
Copy link

mtomczynski commented Jun 16, 2021

Versions:

Android Studio Arctic Fox Beta 4
Android tools gradle plugin 7.0.0-beta04
kotlin gradle plugin 1.5.10
dagger 2.37

Gradle build fails when applying hilt plugin to the module:

plugins {
    ...
    id("dagger.hilt.android.plugin")
    ...
}

Partial stacktrace

com/android/build/api/extension/AndroidComponentsExtension$DefaultImpls

* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Exception is:
java.lang.NoClassDefFoundError: com/android/build/api/extension/AndroidComponentsExtension$DefaultImpls
	at dagger.hilt.android.plugin.HiltGradlePlugin.configureBytecodeTransformASM(HiltGradlePlugin.kt:258)
	at dagger.hilt.android.plugin.HiltGradlePlugin.configureHilt(HiltGradlePlugin.kt:89)
	at dagger.hilt.android.plugin.HiltGradlePlugin.access$configureHilt(HiltGradlePlugin.kt:59)
	at dagger.hilt.android.plugin.HiltGradlePlugin$apply$1.execute(HiltGradlePlugin.kt:66)
	at dagger.hilt.android.plugin.HiltGradlePlugin$apply$1.execute(HiltGradlePlugin.kt:59)
	at org.gradle.configuration.internal.DefaultUserCodeApplicationContext$CurrentApplication$1.execute(DefaultUserCodeApplicationContext.java:112)
	at org.gradle.api.internal.DefaultCollectionCallbackActionDecorator$BuildOperationEmittingAction$1.run(DefaultCollectionCallbackActionDecorator.java:95)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:75)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:68)
	at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:153)
	at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)
	at org.gradle.internal.operations.DefaultBuildOperationRunner.run(DefaultBuildOperationRunner.java:56)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.lambda$run$1(DefaultBuildOperationExecutor.java:74)

EDIT
If anyone needs a quick fix without downgrading AS it compiles without errors on alpha using Android Studio Bumblebee Canary 2 and AGP 7.1.0-alpha02.

@danysantiago
Copy link
Member

The Android Gradle Plugin team is aware of the issue and a fix for this will be available in AGP 7 beta05.

@florianmski
Copy link

For people like me who need to downgrade, here is the link for the previous mac version (beta03) https://dl.google.com/edgedl/android/studio/ide-zips/2020.3.1.18/android-studio-2020.3.1.18-mac.zip

@ubuntudroid
Copy link

@danysantiago is there an issue that we can follow to get updates on the progress?

@n1k3c
Copy link

n1k3c commented Jun 17, 2021

I think this will fix the issue

@roshanrajaratnam
Copy link

@danysantiago is there timeline on the fix?

@roshanrajaratnam
Copy link

Answer by @krzdabrowski on #2634 worked for me.

@danysantiago
Copy link
Member

Sorry all for the issue, AGP is expected to have a release sometime next week for 7.0-beta, if all goes well. Meanwhile using 7.1-alpha02 should work.

And just for context, this is related to Hilt's bytecode transform which uses AGP's new ASM pipeline starting in 4.2 which is way more efficient and correct than the 'previous' version. The APIs for the ASM transform are planned to become stable soon in 7.0 so hopefully, in the near future this should be less of an issue.

copybara-service bot pushed a commit that referenced this issue Jun 23, 2021
This change adds compatibility classes to support registering an ASM transform in AGP 4.2, 7.0 and 7.1. For 4.2 reflection has to be used for all invocations of the newer variant API since their package in 4.2 is different and its not possible to reference the classes when compiling against a newer version. For 7.0 an onwards, the API are stable and can be referenced directly.

Fixes #2700

RELNOTES=Fix an incompatibility in the Hilt Gradle Plugin with AGP 7.0-beta04 and 7.1-alpha02, be aware that with this fix the HiltGradlePlugin will not work with other older alpha/beta versions of AGP 7.0 and 7.1 other than the ones mentioned in these notes.
PiperOrigin-RevId: 380743576
abaker added a commit to tasks/tasks that referenced this issue Jun 25, 2021
@LachlanMcKee
Copy link

LachlanMcKee commented Jul 2, 2021

AGP 7.0.0-beta05 has been released and seems to have fixed this :)
PR for proof: LachlanMcKee/Hilt-Compose-Navigation-Factory#22

copybara-service bot pushed a commit that referenced this issue Jul 9, 2021
This change adds compatibility classes to support registering an ASM transform in AGP 4.2, 7.0 and 7.1. For 4.2 reflection has to be used for all invocations of the newer variant API since their package in 4.2 is different and its not possible to reference the classes when compiling against a newer version. For 7.0 an onwards, the API are stable and can be referenced directly.

Fixes #2700

RELNOTES=Fix an incompatibility in the Hilt Gradle Plugin with AGP 7.0-beta04 and 7.1-alpha03, be aware that with this fix the HiltGradlePlugin will not work with other older alpha/beta versions of AGP 7.0 and 7.1 other than the ones mentioned in these notes.
PiperOrigin-RevId: 380743576
copybara-service bot pushed a commit that referenced this issue Jul 9, 2021
This change adds compatibility classes to support registering an ASM transform in AGP 4.2, 7.0 and 7.1. For 4.2 reflection has to be used for all invocations of the newer variant API since their package in 4.2 is different and its not possible to reference the classes when compiling against a newer version. For 7.0 an onwards, the API are stable and can be referenced directly.

Fixes #2700

RELNOTES=Fix an incompatibility in the Hilt Gradle Plugin with AGP 7.0-beta04 and 7.1-alpha03, be aware that with this fix the HiltGradlePlugin will not work with other older alpha/beta versions of AGP 7.0 and 7.1 other than the ones mentioned in these notes.
PiperOrigin-RevId: 380743576
dptsolutions added a commit to dptsolutions/podcast-app that referenced this issue Aug 2, 2021
Using AGP 7.1.0-alpha02 to workaround google/dagger#2700. Arctic Fox Beta 05 should solve the problem and we can go back to the less bleeding edge versions.

Also updates

* Kotlin to 1.5.10
* Coroutines to 1.5.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants