microsoft / appcenter-sdk-android

Development repository for the App Center SDK for Android
Other
274 stars 135 forks source link

Update Android Gradle plugin to latest version and declare namespace #1693

Closed fabiendem closed 1 year ago

fabiendem commented 1 year ago

Is your feature request related to a problem? Please describe.

The Android Gradle plugin used by the libraries is getting outdated.

Describe the solution you'd like

This is a request to update the Android Gradle plugin to the latest version at https://developer.android.com/build/releases/gradle-plugin#8-0-0

It will require the declaration of a namespace in the Gradle file, instead of in the AndroidManifest file, see https://developer.android.com/build/releases/gradle-plugin#namespace-dsl

Describe alternatives you've considered N/A

Additional context

Our project will soon require the Android Gradle plugin v8.

MikhailSuendukov commented 1 year ago

Hi @fabiendem , thank you for reaching out to us, I will discuss this with the team and come back with news soon

MikhailSuendukov commented 1 year ago

Hi @fabiendem. I wanted to update you on our recent testing with the SDK. We've rigorously tested our SDK in applications using Android Gradle Plugin (AGP) version 8.x and found no issues. The SDK operated as expected, and AppCenter services started successfully without any problems. Given these results, it's clear that it's not necessary to build the SDK with AGP 8.0 specifically, even though it has introduced changes to the declaration of namespaces in the Gradle file. Our SDK, which is currently built with AGP 4.2.2, continues to be fully compatible. Based on these findings, there's no requirement for us to update our AGP at this time. If you don't have any further concerns, I'll proceed to close this issue. If you have any other questions or if there's anything else you'd like us to investigate, please feel free to let us know. You're welcome to reopen this issue at any time.

fabiendem commented 1 year ago

Hi @MikhailSuendukov, Thanks for the details. Could you please read below and reconsider?

The Android Gradle plugin 8 introduced this breaking change, which requires Android modules to declare a namespace: https://developer.android.com/build/releases/gradle-plugin#namespace-dsl You must set a namespace in the AppCenter library for apps which use AGP 8+:

Projects which are built with AGP 8+ will require modules to have the namespace set.

You may not need to bump the AGP version in your library, but the Android AppCenter SDK should at least declare a namespace to be compatible with apps built using AGP 8+. Example in this repo (uses AGP 4.2.2 internally): https://github.com/zoontek/react-native-permissions/pull/782/files

If you want to be retro-compatible with older AGP version, you may be able to use this snippet: https://github.com/react-native-community/discussions-and-proposals/issues/671#issuecomment-1598892444

When you say:

We've rigorously tested our SDK in applications using Android Gradle Plugin (AGP) version 8.x and found no issues. The SDK operated as expected, and AppCenter services started successfully without any problems.

🤔 In this case why not upgrading? But I understand it may not be urgent

Thank you!

MikhailSuendukov commented 1 year ago

Thank you very much for your information, in this case, could you please clarify for me what consequences can lead to the fact that we will not have a namespace in our build file when connecting our current SDK to an application using AGP v8, as far as I understand, the use of this property is advisory? Because I tested it on the AGP v8 sample application and there were no problems when starting the services. Thank you in advance.

fabiendem commented 1 year ago

Thank you very much for your information, in this case, could you please clarify for me what consequences can lead to the fact that we will not have a namespace in our build file when connecting our current SDK to an application using AGP v8, as far as I understand, the use of this property is advisory? Because I tested it on the AGP v8 sample application and there were no problems when starting the services. Thank you in advance.

It is announced as a breaking change: https://developer.android.com/build/releases/gradle-plugin#namespace-dsl But maybe Google's recommendation is incorrect. You should at least start to see warnings when you build your app with dependencies which are not declaring the namespace.

Breaking change: namespace required in module-level build script You must set the namespace in the module-level build.gradle.kts file, rather than the manifest file. You can start using the namespace DSL property starting with AGP 7.3.

This whole thing has been triggered by this post: https://github.com/react-native-community/discussions-and-proposals/issues/671#issue-1761364743

Even though we work on a React Native app, we're using AppCenter Android at the Android level. I wouldn't be surprised if native Android project will ask you for the same.

MikhailSuendukov commented 1 year ago

Hmm. I am unable to reproduce either the error or the warning using our SDK with the application with AGP version v8.0.0. Could you please help me with repro?