Skip to content

Add support for AGP 9#10

Merged
fire-light42 merged 6 commits intorecloudstream:masterfrom
Luna712:agp9-support
Apr 10, 2026
Merged

Add support for AGP 9#10
fire-light42 merged 6 commits intorecloudstream:masterfrom
Luna712:agp9-support

Conversation

@Luna712
Copy link
Copy Markdown
Contributor

@Luna712 Luna712 commented Nov 25, 2025

This adds a convenience compat class that supports backwards compatibility as well as support for LibraryExtension, which will he required with AGP9.

Upgrading to AGP 9 will also require extension developers to replace BaseExtension in the Project.android declaration with LibraryExtension, and also replace compileSdkVersion with compileSdk outside of defaultConfig, as well as move targetSdk to a new lint block, and remove apply(plugin = "kotlin-android") since AGP 9 has built-in Kotlin, that is no longer supported.

This should have no affecf for those that don't upgrade to AGP 9, or those you don't decide to use LibraryExtension in AGP 8 which is also supported.

This adds a convenience compat class that supports backwards compatibility as well as support for LibraryExtension, which will he required with AGP9.

Upgrading to AGP 9 will also require extension developers to replace BaseExtension in the `Project.android` declaration with LibraryExtension, and also replace `compileSdkVersion` with `compileSdk` outside of `defaultConfig`, as well as move `targetSdk` to a new lint block, and remove `apply(plugin = "kotlin-android")` since AGP 9 has built-in Kotlin, that is no longer supported.

This should have no affecf for those that don't upgrade to AGP 9, or those you don't decide to use LibraryExtension in AGP 8 which is also supported.
@Luna712
Copy link
Copy Markdown
Contributor Author

Luna712 commented Nov 25, 2025

Note: this also depends on #8 since AGP 9 requires Gradle 9

@Luna712
Copy link
Copy Markdown
Contributor Author

Luna712 commented Nov 25, 2025

Also kinda depends on #9 as it was built on top of that one. So no guarantee it works without that one.

@Luna712
Copy link
Copy Markdown
Contributor Author

Luna712 commented Apr 10, 2026

@fire-light42 should default minSdk be changes to 23 to be in line with the app by the way? I am not sure if it should or not here.

@fire-light42
Copy link
Copy Markdown
Contributor

fire-light42 commented Apr 10, 2026

I would say remaining on minSdk 21 is good as long as it does not hinder us in any obvious way (dependencies or workarounds).

The last people still using old CloudStream versions on old TVs might as well get working plugin updates (ignoring breaking code changes).

@Luna712
Copy link
Copy Markdown
Contributor Author

Luna712 commented Apr 10, 2026

Good point yeah. We can keep.21 for now but eventually we will probably have to change to 23 but we can delay as long as possible here also.

@Luna712 Luna712 mentioned this pull request Apr 10, 2026
Comment thread src/main/kotlin/com/lagradost/cloudstream3/gradle/tasks/Tasks.kt Outdated
@Luna712 Luna712 requested a review from fire-light42 April 10, 2026 19:25
@fire-light42
Copy link
Copy Markdown
Contributor

fire-light42 commented Apr 10, 2026

When compiling our extensions with this gradle and:

fun Project.android(configuration: LibraryExtension.() -> Unit) = extensions.getByName<LibraryExtension>("android")
* What went wrong:
A problem occurred configuring project ':DailymotionProvider'.
> compileSdkVersion is not specified. Please add it to build.gradle

Am I missing something?
Perhaps I need to be on gradle 9 too?

@Luna712
Copy link
Copy Markdown
Contributor Author

Luna712 commented Apr 10, 2026

Remove compileSdkVersion(...) and add compileSdk = 36 outside of the defaultConfig block in just the android block.

@Luna712
Copy link
Copy Markdown
Contributor Author

Luna712 commented Apr 10, 2026

Example: Luna712/Luna712-CloudStream-Extensions#13 (although that PR doesnt build properly due to latest changes not being on jitpack but the code changes should work)

@fire-light42
Copy link
Copy Markdown
Contributor

fire-light42 commented Apr 10, 2026

With AGP 9 I am required to use Gradle 9.3.1 and I get this error:

Element 'android' of type 'com.android.build.gradle.internal.dsl.LibraryExtensionImpl$AgpDecorated_Decorated' from container 'org.gradle.internal.extensibility.DefaultExtensionContainer@46daced' cannot be cast to 'com.android.build.gradle.LibraryExtension'.

@Luna712
Copy link
Copy Markdown
Contributor Author

Luna712 commented Apr 10, 2026

With AGP 9 I am required to use Gradle 9.3.1 and I get this error:

Element 'android' of type 'com.android.build.gradle.internal.dsl.LibraryExtensionImpl$AgpDecorated_Decorated' from container 'org.gradle.internal.extensibility.DefaultExtensionContainer@46daced' cannot be cast to 'com.android.build.gradle.LibraryExtension'.

Make sure import is com.android.build.api.dsl.LibraryExtension version. My above example now resolves and builds properly also.

@fire-light42
Copy link
Copy Markdown
Contributor

Make sure import is com.android.build.api.dsl.LibraryExtension version.

That works!

@Luna712
Copy link
Copy Markdown
Contributor Author

Luna712 commented Apr 10, 2026

Thank you very much for reviewing these PRs @fire-light42!

@fire-light42 fire-light42 merged commit bd75acd into recloudstream:master Apr 10, 2026
1 check passed
@Luna712 Luna712 deleted the agp9-support branch April 10, 2026 20:04
@fire-light42
Copy link
Copy Markdown
Contributor

Thank you for the contributions!

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

Successfully merging this pull request may close these issues.

2 participants