react-native-navigation
react-native-navigation copied to clipboard
*posible fix* App crashes on Android RELEASE when using uri URL on ButtonTab icons
🐛 Bug Report
As the title says, if you want to have Uri URL, icons on your ButtonTab, it will make the app crash on RN 0.67.4 and RNN 7.26.0
Example to reproduce:
Navigation.mergeOptions('APP_TAB_PROFILE',{
bottomTab: {
icon: {"uri": "https://..."},
size: 30,
}
})
The error on ANDROID LOGCAT:
2022-04-29 23:53:59.954 26047-26047/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.hibodyapp, PID: 26047
android.os.NetworkOnMainThreadException
at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1571)
The possible FIX, commented out && context.isDebug() and add those 2 lines below on ImageLoader.kt
@Throws(IOException::class)
private fun getDrawable(context: Context, source: String): Drawable {
var drawable: Drawable?
if (isLocalFile(Uri.parse(source))) {
drawable = loadFile(context, source)
} else {
drawable = loadResource(context, source)
if (drawable == null /*&& context.isDebug()*/) {
val policy = ThreadPolicy.Builder().permitAll().build()
StrictMode.setThreadPolicy(policy)
drawable = readJsDevImage(context, source)
}
}
if (drawable == null) throw RuntimeException("Could not load image $source")
return drawable.mutate()
}
If there is a better solution I dont know... hope it helps someone.
@vorja Just for understand, why do you not download the remote image?