-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Task 'generateJsonSchema2Pojo' fails after upgrading to Android Gradle Plugin 8.2.2 / Gradle 8.2 #1591
Comments
Hi, @masranber , |
In case it helps anyone, it has helped me to move the plugin to a new module of the application, of type "Java or Kotlin module" |
@oscar-tu-lotero I haven't found a solution yet. The plugin is already in a separate module from the main application. Would you mind posting your project-level build.gradle and module-level build.gradle to see if I can replicate your fix? |
Out of curiosity: does explicitly setting/providing |
Issue
The plugin appears to be incompatible with newer versions the Android Gradle Plugin (8.0.0+ from what I can tell).
I'm using version 1.2.1 of the jsonschema2pojo plugin in an Android library. I'm currently in the process of upgrading the project from Android Gradle Plugin version 7.2.0 to 8.2.2, which also requires Gradle version >= 8.2.
After upgrading AGP and Gradle, building the project fails due to an exception in the
generateJsonSchema2Pojo
Gradle task:Here's the source code snippet where the exception is being thrown:
jsonschema2pojo/jsonschema2pojo-gradle-plugin/src/main/groovy/org/jsonschema2pojo/gradle/GenerateJsonSchemaAndroidTask.groovy
Lines 63 to 73 in 72050f6
Steps to reproduce
Potential solution
In newer versions of the Android Gradle Plugin
extension
is no longer a member of the classcom.android.build.gradle.LibraryPlugin
. Thecom.android.build.gradle.LibraryExtension
instance can instead be accessed via theandroid
property oforg.gradle.api.Project
that gets added by the AGP.Therefore, the following line:
should be changed to:
In my limited testing (basically just running the code directly in my build.gradle script) this appears to work in the latest AGP version as well as the version I was previously using (7.2.0).
I believe this issue also applies to Android apps (
com.android.application
projects). Since theandroid
property returns the correct project extension instance for the current project type (com.android.application
orcom.android.library
) the above code should also work forcom.android.application
projects.The
setTargetVersion
method would then look like:I'm not sure if this issue appears elsewhere in the source code.
The text was updated successfully, but these errors were encountered: