libktx / ktx

Kotlin extensions for the libGDX game framework
https://libktx.github.io/
Creative Commons Zero v1.0 Universal
1.37k stars 74 forks source link

AssetStorage fails to load assets on older Android devices due to unsupported ConcurrentHashMap APIs usage #453

Closed czyzby closed 1 year ago

czyzby commented 1 year ago

AssetStorage uses a ConcurrentHashMap internally to map asset paths to registered asset types. Since it makes use of the getOrDefault method, older Android devices might throw the following exception:

java.lang.NoSuchMethodError: No virtual method getOrDefault(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; in class Ljava/util/concurrent/ConcurrentHashMap; or its super classes (declaration of 'java.util.concurrent.ConcurrentHashMap' appears in /system/framework/core-libart.jar)
    at ktx.assets.async.AssetStorage.getAssetIdentifiers(storage.kt:1228)
czyzby commented 1 year ago

Thanks to Jay for reporting and debugging the issue.