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

Add support for AGP 8.4 #120

Merged
merged 5 commits into from
Jun 19, 2024
Merged

Add support for AGP 8.4 #120

merged 5 commits into from
Jun 19, 2024

Conversation

emersion
Copy link
Contributor

Fixes the following errors with AGP 8.4:

A problem occurred configuring project ':webcrypto'.
> [CXX1110] Platform version 16 is unsupported by this NDK. Please change minSdk to at least 21 to avoid undefined behavior. To suppress this error, add android.ndk.suppressMinSdkVersionError=21 to the project's gradle.properties or set android.experimentalProperties["android.ndk.suppressMinSdkVersionError"]=21 in the Gradle build file.

and

Execution failed for task ':webcrypto:processReleaseManifest'.
> A failure occurred while executing com.android.build.gradle.tasks.ProcessLibraryManifest$ProcessLibWorkAction
   > Incorrect package="com.example.webcrypto" found in source AndroidManifest.xml: /home/simon/src/webcrypto.dart/android/src/main/AndroidManifest.xml.
     Setting the namespace via the package attribute in the source AndroidManifest.xml is no longer supported.
     Recommendation: remove package="com.example.webcrypto" from the source AndroidManifest.xml: /home/simon/src/webcrypto.dart/android/src/main/AndroidManifest.xml.

Fixes the following error with AGP 8.4:

    A problem occurred configuring project ':webcrypto'.
    > [CXX1110] Platform version 16 is unsupported by this NDK. Please change minSdk to at least 21 to avoid undefined behavior. To suppress this error, add android.ndk.suppressMinSdkVersionError=21 to the project's gradle.properties or set android.experimentalProperties["android.ndk.suppressMinSdkVersionError"]=21 in the Gradle build file.
Fixes the following error with AGP 8.4:

    Execution failed for task ':webcrypto:processReleaseManifest'.
    > A failure occurred while executing com.android.build.gradle.tasks.ProcessLibraryManifest$ProcessLibWorkAction
       > Incorrect package="com.example.webcrypto" found in source AndroidManifest.xml: /home/simon/src/webcrypto.dart/android/src/main/AndroidManifest.xml.
         Setting the namespace via the package attribute in the source AndroidManifest.xml is no longer supported.
         Recommendation: remove package="com.example.webcrypto" from the source AndroidManifest.xml: /home/simon/src/webcrypto.dart/android/src/main/AndroidManifest.xml.
@jonasfj
Copy link
Member

jonasfj commented May 24, 2024

Do I understand it correctly that this will drop support for Android 4.x, which is more than 12 years old at this point.

That might be acceptable, I'm guessing :D

@jonasfj
Copy link
Member

jonasfj commented May 24, 2024

Hmm, I'm guessing we should also look at:
https://docs.flutter.dev/release/breaking-changes/flutter-gradle-plugin-apply

I'll file it separately, as #124

Copy link
Member

@jonasfj jonasfj left a comment

Choose a reason for hiding this comment

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

Is there some kind of testing we should do to be more confident this is correct?

I'd love to have it covered in CI.

// Conditional for compatibility with AGP <4.2.
if (project.android.hasProperty("namespace")) {
namespace 'dev.google.webcrypto'
}
namespace 'dev.google.webcrypto'
Copy link
Member

Choose a reason for hiding this comment

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

Dumb question, but do we not need this anymore?

Will minSdkVersion 21 make AGP < 4.2 irrelevant?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

AGP 8.4 rejects AndroidManifest.xml files with a package attribute. If we only set the namespace for AGP ≥ 4.2, then on AGP < 4.2 we won't define any namespace at all and the build will fail anyways.

I think it's reasonable to ask library users to upgrade AGP ≥ 4.2 when upgrading webcrypto.dart.

@HamdaanAliQuatil
Copy link
Collaborator

Fixes the following errors with AGP 8.4:

A problem occurred configuring project ':webcrypto'.
> [CXX1110] Platform version 16 is unsupported by this NDK. Please change minSdk to at least 21 to avoid undefined behavior. To suppress this error, add android.ndk.suppressMinSdkVersionError=21 to the project's gradle.properties or set android.experimentalProperties["android.ndk.suppressMinSdkVersionError"]=21 in the Gradle build file.

and

Execution failed for task ':webcrypto:processReleaseManifest'.
> A failure occurred while executing com.android.build.gradle.tasks.ProcessLibraryManifest$ProcessLibWorkAction
   > Incorrect package="com.example.webcrypto" found in source AndroidManifest.xml: /home/simon/src/webcrypto.dart/android/src/main/AndroidManifest.xml.
     Setting the namespace via the package attribute in the source AndroidManifest.xml is no longer supported.
     Recommendation: remove package="com.example.webcrypto" from the source AndroidManifest.xml: /home/simon/src/webcrypto.dart/android/src/main/AndroidManifest.xml.

@emersion can you please let me know how to reproduce this error

These changes are made automatically by the flutter tool when
running "flutter build apk".
This is done via the Android Studio AGP upgrade assistant.
@emersion
Copy link
Contributor Author

Do I understand it correctly that this will drop support for Android 4.x, which is more than 12 years old at this point.

Correct. Note that the latest version of Flutter requires Android ≥ 5.x, so this just aligns the plugin requirements with Flutter's.

Hmm, I'm guessing we should also look at:
https://docs.flutter.dev/release/breaking-changes/flutter-gradle-plugin-apply

Yes, that would be nice to fix as well. But it's orthogonal.

Is there some kind of testing we should do to be more confident this is correct?

I'd love to have it covered in CI.

I've pushed a commit to upgrade the example to AGP 8.4. The failures reported in the first two commits can be reproduced there.

Java 11 is not new enough for AGP 8.4.
@jonasfj jonasfj merged commit 4c2e760 into google:master Jun 19, 2024
6 checks passed
@emersion emersion deleted the agp-8.4 branch June 19, 2024 17:43
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.

3 participants