"Theming Icons" functionality crashes live wallpapers on Android 12
Asked Answered
B

3

13

I recently noticed that my live wallpaper apps are crashing when users try to set the newly introduced "Theming Icons" functionality on Android 12. This new functionality calculates a palette of colors from the user's current static wallpaper and uses this palette to color some of the other apps icons (a feature of the new "Material You" design). But for some reason when it operates on a live wallpaper it crashes the app with the following log:

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'android.graphics.Bitmap android.graphics.drawable.BitmapDrawable.getBitmap()' on a null object reference
       at android.os.Parcel.createExceptionOrNull(Parcel.java:2443)
       at android.os.Parcel.createException(Parcel.java:2421)
       at android.os.Parcel.readException(Parcel.java:2404)
       at android.os.Parcel.readException(Parcel.java:2346)
       at android.service.wallpaper.IWallpaperConnection$Stub$Proxy.onWallpaperColorsChanged(IWallpaperConnection.java:298)
       at android.service.wallpaper.WallpaperService$IWallpaperEngineWrapper.executeMessage(WallpaperService.java:2586)
       at com.android.internal.os.HandlerCaller$MyHandler.handleMessage(HandlerCaller.java:44)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loopOnce(Looper.java:226)
       at android.os.Looper.loop(Looper.java:313)
       at android.app.ActivityThread.main(ActivityThread.java:8582)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:563)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1133)


Caused by android.os.RemoteException: Remote stack trace:
    at com.samsung.server.wallpaper.LegibilityColor.convertColors(LegibilityColor.java:418)
    at com.android.server.wallpaper.WallpaperManagerService$WallpaperConnection.onWallpaperColorsChanged(WallpaperManagerService.java:2169)
    at android.service.wallpaper.IWallpaperConnection$Stub.onTransact(IWallpaperConnection.java:158)
    at android.os.Binder.execTransactInternal(Binder.java:1215)
    at android.os.Binder.execTransact(Binder.java:1179)

At this moment I can observe this crash only on Samsung Galaxy S21 / S21 Ultra phones but it will be present on many more phones as users update their system to Android 12.

Currently, I cannot reproduce this crash because I don't own a Galaxy S21 and the Android Studio emulator still misses the "Theming Icons" option (maybe because this functionality is currently still in beta).

Does anybody have any clue on how to solve this catastrophic problem? Any help is greatly appreciated!

Update November 18: I was able to test the new "Themed icon" feature on the Android Studio Emulator (on the newly introduced "SV2" release). This release is really buggy but I was not able to reproduce a similar crash. It makes me think that this crash is exclusive to Samsung phones.

I tried to test some Galaxy S21 devices from the publicly available phones at the "Galaxy Mobile - Remote Test Lab" site, but they implement a beta version of Android 12 where the Themed Icon feature is not available.

I want to generate a complete crash report (log + video) to send to Samsung but I still can't find a Galaxy S21 with Android 12 installed (the Android 12 system update started on November 15 for Galaxy S21 phones). In the meantime, the crash reports are exploding as many more users are updating their phones to Android 12...Such a shame!

Butyraldehyde answered 16/11, 2021 at 0:4 Comment(5)
That's going to be tough for anyone outside of Samsung to help with. It would appear to be a bug in Samsung's customized wallpaper logic.Rinse
I have already begun to receive emails from different users who had updated to android 12... All of them tell me that the wallpaper stopped working after updating to android 12 and all of them have exactly Samsung S21 ultra. It's unbearable to witness all this and knowin that there's nothing you can do...Systemize
Finally I got a Pixel 5a device with the latest Android 12 and the first thing I did was of course installing my live wallpaper app and activating "Themed icons". Fortunately there was no problem and no crashes and everything went on working as it should. It confirms that the problem affects only Samsung devices.Systemize
I wonder if that bug occurs only when the "Themed icons" is on. If yes then as a temporary solution we can recommend to switch that option off. But I'm not sure. I don't know anyone who owns Samsung s21... By the way, even in Pixel 5a the Themed icons options is still marked as Beta.Systemize
hey, could you share a sample file demonstrating how to add live wallpaper functionality. I am trying from months but failing to do so.Branch
C
8

Solution found.

File name: wallpaper.xml

Was:

<wallpaper bla bla bla 
android:thumbnail="@mipmap/ic_launcher" 
/>

Changed to:

<wallpaper bla bla bla 
android:thumbnail="@drawable/thumbnail" 
/>

Copied the app icon to: drawable/thumbnail.png

Update from @Redwarp: you should use a bitmap not a vector image.

After app update:

enter image description here

Carlock answered 1/12, 2021 at 15:35 Comment(15)
That is odd. My app is already setup to drawable and not mipmap, and I still have the crash...Progress
I confirm, this solution works!! At least on Samsung s21 ultra in Samsung Remote Test Lab!!! First, I reproduced the bug there and then I applied the solution offered by Alexey and tested my live wallpaper app again in Samsung Remote Test Lab and to my surprise the bug disappeared!!! I don't know why but this solution really works! Thanks Alexey! P.S. It seems like Samsung OneUI needs wallpaper "android:thumbnail" icon to get wallpaper colors and for some unknown reason cannot find it if it's located in mipmap directory. So placing it in drawable directory fixed the issue.Systemize
I found a new bug: if the screen is off for more than 2 minutes, then the live wallpaper stops showing on the lock screen. After unlocking your phone, the wallpaper is displayed on the lock screen again. I tried to somehow influence this timeout by changing the settings, tried to set different live wallpapers but nothing changed. After that I put some of the recommended wallpapers on the lock screen (as I understand this video wallpaper) and they did not disappear after 2 minutes.Carlock
Just wanted to let everybody know that I have just received the 1st confirmation from a real user of Samsung S21 Ultra that the solution works.Systemize
Extra precision for me: the fix was not working for me because I was using a vector drawable. My thumbnail was indeed a drawable, but not a bitmap. Once I replaced the vector drawable with a bitmap (in my case, a webp), then I could verify on the Samsung Remote Test Lab that my app was not crashing anymore. Thanks a lot @Carlock for the suggestion.Progress
I've now confirmed that this fix is working for my users on my app (play.google.com/store/apps/…). Thank you @Carlock for discovering and sharing this fix! I certainly would have never thought of it…Theone
It didn't work for me. I am using LibGDX. Still looking for a workaround. And Samsung is taking long to fix the bug at their side :(Distaste
@Distaste give me a link to the appCarlock
@Carlock play.google.com/store/apps/details?id=com.fruit4droid.cronosurfDistaste
@Distaste I downloaded the apk from apkpure and apkcombo, after decompiling, I did not find the file corresponding to livewallpaper.xml specified in the manifest in the resources. I tried searching for the contents of "<wallpaper" and didn't find anything either. I understand that you used an obfuscator, but perhaps the problem is in the wrong content of this file.Carlock
@Distaste I explored some live wallpaper recently, because there is a similar problem on Google Pixel devices with Android 12 and I have not yet been able to find a solution. Here is an example of the contents of such a file from the wallpaper that I watched: <?xml version="1.0" encoding="utf-8"?> <wallpaper xmlns:android="schemas.android.com/apk/res/android" android:description="@string/description" android:settingsActivity="com.maxelus.shadowgalaxylivewallpaper.WallpaperSettings" android:thumbnail="@drawable/thumbnail"/>Carlock
@Carlock I see. When I open the apk file, I also don't find the file livewallpaper.xml, and neither the string "<wallpaper" or "android:thumbnail". My file livewallpaper.xml contains: <?xml version="1.0" encoding="utf-8"?> <wallpaper xmlns:android ="schemas.android.com/apk/res/android" android:thumbnail = "@drawable/minics" android:settingsActivity="com.fruit4droid.cronosurf.android.LiveWallpaperSettings" android:description = "@string/app_name" /> As a test, I change the "@drawable/minics" to "@drawable/x" and I do get an error when trying to run. So, why is it not in the apk?Distaste
@Distaste Possibly due to obfuscator settings. Try turning it off for resources.Carlock
@Carlock Yes, you are right, it must be the obfuscator. However, as you see in my last comment, the content of my file livewallpaper.xml is correct, isn't it? And the file minics.png is a bitmap, not a vector image. So still wondering why this solution is not working for me.Distaste
@Distaste File livewallpaper.xml is fine. You can try to exclude certain folders from the obfuscator using the "-keepdirectories" command. Then build the APK and check for livewallpaper.xml and minics.png files. If all is well, release an update. I will test it on S21 and report the results.Carlock
C
1

For a while I was looking for a similar problem in reviews of popular live wallpapers. I found similar reviews only for one application. I updated my phone today. All my live wallpapers stopped working as expected. Then I installed "Earth & Moon" and this app works fine. It means that we are doing something wrong or, on the contrary, we are not doing something :) In the near future I will begin to investigate this problem.

Carlock answered 30/11, 2021 at 22:5 Comment(4)
I was just going to report that Walloop is also still working (Android 12, Samsung S21) so it must be possible! I have no idea what to try though, so I look forward to hearing what you find!Theone
Since it has to do with the wallpaper colors, I wonder if there's something different we can do with onComputeColors or something. My live wallpaper has onComputeColors, but it just returns three pure black values; maybe the system doesn't like that and is trying to figure it out itself?Theone
Can you please specify the exact wallpaper name or its package name which works without problems on s21? There are lots of apps with name Earth & Moon :)Systemize
"Earth & Moon 3D Live Wallpaper" by CodeKonditor, "Matrix Live Wallpaper" by Crydata.Carlock
T
0

One of the users of my app who is on a Samsung S21 tells me that a new Samsung OS update (SP1A.210812.016.G991BXXU3BUKG) fixed the issue for them even before I implemented @Aleksey's fix. Good to see Samsung is taking care of things.

That said, I'm still in favor of implementing the fix ourselves as well, in case there are other places where it's needed.

Theone answered 7/12, 2021 at 22:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.