ccomeaux / boardgamegeek4android

BoardGameGeek application for Android (unofficial)
GNU General Public License v3.0
228 stars 47 forks source link

BggProvider.kt: Replace requireContext() by context!! #168

Closed ElieDeBrauwer closed 2 years ago

ElieDeBrauwer commented 3 years ago

The build the develop branch as-is fails with the exception shown below on my (HMD) Nokida 7 Plus running Android 10.

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.boardgamegeek, PID: 30735
    java.lang.NoSuchMethodError: No virtual method requireContext()Landroid/content/Context; in class Lcom/boardgamegeek/provider/BggProvider; or its super classes (declaration of 'com.boardgamegeek.provider.BggProvider' appears in /data/app/com.boardgamegeek-OSsvV3Z1KrlEY3riva2NfA==/base.apk!classes6.dex)
        at com.boardgamegeek.provider.BggProvider.query(BggProvider.kt:28)
        at android.content.ContentProvider.query(ContentProvider.java:1227)
        at android.content.ContentProvider.query(ContentProvider.java:1320)
        at android.content.ContentProvider$Transport.query(ContentProvider.java:280)
        at android.content.ContentResolver.query(ContentResolver.java:946)

As the implementation of requireContext() [1] is often limited to getting the context and throwing an exception when it is null, I replaced the calls to requireContext() to context!! calls.

There might be a real root cause to why the virtual method is missing, but this solution works for me.

[1] https://stackoverflow.com/questions/60402490/difference-between-getcontext-and-requirecontext-when-using-fragments

Signed-off-by: Elie De Brauwer eliedebrauwer@gmail.com