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

Installing APK fails with 'java.lang.RuntimeException: Could not copy bitmap to parcel blob' #2026

Closed
raxod502 opened this issue Dec 15, 2023 · 22 comments

Comments

@raxod502
Copy link

raxod502 commented Dec 15, 2023

I am unable to install Syncthing on Android 14, receiving the following stack trace from the package installer when attempting to install the APK from https://github.com/syncthing/syncthing-android/releases/tag/1.27.1:

Stack trace
type: crash
osVersion: google/bluejay/bluejay:14/UQ1A.231205.015/2023120701:user/release-keys
package: com.android.packageinstaller:34
process: com.android.packageinstaller
processUptime: 1513 + 232 ms

java.lang.RuntimeException: Could not copy bitmap to parcel blob.
at android.graphics.Bitmap.nativeWriteToParcel(Native Method)
at android.graphics.Bitmap.writeToParcel(Bitmap.java:2271)
at android.os.Parcel.writeParcelable(Parcel.java:2586)
at com.android.packageinstaller.PackageUtil$AppSnippet.writeToParcel(PackageUtil.java:151)
at android.os.Parcel.writeParcelable(Parcel.java:2586)
at android.os.Parcel.writeValue(Parcel.java:2487)
at android.os.Parcel.writeValue(Parcel.java:2364)
at android.os.Parcel.writeArrayMapInternal(Parcel.java:1300)
at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1845)
at android.os.Bundle.writeToParcel(Bundle.java:1389)
at android.os.Parcel.writeBundle(Parcel.java:1369)
at android.content.Intent.writeToParcel(Intent.java:11823)
at android.os.Parcel.writeTypedObject(Parcel.java:2205)
at android.app.IActivityTaskManager$Stub$Proxy.startActivity(IActivityTaskManager.java:2077)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1879)
at android.app.Activity.startActivityForResult(Activity.java:5664)
at com.android.packageinstaller.PackageInstallerActivity.startActivityForResult(PackageInstallerActivity.java:487)
at android.app.Activity.startActivityForResult(Activity.java:5583)
at android.app.Activity.startActivity(Activity.java:6127)
at android.app.Activity.startActivity(Activity.java:6094)
at com.android.packageinstaller.PackageInstallerActivity.startInstall(PackageInstallerActivity.java:744)
at com.android.packageinstaller.PackageInstallerActivity.lambda$bindUi$0(PackageInstallerActivity.java:521)
at com.android.packageinstaller.PackageInstallerActivity.$r8$lambda$RCIm8wl1VPqdfQgkgmrBIDbuvOQ(PackageInstallerActivity.java:0)
at com.android.packageinstaller.PackageInstallerActivity$$ExternalSyntheticLambda0.onClick(R8$$SyntheticClass:0)
at com.android.packageinstaller.AlertController$ButtonHandler.handleMessage(AlertController.java:144)
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:8216)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
at com.android.internal.os.ExecInit.main(ExecInit.java:49)
at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:359)

My phone is a Google Pixel 6a running Android 14 (GrapheneOS UQ1A.231205.015.2023120701).

I was previously using https://github.com/Catfriend1/syncthing-android from F-Droid but updates started crashing the installer as of a couple days ago, with the stack trace above. I figured it might be an issue with the fork and so I uninstalled it and tried installing https://github.com/syncthing/syncthing-android instead, however I received the same result. I figured it might an F-Droid problem so I tried installing the APK directly downloaded from this GitHub repository, which had the same result. I tried versions 1.27.1, 1.27.0, 1.26.1, and 1.26.0, which all had the same issue. I am confident that I was previously using one of these versions without a problem, so I think there is an incompatibility with a recent release of GrapheneOS.

Other apps can still be installed and updated on my phone, just not Syncthing (or Syncthing-Fork).

@bt90
Copy link
Contributor

bt90 commented Dec 15, 2023

To be clear, the Android installer crashes here. This shouldn't happen no matter what we do on our end.

Did you try to contact the GrapheneOS devs?

@jpacura
Copy link

jpacura commented Dec 15, 2023

I'm not sure that this is just GrapheneOS, because I can't get 1.27.0 and 1.27.1 to install from F-Droid on either a Pixel 7 Pro or a Pixel Tablet, both running the latest stock operating system (December 2023). Other F-Droid apps install without problem. I'll check my logs later today to make sure whether it's the same error or not.

@jpacura
Copy link

jpacura commented Dec 15, 2023

Yep, it appears to be the same error message on my Pixel 7 Pro, Stock OS, December 2023 update:

Stack Trace
Process: com.google.android.packageinstaller
java.lang.RuntimeException: Could not copy bitmap to parcel blob.
	at android.graphics.Bitmap.nativeWriteToParcel(Native Method)
	at android.graphics.Bitmap.writeToParcel(Bitmap.java:2271)
	at android.os.Parcel.writeParcelable(Parcel.java:2584)
	at com.android.packageinstaller.PackageUtil$AppSnippet.writeToParcel(PackageUtil.java:151)
	at android.os.Parcel.writeParcelable(Parcel.java:2584)
	at android.os.Parcel.writeValue(Parcel.java:2485)
	at android.os.Parcel.writeValue(Parcel.java:2362)
	at android.os.Parcel.writeArrayMapInternal(Parcel.java:1298)
	at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1843)
	at android.os.Bundle.writeToParcel(Bundle.java:1389)
	at android.os.Parcel.writeBundle(Parcel.java:1367)
	at android.content.Intent.writeToParcel(Intent.java:11807)
	at android.os.Parcel.writeTypedObject(Parcel.java:2203)
	at android.app.IActivityTaskManager$Stub$Proxy.startActivity(IActivityTaskManager.java:2077)
	at android.app.Instrumentation.execStartActivity(Instrumentation.java:1873)
	at android.app.Activity.startActivityForResult(Activity.java:5615)
	at android.app.Activity.startActivityForResult(Activity.java:5573)
	at android.app.Activity.startActivity(Activity.java:6071)
	at android.app.Activity.startActivity(Activity.java:6038)
	at com.android.packageinstaller.PackageInstallerActivity.startInstall(PackageInstallerActivity.java:701)
	at com.android.packageinstaller.PackageInstallerActivity.lambda$bindUi$0(PackageInstallerActivity.java:479)
	at com.android.packageinstaller.PackageInstallerActivity.$r8$lambda$RCIm8wl1VPqdfQgkgmrBIDbuvOQ(PackageInstallerActivity.java:0)
	at com.android.packageinstaller.PackageInstallerActivity$$ExternalSyntheticLambda0.onClick(R8$$SyntheticClass:0)
	at com.android.packageinstaller.AlertController$ButtonHandler.handleMessage(AlertController.java:144)
	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:8194)
	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)

@jpacura
Copy link

jpacura commented Dec 15, 2023

If it helps anything, both of my devices are currently running 1.26.1, installed prior to the December 2023 android update

@bt90
Copy link
Contributor

bt90 commented Dec 15, 2023

I'm running the fork version v1.27.0.1 installed via F-Droid on my Pixel 4a 5G without problems.

Edit: just installed the regular app via F-Droid. Everything working as intended. I'm using Droid-ify as my f-droid client and running vanilla Android 14.

@mcexit
Copy link

mcexit commented Dec 15, 2023

I'm guessing it has something to do with some changes to Package Installer in Android 14 QPR1. See here:

uazo/cromite#595

@raxod502
Copy link
Author

Another app experiencing the same issue has worked around it by resizing an image asset: uazo/cromite@1a8ef38. The workaround has been confirmed to work: uazo/cromite#595 (comment)

I have reported the issue also on the GrapheneOS forum at https://discuss.grapheneos.org/d/9645-javalangruntimeexception-could-not-copy-bitmap-to-parcel-blob as suggested in #2026 (comment).

@tepozoa
Copy link

tepozoa commented Dec 18, 2023

If it helps anything, both of my devices are currently running 1.26.1, installed prior to the December 2023 android update

This is my situation as well - one of my 6a devices never had it installed, I can no longer install it on that device as of today (all the 14 updates applied etc.) The other with 1.26.1 installed pre-14 upgrades is working just fine, but will not upgrade to the latest from F-Droid as of today. https://forum.f-droid.org/t/syncthing-1-27-0-1-wont-update-install-on-2x-pixel-6a/24552

@imsodin
Copy link
Member

imsodin commented Dec 18, 2023

The reply in the grapheneos thread linked above suggests to me that this is an aosp (android) issue that was fixed, and system updates may not have rolled out to everyone affected:

Hello, the fix for this is on the latest version release. Please update your system.

So I suggest to upgrade your system if you are affected, as soon as you can.

@jpacura
Copy link

jpacura commented Dec 18, 2023

As far as I can tell, the stock pixel rom hasn't released an update yet for this, but it appears to be in the beta changelog, so hopefully they push it in the January update, but that's still almost a month away

@pbasov
Copy link

pbasov commented Dec 22, 2023

Reporting the same issue on Pixel 8 Pro after update to Android 14 UQ1A.231205.015 with the latest F-Droid version.

Really unfortunate, since I've uninstalled the app while trying to troubleshoot the upgrade. Google Play version of the app works though, so will continue using that till the fix is out.

@jpacura
Copy link

jpacura commented Dec 24, 2023

Just in case it helps anyone else that wants to upgrade syncthing before Google fixes this, I was able to download the apk from f-droid (be sure to validate the signature), and install it with adb install. It installed on my Pixel 7 Pro without any obvious issues so far, despite still refusing to install from the f-droid app. Because the apk from f-droid's website is identical to the one that the app tries to install, f-droid will still detect it as having been installed from f-droid, and it should not wipe the app's data.

@tepozoa
Copy link

tepozoa commented Dec 24, 2023

It installed on my Pixel 7 Pro without any obvious issues so far, despite still refusing to install from the f-droid app.

It fails for me on 2x different Pixel 6a w/December updates (one with the app already installed previously, one without) using a direct download; it's the system level Android APK installer failing, not the F-Droid client app.

@cumber
Copy link

cumber commented Dec 24, 2023

As far as I can tell, the stock pixel rom hasn't released an update yet for this, but it appears to be in the beta changelog, so hopefully they push it in the January update, but that's still almost a month away

I can confirm that I had the issue and was completely unable to install Syncthing, and that when I opted into the Pixel beta and got the newer firmware out was resolved.

So the next firmware update should fix it for everyone.

@imsodin
Copy link
Member

imsodin commented Jan 3, 2024

Well yeah, clearly not our bug - closing.

@imsodin imsodin closed this as completed Jan 3, 2024
@tepozoa
Copy link

tepozoa commented Jan 5, 2024

So the next firmware update should fix it for everyone.

The brand new 2024-01-05 security update applied to my Pixel 6a devices does not solve the problem, still crashes.

Well yeah, clearly not our bug - closing.

It may not directly be, but it sure would be nice if the community was able to use this OPEN issue as a focal point until the actual problem is resolved. As it stands, the syncthing-android package (via F-Droid) is the one and only application out of everything on my devices which can't upgrade.

Tangentially it is our (syncthing) issue in the sense of there are workarounds which could be applied; other projects (linked above) have done workaround to avoid the bug, the syncthing-android packagers could possibly do the same but choose not to at this time.

@bt90
Copy link
Contributor

bt90 commented Jan 5, 2024

I've tried to limit the vector path length of our drawables in #2035. Could you test if the app is installable with these changes?

The debug apk can be downloaded for this build: https://github.com/syncthing/syncthing-android/actions/runs/7424933082

grafik

@tepozoa
Copy link

tepozoa commented Jan 5, 2024

I've tried to limit the vector path length of our drawables in #2035. Could you test if the app is installable with these changes?

Thank you - alas, it sadly seems to crash the same in my test on a stock 6a. I'm using my one device which has never been syncthing-installed ("clean") and it appears to crash the on-device APK installer app in the same way as the releases.

@hcbraun
Copy link

hcbraun commented Jan 7, 2024

It may not directly be, but it sure would be nice if the community was able to use this OPEN issue as a focal point until the actual problem is resolved. As it stands, the syncthing-android package (via F-Droid) is the one and only application out of everything on my devices which can't upgrade.

Sadly same thing for me. The last two versions of syncthing via F-Droid do not install for me.

@bt90
Copy link
Contributor

bt90 commented Jan 7, 2024

If someone is able to figure out what exactly triggers the crash, I could try to patch that.

@tepozoa
Copy link

tepozoa commented Jan 7, 2024

If someone is able to figure out what exactly triggers the crash, I could try to patch that.

Disclaimer: I'm not a programmer. :) Looking at how the other linked project solved it, it boils down to this:

chrome/android/java/res_chromium_base/drawable/themed_app_icon.xml
-    android:width="900dp"
-    android:height="900dp"
-    android:viewportWidth="900"
-    android:viewportHeight="900">
+    android:width="90dp"
+    android:height="90dp"
+    android:viewportWidth="90"
+    android:viewportHeight="90">

Using that as an idea, I started digging around in the code and found two "these are not int values in the viewport declarations" anomalies:

I found two others which had a "high" (non-24) viewport specified:

I tried to backtrace the Android API reference (VectorDrawable -> Drawable -> Rect) and while I could be wrong, I think that everything that queries the viewport is expecting an int in return based on my read of the Rect object, which just so happens to be a member of android.os.Parcelable where our crash is being reported in the stack trace:

My thought is "what if we make those values proper ints? and should they just be generically 24?" ; I have no idea what these things actually are to the code, the next person can maybe pick up my idea from here...

@DrStrangeloovee
Copy link

I've tried to limit the vector path length of our drawables in #2035. Could you test if the app is installable with these changes?

The debug apk can be downloaded for this build: https://github.com/syncthing/syncthing-android/actions/runs/7424933082

grafik

I had the same initial problem on my Pixel 7a (with 5. Jan. updates) but I was able to install the provided debug apk via adb install without any error messages. So far I couldn't find any problems with it.

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 a pull request may close this issue.

10 participants