smartdevicelink / sdl_java_suite

SmartDeviceLink libraries for Android, Java SE, and Java EE
BSD 3-Clause "New" or "Revised" License
187 stars 171 forks source link

The Android project should be updated from AGP 7.4.2 #1883

Open hanis0 opened 9 months ago

hanis0 commented 9 months ago

Description

Warnings

AGP update recommended

There is this new Android Gradle Plugin (AGP) warning present since the recent upgrade to support Android SDK 34 (#1856, #1880).

We recommend using a newer Android Gradle plugin to use compileSdk = 34

This Android Gradle plugin (7.4.2) was tested up to compileSdk = 33

This warning can be suppressed by adding android.suppressUnsupportedCompileSdk=34 to this project's gradle.properties

The build will continue, but you are strongly encouraged to update your project to use a newer Android Gradle Plugin that has been tested with compileSdk = 34

Screenshot 2024-01-27 at 7 02 12

Deprecated attribute in AndroidManifest.xml

And there's also one older yet related warning thrown by the manifest processing task.

package="com.smartdevicelink" found in source AndroidManifest.xml:…/sdl_java_suite/android/sdl_android/src/main/AndroidManifest.xml. Setting the namespace via a source AndroidManifest.xml's package attribute is deprecated. Please instead set the namespace (or testNamespace) in the module's build.gradle file, as described here: https://developer.android.com/studio/build/configure-app-module#set-namespace This migration can be done automatically using the AGP Upgrade Assistant, please refer to https://developer.android.com/studio/build/agp-upgrade-assistant for more information.

Screenshot 2024-01-27 at 7 28 23

Impact

Users of the sdl_android module who link the module source code are affected by the deprecated attribute in AndroidManifest.xml warning and because of that they cannot upgrade their project's AGP to 8+ versions without any custom modifications to the sdl_android module's source code.

hanis0 commented 9 months ago

Attaching SDL_Issue_1883.patch GIT Patch that I believe to resolve the AGP update recommended issue which also includes a resolution of the Deprecated attribute in AndroidManifest.xml issue.

Most of the changes were do by the AGP Upgrade Assistant tool. However it would fail to load the project after the upgrade with this exception:

org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':sdl_android'.
    at org.gradle.configuration.project.LifecycleProjectEvaluator.wrapException(LifecycleProjectEvaluator.java:84)
…
    at org.gradle.internal.concurrent.AbstractManagedExecutor$1.run(AbstractManagedExecutor.java:47)
Caused by: org.gradle.api.UnknownDomainObjectException: SoftwareComponent with name 'release' not found.
    at org.gradle.api.internal.DefaultNamedDomainObjectCollection.createNotFoundException(DefaultNamedDomainObjectCollection.java:504)
    at org.gradle.api.internal.DefaultNamedDomainObjectCollection.getByName(DefaultNamedDomainObjectCollection.java:333)
    at com.vanniktech.maven.publish.MavenPublishConfigurer.configureAndroidArtifacts(MavenPublishConfigurer.kt:152)
    at com.vanniktech.maven.publish.MavenPublishPlugin.configurePublishing(MavenPublishPlugin.kt:87)
    at com.vanniktech.maven.publish.MavenPublishPlugin.access$configurePublishing(MavenPublishPlugin.kt:13)
    at com.vanniktech.maven.publish.MavenPublishPlugin$apply$1.execute(MavenPublishPlugin.kt:43)
    at com.vanniktech.maven.publish.MavenPublishPlugin$apply$1.execute(MavenPublishPlugin.kt:13)
…

Update of the com.vanniktech:gradle-maven-publish-plugin:0.13.0 dependency to the most recent com.vanniktech:gradle-maven-publish-plugin:0.27.0 seems to fix the exception and the Android project loads fine.

There are some failing tests but all of those had been failing for me also before the AGP update.

Screenshot 2024-01-29 at 11 03 46