Skip to content

Update AGP to 8.11.0#22043

Merged
oguzkocer merged 38 commits into
trunkfrom
update-agp-to-8.11.0
Jul 28, 2025
Merged

Update AGP to 8.11.0#22043
oguzkocer merged 38 commits into
trunkfrom
update-agp-to-8.11.0

Conversation

@oguzkocer

@oguzkocer oguzkocer commented Jul 22, 2025

Copy link
Copy Markdown
Contributor

Summary

Updates Android Gradle Plugin from previous version to 8.11.0, addresses 99 new lint warnings, and fixes test failures introduced by dependency updates.

Changes Made

Lint Configuration Updates

  • Added temporary warning for Aligned16KB errors - These will be addressed once all dependencies support 16KB page size alignment
  • Added ignore rule for UseRequiresApi in generated Hilt files
  • Suppressed UseKtx warning in ResolverUtility - KTX transaction extension doesn't provide sufficient control for existing boolean return API contract

UseKtx Modernization

  • Converted Uri.parse() to String.toUri() KTX extension across multiple files
  • Added null safety handling for nullable URI parameters in EditPostActivity and GifMediaDataSource
  • Updated UriUtilsWrapper to use non-nullable String parameter with proper null checks at call sites

Test Fixes

  • Fixed AztecImageLoaderTest - Added proper Context and Resources mocks to prevent NullPointerException

Riskiest Changes ⚠️

Null Safety Behavior Changes

The most significant risk comes from null safety improvements that change method signatures and behavior:

UriUtilsWrapper Parameter Change

  • File: WordPress/src/main/java/org/wordpress/android/util/UriUtilsWrapper.kt
  • Change: parse(uriString: String?)parse(uriString: String)
  • Impact: Method no longer accepts null parameters
  • Mitigation: Added null checks in GifMediaDataSource.kt using mapNotNull to filter invalid MediaItems

GifMediaDataSource Null Handling

  • File: WordPress/src/main/java/org/wordpress/android/ui/mediapicker/loader/GifMediaDataSource.kt
  • Change: toMediaItem() now returns MediaItem? and checks for null URLs
  • Impact: Invalid GIFs with missing URLs are now filtered out instead of causing crashes
  • Risk: Potentially fewer GIFs displayed if backend data is inconsistent

EditPostActivity Pattern Matching

  • File: WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.kt
  • Change: Added ?: continue for null regex group results
  • Impact: Null regex matches are skipped instead of processed
  • Risk: Content with malformed patterns might be handled differently

@dangermattic

dangermattic commented Jul 22, 2025

Copy link
Copy Markdown
Collaborator
2 Warnings
⚠️ View files have been modified, but no screenshot or video is included in the pull request. Consider adding some for clarity.
⚠️ This PR is larger than 300 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.

Generated by 🚫 Danger

@wpmobilebot

wpmobilebot commented Jul 22, 2025

Copy link
Copy Markdown
Contributor

Project dependencies changes

list
! Upgraded Dependencies
androidx.databinding:viewbinding:8.11.0, (changed from 8.7.3)
tree
-+--- androidx.databinding:viewbinding:8.7.3
++--- androidx.databinding:viewbinding:8.11.0
 \--- project :libs:image-editor
-     \--- androidx.databinding:viewbinding:8.7.3 (*)
+     \--- androidx.databinding:viewbinding:8.11.0 (*)

Build environment changes

list
+ New Dependencies
io.grpc:grpc-inprocess:1.69.1
io.grpc:grpc-util:1.69.1

- Removed Dependencies
com.android.tools.utp:android-test-plugin-host-retention-proto:31.7.3

! Upgraded Dependencies
androidx.databinding:databinding-common:8.11.0, (changed from 8.7.3)
androidx.databinding:databinding-compiler-common:8.11.0, (changed from 8.7.3)
com.android.application:com.android.application.gradle.plugin:8.11.0, (changed from 8.7.3)
com.android.databinding:baseLibrary:8.11.0, (changed from 8.7.3)
com.android.library:com.android.library.gradle.plugin:8.11.0, (changed from 8.7.3)
com.android.tools.analytics-library:crash:31.11.0, (changed from 31.7.3)
com.android.tools.analytics-library:protos:31.11.0, (changed from 31.7.3)
com.android.tools.analytics-library:shared:31.11.0, (changed from 31.7.3)
com.android.tools.analytics-library:tracker:31.11.0, (changed from 31.7.3)
com.android.tools.build:aapt2-proto:8.11.0-12782657, (changed from 8.7.3-12006047)
com.android.tools.build:aaptcompiler:8.11.0, (changed from 8.7.3)
com.android.tools.build:apksig:8.11.0, (changed from 8.7.3)
com.android.tools.build:apkzlib:8.11.0, (changed from 8.7.3)
com.android.tools.build:builder:8.11.0, (changed from 8.7.3)
com.android.tools.build:builder-model:8.11.0, (changed from 8.7.3)
com.android.tools.build:builder-test-api:8.11.0, (changed from 8.7.3)
com.android.tools.build:bundletool:1.18.1, (changed from 1.17.1)
com.android.tools.build:gradle:8.11.0, (changed from 8.7.3)
com.android.tools.build:gradle-api:8.11.0, (changed from 8.7.3)
com.android.tools.build:gradle-settings-api:8.11.0, (changed from 8.7.3)
com.android.tools.build:manifest-merger:31.11.0, (changed from 31.7.3)
com.android.tools.ddms:ddmlib:31.11.0, (changed from 31.7.3)
com.android.tools.layoutlib:layoutlib-api:31.11.0, (changed from 31.7.3)
com.android.tools.lint:lint-model:31.11.0, (changed from 31.7.3)
com.android.tools.lint:lint-typedef-remover:31.11.0, (changed from 31.7.3)
com.android.tools.utp:android-device-provider-ddmlib-proto:31.11.0, (changed from 31.7.3)
com.android.tools.utp:android-device-provider-gradle-proto:31.11.0, (changed from 31.7.3)
com.android.tools.utp:android-device-provider-profile-proto:31.11.0, (changed from 31.7.3)
com.android.tools.utp:android-test-plugin-host-additional-test-output-proto:31.11.0, (changed from 31.7.3)
com.android.tools.utp:android-test-plugin-host-apk-installer-proto:31.11.0, (changed from 31.7.3)
com.android.tools.utp:android-test-plugin-host-coverage-proto:31.11.0, (changed from 31.7.3)
com.android.tools.utp:android-test-plugin-host-emulator-control-proto:31.11.0, (changed from 31.7.3)
com.android.tools.utp:android-test-plugin-host-logcat-proto:31.11.0, (changed from 31.7.3)
com.android.tools.utp:android-test-plugin-result-listener-gradle-proto:31.11.0, (changed from 31.7.3)
com.android.tools:annotations:31.11.0, (changed from 31.7.3)
com.android.tools:common:31.11.0, (changed from 31.7.3)
com.android.tools:dvlib:31.11.0, (changed from 31.7.3)
com.android.tools:repository:31.11.0, (changed from 31.7.3)
com.android.tools:sdk-common:31.11.0, (changed from 31.7.3)
com.android.tools:sdklib:31.11.0, (changed from 31.7.3)
com.android:signflinger:8.11.0, (changed from 8.7.3)
com.android:zipflinger:8.11.0, (changed from 8.7.3)
com.google.api.grpc:proto-google-common-protos:2.48.0, (changed from 2.17.0)
com.google.code.gson:gson:2.11.0, (changed from 2.10.1)
com.google.errorprone:error_prone_annotations:2.30.0, (changed from 2.28.0)
com.google.protobuf:protobuf-java:3.25.5, (changed from 3.22.3)
com.google.protobuf:protobuf-java-util:3.25.5, (changed from 3.22.3)
com.google.testing.platform:core-proto:0.0.9-alpha03, (changed from 0.0.9-alpha02)
commons-io:commons-io:2.16.1, (changed from 2.13.0)
io.grpc:grpc-api:1.69.1, (changed from 1.57.0)
io.grpc:grpc-context:1.69.1, (changed from 1.57.0)
io.grpc:grpc-core:1.69.1, (changed from 1.57.0)
io.grpc:grpc-netty:1.69.1, (changed from 1.57.0)
io.grpc:grpc-protobuf:1.69.1, (changed from 1.57.0)
io.grpc:grpc-protobuf-lite:1.69.1, (changed from 1.57.0)
io.grpc:grpc-stub:1.69.1, (changed from 1.57.0)
io.netty:netty-buffer:4.1.110.Final, (changed from 4.1.93.Final)
io.netty:netty-codec:4.1.110.Final, (changed from 4.1.93.Final)
io.netty:netty-codec-http:4.1.110.Final, (changed from 4.1.93.Final)
io.netty:netty-codec-http2:4.1.110.Final, (changed from 4.1.93.Final)
io.netty:netty-codec-socks:4.1.110.Final, (changed from 4.1.93.Final)
io.netty:netty-common:4.1.110.Final, (changed from 4.1.93.Final)
io.netty:netty-handler:4.1.110.Final, (changed from 4.1.93.Final)
io.netty:netty-handler-proxy:4.1.110.Final, (changed from 4.1.93.Final)
io.netty:netty-resolver:4.1.110.Final, (changed from 4.1.93.Final)
io.netty:netty-transport:4.1.110.Final, (changed from 4.1.93.Final)
io.netty:netty-transport-native-unix-common:4.1.110.Final, (changed from 4.1.93.Final)
io.perfmark:perfmark-api:0.27.0, (changed from 0.26.0)
org.bouncycastle:bcpkix-jdk18on:1.79, (changed from 1.77)
org.bouncycastle:bcprov-jdk18on:1.79, (changed from 1.77)
org.bouncycastle:bcutil-jdk18on:1.79, (changed from 1.77)
org.codehaus.mojo:animal-sniffer-annotations:1.24, (changed from 1.23)
org.jetbrains.kotlin:kotlin-reflect:2.1.20, (changed from 2.0.21)
org.jetbrains.kotlin:kotlin-stdlib:2.1.20, (changed from 2.1.10)
org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.1.20, (changed from 2.0.21)
org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.1.20, (changed from 2.0.21)
org.ow2.asm:asm:9.7.1, (changed from 9.6)
org.ow2.asm:asm-analysis:9.7.1, (changed from 9.6)
org.ow2.asm:asm-commons:9.7.1, (changed from 9.6)
org.ow2.asm:asm-tree:9.7.1, (changed from 9.6)
org.ow2.asm:asm-util:9.7.1, (changed from 9.6)
org.tensorflow:tensorflow-lite-metadata:0.2.0, (changed from 0.1.0-rc2)

⚠️ Build environment tree is too large. View it in Buildkite artifacts

@wpmobilebot

wpmobilebot commented Jul 22, 2025

Copy link
Copy Markdown
Contributor
WordPress📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress WordPress
FlavorJalapeno
Build TypeDebug
Versionpr22043-62aff76
Commit62aff76
Direct Downloadwordpress-prototype-build-pr22043-62aff76.apk
Note: Google Login is not supported on these builds.

@wpmobilebot

wpmobilebot commented Jul 22, 2025

Copy link
Copy Markdown
Contributor
Jetpack📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack Jetpack
FlavorJalapeno
Build TypeDebug
Versionpr22043-62aff76
Commit62aff76
Direct Downloadjetpack-prototype-build-pr22043-62aff76.apk
Note: Google Login is not supported on these builds.

oguzkocer added 19 commits July 22, 2025 15:19
Replace @TargetApi(VERSION_CODES.P) with @RequiresApi(VERSION_CODES.P) in SignatureUtils.kt
to properly propagate API level requirements to callers as recommended by lint.
Replace manual SharedPreferences.edit() calls with KTX edit { } extension:
- Automatically handles editor creation and apply()
- More concise and idiomatic Kotlin code
- No functional changes, only syntax improvements

Files updated:
- JetpackFeatureOverlayShownTracker: 3 instances
- SelectedSectionManager: 1 instance
- SelectedTrafficGranularityManager: 1 instance
- UpdateNotificationSettingsUseCase: 1 instance
- GCMRegistrationWorker: 3 instances (already using KTX)
Replace View.visibility comparisons and assignments with isVisible property:
- Cleaner syntax for visibility checks (view.isVisible vs view.visibility == View.VISIBLE)
- Direct boolean assignment for showing/hiding views
- No functional changes

Files updated:
- EventItemViewHolder: Both setting and reading visibility
- PhotoPickerFragment: 2 visibility checks
- ReaderExpandableTagsView: Filter operation using isVisible
- MediaPickerFragment: Conditional visibility check
- UiHelpers: Already using isVisible correctly
Replace manual transaction handling with KTX transaction { } extension:
- Automatically handles beginTransaction, setTransactionSuccessful, and endTransaction
- Ensures proper cleanup in finally block
- Maintains error handling with SQLException catches for boolean return functions

Files updated:
- ResolverUtility: 2 transaction blocks with proper error handling
- SavedInstanceDatabase: Simple transaction for reset operation
Replace manual canvas.save()/restoreToCount() with withSave { } extension:
- Automatically saves and restores canvas state
- Cleaner scoped canvas operations
- No functional changes to drawing behavior

Files updated:
- LineChartMarkerView: Chart tooltip drawing
- SubscribersChartMarkerView: Chart tooltip drawing
Replace Uri.parse() calls with toUri() extension function:
- More idiomatic Kotlin syntax
- Same functionality, just cleaner API
- Note: EditPostActivity Uri.parse() kept due to nullable String handling

Files updated:
- MediaUriPager: Preview URIs
- HelpActivity: FAQ URLs (2 instances)
- FeedbackFormViewModel: Attachment URIs
- FeedbackFormScreen: Placeholder URIs (2 instances)
- AbstractAllowedUrlsWebViewNavigationDelegate: URL parsing
- ImageManager: Multiple image loading URIs
- WidgetUtils: Intent data URI
- PreviewImageFragment: Image loading URI
Replace TextUtils.getTrimmedLength() with trimmedLength() extension:
- Direct extension function on CharSequence
- Same trimming behavior (removes trailing whitespace)
- More idiomatic Kotlin

File updated:
- NoteViewHolder: Trimming notification subject text
Replace ColorDrawable constructor with toDrawable() extension:
- Creates ColorDrawable from color int value
- Cleaner and more idiomatic Kotlin
- Same resulting drawable

Files updated:
- PreviewModeSelectorPopup: Background color drawable
- ImageManager: Fallback error drawable from color resource
Replace menu.size() method call with size property:
- KTX extension provides property access
- More idiomatic Kotlin property syntax
- Same functionality

File updated:
- PhotoPickerActionModeCallback: Check if menu is empty
Replace more Uri.parse() calls with toUri() extension function:
- More idiomatic Kotlin syntax for URI creation
- Same functionality as Uri.parse() for non-null strings
- Consistent with previous toUri() conversions

Files updated:
- ActivityLauncherWrapper: Play Store URL parsing
- VideoLoader: File path to URI conversion
- DeviceMediaLoader: Media URI parsing
- CardViewModelSlice: URL parsing (2 files)
- PhotoPickerViewModel: URI construction
- AztecImageLoader: Image URI parsing
- AppPrefsWrapper: URL parsing
- DownloadManagerWrapper: Download URI parsing
- UriWrapper: Constructor URI parsing
- AppReviewManager: Review URL parsing
Replace manual TypedArray handling with withStyledAttributes extension:
- Automatically handles obtainStyledAttributes and recycle()
- Scoped access to attributes within lambda
- Cleaner resource management

File updated:
- ActionableEmptyView: Custom view attribute parsing
Replace Uri.parse() with toUri() extension for URI creation:
- Consistent with other toUri() conversions
- More idiomatic Kotlin syntax
- Same functionality for content resolver queries

File updated:
- ContentResolverWrapper: Query URI construction
Replace View.visibility == View.GONE checks with isGone property:
- Consistent with isVisible usage elsewhere
- More readable boolean checks
- Same functionality

File updated:
- DateSelectorViewUtils: Time zone visibility checks
Updates deprecated Uri.parse() calls to use the KTX extension for cleaner and more idiomatic code.
Modernizes styled attributes handling using KTX extension for automatic resource management and cleaner code.
Modernizes canvas state management using KTX extension for automatic restore handling and cleaner code.
Add proper exception logging for caught SQLException to comply with detekt rules and improve debugging.
- Replace Context.obtainStyledAttributes with withStyledAttributes KTX in UnifiedCommentListItemDecoration
- Replace Menu.size() with Menu.size property in WPMainNavigationView

Note: Uri.parse() calls in EditPostActivity and UriUtilsWrapper are left unchanged as they handle nullable strings which the KTX toUri() extension does not support.
Added baseline entries for Aligned16KB lint errors from native libraries that don't support 16KB page alignment. These errors will be addressed in a later PR by updating dependencies to versions that support 16KB alignment for better device compatibility.

Libraries affected:
- com.facebook.fbjni:fbjni:0.5.1
- com.facebook.react:react-android:0.73.3
- com.facebook.fresco:animated-gif:2.0.0
- com.facebook.react:hermes-android:0.73.3
- com.facebook.fresco:imagepipeline-native:3.1.3
- com.facebook.fresco:nativeimagefilters:3.1.3
Replaces Uri.parse() with String.toUri() extension and adds
null safety check for matcher.group(1) result.
- Convert UriUtilsWrapper.parse() to use non-nullable String parameter
- Replace Uri.parse() with String.toUri() KTX extension
- Add null safety in GifMediaDataSource.toMediaItem()
- Use mapNotNull to filter out invalid MediaItems
- Add proper Context and Resources mocks in test setup
- Mock context.resources to return valid Resources object
- Fixes NullPointerException in resource.toDrawable(context.resources)
Reverts database transaction KTX changes that broke existing tests.
The KTX conversion changed exception handling behavior and return values,
breaking test expectations for database failure scenarios.
UseKtx warning is suppressed because the transaction KTX extension doesn't
provide sufficient control over transaction success/failure handling needed
for the existing API contract. Manual transaction handling is required to
return specific boolean values to callers like UserFlagsHelper.
@sonarqubecloud

Copy link
Copy Markdown

@codecov

codecov Bot commented Jul 27, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 13.63636% with 76 lines in your changes missing coverage. Please review.
✅ Project coverage is 39.29%. Comparing base (a2699bf) to head (62aff76).
⚠️ Report is 3 commits behind head on trunk.

Files with missing lines Patch % Lines
...mments/unified/UnifiedCommentListItemDecoration.kt 0.00% 35 Missing ⚠️
...workers/notification/push/GCMRegistrationWorker.kt 0.00% 5 Missing ⚠️
...a/org/wordpress/android/util/image/ImageManager.kt 0.00% 4 Missing ⚠️
...etpackoverlay/JetpackFeatureOverlayShownTracker.kt 0.00% 3 Missing ⚠️
...ndroid/ui/mediapicker/loader/GifMediaDataSource.kt 72.72% 0 Missing and 3 partials ⚠️
...tions/usecase/UpdateNotificationSettingsUseCase.kt 0.00% 3 Missing ⚠️
...android/ui/main/feedbackform/FeedbackFormScreen.kt 0.00% 2 Missing ⚠️
...id/ui/stats/refresh/utils/DateSelectorViewUtils.kt 0.00% 2 Missing ⚠️
...rdpress/android/ui/utils/DownloadManagerWrapper.kt 0.00% 2 Missing ⚠️
...rdpress/android/resolver/ContentResolverWrapper.kt 0.00% 1 Missing ⚠️
... and 16 more
Additional details and impacted files
@@            Coverage Diff             @@
##            trunk   #22043      +/-   ##
==========================================
+ Coverage   39.15%   39.29%   +0.13%     
==========================================
  Files        2134     2143       +9     
  Lines      101271   101698     +427     
  Branches    15544    15597      +53     
==========================================
+ Hits        39655    39958     +303     
- Misses      58079    58187     +108     
- Partials     3537     3553      +16     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@oguzkocer oguzkocer marked this pull request as ready for review July 27, 2025 07:15
@oguzkocer oguzkocer requested a review from a team as a code owner July 27, 2025 07:15
@oguzkocer oguzkocer requested review from nbradbury and removed request for a team July 27, 2025 07:15
@oguzkocer oguzkocer enabled auto-merge (squash) July 27, 2025 07:15
@nbradbury nbradbury self-assigned this Jul 28, 2025

@nbradbury nbradbury left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@oguzkocer Thanks for this PR! I smoke-tested the app and didn't find any issues. :shipit:

@oguzkocer oguzkocer merged commit 7902a7a into trunk Jul 28, 2025
28 checks passed
@oguzkocer oguzkocer deleted the update-agp-to-8.11.0 branch July 28, 2025 14:37
@dcalhoun

dcalhoun commented Jul 30, 2025

Copy link
Copy Markdown
Member

@oguzkocer @nbradbury I'm encountering unexpected languages in trunk, where incorrect language strings are sporadically displayed. Do you experience this issue as well?

I recall we reverted a previous AGP upgrade in #21917 due to this issue. Do you think my recent experience stems from this AGP upgrade?

@adalpari

Copy link
Copy Markdown
Contributor

I recall we reverted a previous AGP upgrade in #21917 due to this issue. Do you think my recent experience stems from this AGP upgrade?

I did test it with Spanish and English (Having my phone in English but the app in Spanish and vice versa). Could you share any examples or steps to reproduce it?
I though the latest AGP version fixed it :(

@nbradbury

Copy link
Copy Markdown
Contributor

Oof, I'm stunned this is still an issue. I'm able to reproduce this:

  • Use a Pixel 8 Android 15 device (API 35)
  • Set the device language to something other than English
  • Change the app language to English
  • Return to the main activity and switch tabs
  • Note that the app reverts back to the device language

@oguzkocer I hate to say this, but we'll need to revert the AGP 8.11.0 update.

@dcalhoun

Copy link
Copy Markdown
Member

I'm testing with 43b0fb7.

Emulator configuration

image

Screen recording

wp-android-languages.mov

@dcalhoun

Copy link
Copy Markdown
Member

For additional context, my understanding is that we should await the resolution of the relevant issue before upgrading AGP.

@nbradbury

Copy link
Copy Markdown
Contributor

For additional context, my understanding is that we should await the resolution of the relevant issue before upgrading AGP.

Yes, we should. It was a mistake to overlook this.

@dcalhoun

Copy link
Copy Markdown
Member

Noting another relevant issue discussing the same subject.

@nbradbury

Copy link
Copy Markdown
Contributor

@dcalhoun Good find, I missed that other issue! The final comment on that mentions that this was fixed in the May AOSP update, so it's not strictly an AGP issue.

Regardless, I don't think we can expect everyone to have installed that update, so it probably still makes sense for us to revert the change.

@dcalhoun

Copy link
Copy Markdown
Member

The final comment on that mentions that this was fixed in the May AOSP update, so it's not strictly an AGP issue.

Yeah, the issue does not occur on my Samsung Galaxy S20 running Android 13. So, it seems to be device/OS specific.

@oguzkocer oguzkocer mentioned this pull request Jul 30, 2025
@oguzkocer

Copy link
Copy Markdown
Contributor Author

Thank you all for reporting the issue and sharing extra context! I've started working on reverting the update.

@sentry

sentry Bot commented Aug 2, 2025

Copy link
Copy Markdown

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

Did you find this useful? React with a 👍 or 👎

@oguzkocer

Copy link
Copy Markdown
Contributor Author

This pull request was deployed and Sentry observed the following issues:

The PR is not deployed, so that's not possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants