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

[Build] Upgrade Gradle to 8.2.1 and AGP to 8.1.0 #1051

Merged
merged 13 commits into from
Jul 28, 2023

Conversation

ParaskP7
Copy link
Contributor

@ParaskP7 ParaskP7 commented Jul 12, 2023

Platform Request: pdnsEh-13V-p2
Project Thread: paaHJt-57Z-p2

This PR upgraded Gradle to 8.2.1 and AGP to 8.0.2.

FYI: The 8.1.1 Gradle upgrades had to happen in 2 parts (19e79dd and f60a051). This is because of the breaking changes that this upgrade introduces, including the AGP upgrade and its associated breaking changes (namespace, build option, etc).


🚫 Blocked By:

  • Android Gradle plugin requires Java 17 to run. You are currently using Java 11.
CI Failure
[2023-07-12T13:08:41Z] FAILURE: Build failed with an exception.
--
  | [2023-07-12T13:08:41Z]
  | [2023-07-12T13:08:41Z] * Where:
  | [2023-07-12T13:08:41Z] Build file '/var/lib/buildkite-agent/builds/ci-android-i-09d7f5ed0f4906143-1/automattic/azteceditor-android/app/build.gradle' line: 2
  | [2023-07-12T13:08:41Z]
  | [2023-07-12T13:08:41Z] * What went wrong:
  | [2023-07-12T13:08:41Z] An exception occurred applying plugin request [id: 'com.android.application', version: '8.0.2']
  | [2023-07-12T13:08:41Z] > Failed to apply plugin 'com.android.internal.application'.
  | [2023-07-12T13:08:41Z]    > Android Gradle plugin requires Java 17 to run. You are currently using Java 11.
  | [2023-07-12T13:08:41Z]       Your current JDK is located in /usr/lib/jvm/java-11-openjdk-11.0.19.0.7-1.amzn2.0.1.x86_64
  | [2023-07-12T13:08:41Z]       You can try some of the following options:
  | [2023-07-12T13:08:41Z]        - changing the IDE settings.
  | [2023-07-12T13:08:41Z]        - changing the JAVA_HOME environment variable.
  | [2023-07-12T13:08:41Z]        - changing `org.gradle.java.home` in `gradle.properties`.

Breaking Change List:

  1. Move package from android manifest to build files
  2. Enable build config build feature for app

AGP Upgrade Assistant List:

  1. Remove ignored configuration properties
  2. Migrate dsl properties from lint options to lint

Lint Resolution List:

  1. Resolve notifications without permission lint warning

Lint Suppression List:

  1. Suppress perm implies unsupported chrome os hw lint warning

Associated clients

You can reference the [Build] Upgrade Gradle to 8.1.1 and AGP to 8.0.2 PRs of the below associated clients for testing/verification purposes:


To test

  1. Verify that all the CI checks are successful.
  2. Test composite builds via the associated clients apps (see above).

Merge instructions

  • Mark PR as Ready for review.
  • Wait for PR to get approved.
    • TODO: Test all the PRs together once done with the reviews (@oguzkocer).
  • Remove [PR] Not Ready for Merge label.
  • In coordination with all the other library and client PRs, merge this PR only when every PR is ready to be merged.

ParaskP7 added 9 commits July 12, 2023 15:20
Release Notes: https://docs.gradle.org/8.1.1/release-notes.html
Command: ./gradlew wrapper --gradle-version=8.1.1
--distribution-type=all

------------------------------------------------------------------------

FYI: You will notice that the associated 'gradle-wrapper.jar', 'gradlew'
and 'gradlew.bat' files are not updated. This is because of the breaking
changes that this upgrade introduces, including the 'AGP' upgrade and
its associated breaking changes (namespace, build option, etc). As such,
this Gradle upgrade command is only half done.

PS: When all the breaking changes are resolved, this Gradle command will
be issued again, which should fully complete this upgrade.
This is an AGP version '8.0' breaking change that requires 'namespace'
in module-level build scripts, see build failure below:

------------------------------------------------------------------------

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Could not create an instance of type
 com.android.build.api.variant.impl.ApplicationVariantImpl.
   > Namespace not specified. Please specify a namespace in the module's
    build.gradle file like so:

     android {
         namespace 'com.example.namespace'
     }

     If the package attribute is specified in the source
      AndroidManifest.xml, it can be migrated automatically to the
      namespace value in the build.gradle file using the AGP Upgrade
      Assistant; please refer to https://developer.android.com/studio/
      build/agp-upgrade-assistant for more information.

------------------------------------------------------------------------

Explanation: "You must set the namespace in the module-level
'build.gradle.kts' file, rather than the manifest file."

For more info see: https://developer.android.com/build/releases/
gradle-plugin#namespace-dsl
This is an AGP version '8.0' breaking change that changes the build
option default values, see build failure below:

------------------------------------------------------------------------

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':stories'.
> Failed to notify project evaluation listener.
   > com.android.builder.errors.EvalIssueException: Build Type 'debug'
    contains custom BuildConfig
    fields, but the feature is disabled.
   > Could not get unknown property 'release' for SoftwareComponent
    container of type org.gradle.api.internal.component
    .DefaultSoftwareComponentContainer.

------------------------------------------------------------------------

> Task :app:compileDebugKotlin FAILED
e: /Users/.../app/src/main/kotlin/org/wordpress/aztec/demo/
 MainActivity.kt: (680, 21): Unresolved reference: BuildConfig

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner
 .GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
   > Compilation error. See log for more details

------------------------------------------------------------------------

Explanation: "Starting with AGP 8.0, the default values for these flags
have changed to improve build performance. AGP 8.0 doesn't generate
'BuildConfig' by default. You need to specify this option using the DSL
in the projects where you need it."

For more info see: https://developer.android.com/build/releases/
gradle-plugin#default-changes
Release Notes: https://docs.gradle.org/8.1.1/release-notes.html
Command: ./gradlew wrapper --gradle-version=8.1.1
--distribution-type=all

------------------------------------------------------------------------

As per the previous 19e79dd commit and
its description, this change is a follow-up upgrade, which fully
completes this Gradle upgrade.
FYI: This was suggested automatically using the AGP upgrade assistant.
FYI: This was suggested automatically using the AGP upgrade assistant.
Warning Message: "When targeting Android 13 or higher, posting a
permission requires holding the 'POST_NOTIFICATIONS' permission
(usage from 'com.bumptech.glide.request.target.NotificationTarget')
When targeting Android 13 and higher, posting permissions requires
holding the runtime permission 'android.permission.POST_NOTIFICATIONS'."
Warning Message: "Permission exists without corresponding hardware
<uses-feature android:name="android.hardware.camera" required="false">
tag"

Explanation: "The <uses-permission> element should not require a
permission that implies an unsupported large screen hardware feature.
Google Play assumes that certain hardware related permissions indicate
that the underlying hardware features are required by default. To fix
the issue, consider declaring the corresponding <uses-feature> element
with required="false" attribute."
Release Notes: https://docs.gradle.org/8.2.1/release-notes.html
Command: ./gradlew wrapper --gradle-version=8.2.1
--distribution-type=all
@ParaskP7 ParaskP7 changed the title [Build] Upgrade Gradle to 8.1.1 and AGP to 8.0.2 [Build] Upgrade Gradle to 8.2.1 and AGP to 8.0.2 Jul 13, 2023
Copy link
Contributor

@oguzkocer oguzkocer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Approving the PR pending testing.

@ParaskP7
Copy link
Contributor Author

Awesome @oguzkocer , thanks for adding JDK17 support to this repo, updating the publish-to-s3 Gradle plugin, then reviewing and tentatively approving the changes, pending some extra testing! 🙇 ❤️ 🚀

FYI: I went ahead, marked this PR as Ready for review and removed the [PR] Not Ready for Merge label. The last thing for us to do is to coordinate the merge wit with all the other library and client PRs, merging this PR only when every other such PR is ready to be merged as well.

@oguzkocer oguzkocer changed the title [Build] Upgrade Gradle to 8.2.1 and AGP to 8.0.2 [Build] Upgrade Gradle to 8.2.1 and AGP to 8.1.0 Jul 27, 2023
@oguzkocer oguzkocer merged commit f29186e into trunk Jul 28, 2023
@oguzkocer oguzkocer deleted the build/upgrade-gradle-to-8.1.1-and-agp-to-8.0.2 branch July 28, 2023 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants