简体   繁体   English

使用 react-native-device-info 模块时,React native android 应用程序在 assemble release build 中崩溃

[英]React native android app crashes in assemble release build when use react-native-device-info module

In debug build it is working fine but when in release apk build, when run it only display splash screen then it crashes.在调试版本中它工作正常,但是在发布 apk 版本时,运行时它只显示启动屏幕然后它崩溃。

I tried many technics and look the related issue in the forum to fix it, did not work.我尝试了许多技术并在论坛中查看相关问题以解决它,但没有奏效。

Solution:解决方案:

I was not able to track how the released apk app crashing.我无法跟踪已发布的 apk 应用程序是如何崩溃的。 It worked fine in debug mode.它在调试模式下运行良好。

The simple trick that I made work.我成功的简单技巧。

when I run this command in projectname/android and open release apk app当我在projectname/android中运行此命令并打开发布 apk 应用程序时

adb logcat *:E

It gives me this error exception in logcat它在 logcat 中给了我这个错误异常

04-20 12:31:49.153 23368 23410 E AndroidRuntime: java.lang.SecurityException: WifiService: Neither user 11740 nor current process has android.permission.ACCESS_WIFI_STATE.

04-20 12:31:49.153 23368 23410 E AndroidRuntime:        at android.os.Parcel.createException(Parcel.java:2088)

04-20 12:31:49.153 23368 23410 E AndroidRuntime:        at android.os.Parcel.readException(Parcel.java:2056)

04-20 12:31:49.153 23368 23410 E AndroidRuntime:        at android.os.Parcel.readException(Parcel.java:2004)

04-20 12:31:49.153 23368 23410 E AndroidRuntime:        at android.net.wifi.IWifiManager$Stub$Proxy.getConnectionInfo(IWifiManager.java:3474)
...

There was no wifi access permission which is required by react-native-device-info module. react-native-device-info模块不需要 wifi 访问权限。

In the Manifest file, I give this permission and work it out.在 Manifest 文件中,我授予此权限并解决。

<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM