Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Update to targetSdk 34 #16711

Closed
david-allison opened this issue Jul 9, 2024 · 9 comments · Fixed by #16717
Closed

Update to targetSdk 34 #16711

david-allison opened this issue Jul 9, 2024 · 9 comments · Fixed by #16717

Comments

@david-allison
Copy link
Member

Index: gradle/libs.versions.toml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
--- a/gradle/libs.versions.toml	(revision 1125658c232c8e7ff6266abc2c580952785600d8)
+++ b/gradle/libs.versions.toml	(date 1720531017288)
@@ -1,7 +1,7 @@
 [versions]
 compileSdk = "34"
 minSdk = "23"  # also in testlib/build.gradle.kts
-targetSdk = "33"  # also in  ../robolectricDownloader.gradle
+targetSdk = "34"  # also in  ../robolectricDownloader.gradle
 acra = '5.11.3'
 amazonappstorepublisher = "0.1.0"
 androidGradlePlugin = "8.5.0"

https://developer.android.com/about/versions/14/behavior-changes-14

@MinusMallard
Copy link
Contributor

I might be too dumb to understand what you are trying to say, could you please elaborate

@Arthur-Milchior
Copy link
Member

Arthur-Milchior commented Jul 10, 2024

Sorry @MinusMallard but this is not a task for beginner, and if the link is not enough, I doubt we will try to explain more.

For anyone wanting to attack this issue, this is the error message that you obtain when applying this patch.


2024-07-10 03:46:24.494  9954-9954  AndroidRuntime          com.ichi2.anki.debug                 E  FATAL EXCEPTION: main
  Process: com.ichi2.anki.debug, PID: 9954
  java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ichi2.anki.debug/com.ichi2.anki.DeckPicker}: java.lang.SecurityException: com.ichi2.anki.debug: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts
  	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3782)
  	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3922)
  	at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
  	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:139)
  	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:96)
  	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2443)
  	at android.os.Handler.dispatchMessage(Handler.java:106)
  	at android.os.Looper.loopOnce(Looper.java:205)
  	at android.os.Looper.loop(Looper.java:294)
  	at android.app.ActivityThread.main(ActivityThread.java:8177)
  	at java.lang.reflect.Method.invoke(Native Method)
  	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
  	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
  Caused by: java.lang.SecurityException: com.ichi2.anki.debug: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts
  	at android.os.Parcel.createExceptionOrNull(Parcel.java:3057)
  	at android.os.Parcel.createException(Parcel.java:3041)
  	at android.os.Parcel.readException(Parcel.java:3024)
  	at android.os.Parcel.readException(Parcel.java:2966)
  	at android.app.IActivityManager$Stub$Proxy.registerReceiverWithFeature(IActivityManager.java:5684)
  	at java.lang.reflect.Method.invoke(Native Method)
  	at leakcanary.ServiceWatcher$install$4$2.invoke(ServiceWatcher.kt:93)
  	at java.lang.reflect.Proxy.invoke(Proxy.java:1006)
  	at $Proxy4.registerReceiverWithFeature(Unknown Source)
  	at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1852)
  	at android.app.ContextImpl.registerReceiver(ContextImpl.java:1792)
  	at android.app.ContextImpl.registerReceiver(ContextImpl.java:1780)
  	at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:755)
  	at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:755)
  	at com.ichi2.anki.DeckPicker.registerExternalStorageListener(DeckPicker.kt:1914)
  	at com.ichi2.anki.DeckPicker.onCreate(DeckPicker.kt:453)
  	at android.app.Activity.performCreate(Activity.java:8595)
  	at android.app.Activity.performCreate(Activity.java:8573)
  	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1456)
  	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3764)
  	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3922) 
  	at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103) 
  	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:139) 
  	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:96) 
  	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2443) 
  	at android.os.Handler.dispatchMessage(Handler.java:106) 
  	at android.os.Looper.loopOnce(Looper.java:205) 
  	at android.os.Looper.loop(Looper.java:294) 
  	at android.app.ActivityThread.main(ActivityThread.java:8177) 
  	at java.lang.reflect.Method.invoke(Native Method) 
  	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552) 
  	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971) 
  Caused by: android.os.RemoteException: Remote stack trace:
  	at com.android.server.am.ActivityManagerService.registerReceiverWithFeature(ActivityManagerService.java:13927)
  	at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:2570)
  	at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2720)
  	at android.os.Binder.execTransactInternal(Binder.java:1339)
  	at android.os.Binder.execTransact(Binder.java:1275)

I created #16713 to solve this first step

@mikehardy
Copy link
Member

mikehardy commented Jul 12, 2024

Publish failed, for a new reason, needs investigation with regard to whether we are using foreground services and if so for what reason etc:


* What went wrong:
Execution failed for task ':commitEditForComDotIchi2DotAnki'.
> A failure occurred while executing com.github.triplet.gradle.play.tasks.CommitEdit$Committer
   > 403 Forbidden
> Task :commitEditForComDotIchi2DotAnki FAILED
     POST https://androidpublisher.googleapis.com/androidpublisher/v3/applications/com.ichi2.anki/edits/02044752375500691564:commit?changesNotSentForReview=false
     {
       "code": 403,
       "errors": [
         {
           "domain": "global",
           "message": "You must let us know whether your app uses any Foreground Service permissions.",
           "reason": "forbidden"
         }
       ],
       "message": "You must let us know whether your app uses any Foreground Service permissions.",
       "status": "PERMISSION_DENIED"
     }

@mikehardy mikehardy reopened this Jul 12, 2024
@BrayanDSO
Copy link
Member

It is used for the scoped storage migration and for syncing in the background

@mikehardy
Copy link
Member

some progress, looked in to this again today and I think we are doing things correctly.

Specifically, we have two foreground services, the collection sync and the data migration. Both are permissible (I believe) as "dataSync" foreground service types and are marked as such in the AndroidManifest, with the correct use-permission chunks included.

What appears to be missing is the Play Console information where I am supposed to be able to (or, "am required to") add information about each service including a usage video on how to access the service and what happens if it is killed or whatever:

https://support.google.com/googleplay/android-developer/answer/13392821

Section "Declaring your foreground service information in Play Console"

I am currently unable to see that anywhere in our App Content page, so I suppose next step is to locally build an alpha and try to upload it manually to see if that unlocks things in a step-wise fashion vs the "upload + commit + launch" that our auto-publish does.

@mikehardy
Copy link
Member

mikehardy commented Jul 13, 2024

Amazing. IMNSHO, this is a broken process as there is no way to pre-declare in Play Console what you are doing, the declaration form is only available if you upload a targetSdk 34 build and then attempt to publish, and it just shows up as a warning where you can then click in

image

I need to link to a video that demonstrates:

  • using sync (easy)
  • doing the data migration from shared storage to scoped storage (harder)

Then the release will go through I think? After they review it.

Not sure how anyone could have done this if they didn't have the production keystore on their machine, and no one else has it 🤷 . Perhaps there is an "upload but don't commit/publish" option to the Triple-T plugin we are using. Anyway, working through this and I pushed the version bump commit + tag to main so the build is reproducible at least

@mikehardy
Copy link
Member

Continuing to leave notes to myself as I do this as I never know when family commitments will pull me away

release-2.15 branch appears to be both buildable (with Java 11 anyway, and you need to install an old NDK I believe) and syncable as it supports the timezone code requirement that ankiweb enforces now. So you can use that pull a collection down (if you have one... I do) to /sdcard/AnkiDroid so you have a pre-migration setup

Now I'm going to save that off so I can re-use it as needed, and attempt to do the migration a few times until I have a reasonable video to submit to The Google

@mikehardy
Copy link
Member

That was quite challenging. I ended up just hacking in quick returns / boolean trues in order to trigger a migration offer as I could not get it to trigger otherwise. I was able to film it using those tricks though, and I completed the declaration 😅

image

@mikehardy
Copy link
Member

Note for the future, if we ever have manual steps like this again, the way to do it if you are not me and do not have access to the production keystore is:

  • add param to the workflow that allows the release build artifacts to be uploaded so people may download + upload manually to google play as needed
  • add param to workflow that allows the google play upload to stop at "upload" and not attempt to commit them + publish them, so you can manually attempt that and then do whatever manual step Google Play Dashboard forces you

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants