Android AssetPackManager registerListener SecurityException

137 views Asked by At

To get a large amount of image into my app I use AssetPackManager, and that works well, up to Android 14, where the following error is produced:

Fatal Exception: java.lang.SecurityException 
app.company.appname: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts.

Looking around for solutions, both in code and on the internet, I could not find anything. The log points to the next code:

assetPackManager?.let {
    it.fetch(Collections.singletonList(assetPackName))
    it.registerListener(mAssetPackStateUpdateListener)
}

And that uses:

var mAssetPackStateUpdateListener = AssetPackStateUpdateListener { state ->
    handleUpdate(state)
}

Checked Google Play Asset Delivery library: implementation 'com.google.android.play:core:1.10.3'

But I cannot find where to set RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED.

What I am going to dig into is where the OS UI shows the download. I have no receivers on that, but the OS does show something is going on.

Has anyone experience with this error in combination with Asset Packs?

1

There are 1 answers

1
Flummox - don't be evil SE On

CommonsWare put me on the right track.

Android AssetPack have been changed somewhere in the last few years. com.google.android.play:core: is deprecated!

Use the following (or newer, check link)

// For Java:
implementation "com.google.android.play:asset-delivery:2.1.0"
// For Kotlin use asset-delivery-ktx
implementation "com.google.android.play:asset-delivery-ktx:2.1.0"

So, I was using an old library and testing, with hundreds op people, did not pick this up...

*Will come back to see if this fixes things in the wild.