gpt4 book ai didi

java - android 应用程序在启动前崩溃

转载 作者:太空宇宙 更新时间:2023-11-03 12:09:30 26 4
gpt4 key购买 nike

这是一个非常简单的应用程序,在我添加之前它运行良好

<script src="cordova-2.5.0.js" type="text/javascript"></script>

对于我的 index.html,它在启动前崩溃(在模拟器和实际设备中)这里是错误

03-19 21:24:28.633: E/AndroidRuntime(1467): FATAL EXCEPTION: main
03-19 21:24:28.633: E/AndroidRuntime(1467): java.lang.RuntimeException: Error receiving broadcast Intent { act=android.net.conn.CONNECTIVITY_CHANGE flg=0x10000010 (has extras) } in org.apache.cordova.NetworkManager$1@b49b2b50
03-19 21:24:28.633: E/AndroidRuntime(1467): at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:737)
03-19 21:24:28.633: E/AndroidRuntime(1467): at android.os.Handler.handleCallback(Handler.java:605)
03-19 21:24:28.633: E/AndroidRuntime(1467): at android.os.Handler.dispatchMessage(Handler.java:92)
03-19 21:24:28.633: E/AndroidRuntime(1467): at android.os.Looper.loop(Looper.java:137)
03-19 21:24:28.633: E/AndroidRuntime(1467): at android.app.ActivityThread.main(ActivityThread.java:4424)
03-19 21:24:28.633: E/AndroidRuntime(1467): at java.lang.reflect.Method.invokeNative(Native Method)
03-19 21:24:28.633: E/AndroidRuntime(1467): at java.lang.reflect.Method.invoke(Method.java:511)
03-19 21:24:28.633: E/AndroidRuntime(1467): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
03-19 21:24:28.633: E/AndroidRuntime(1467): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-19 21:24:28.633: E/AndroidRuntime(1467): at dalvik.system.NativeStart.main(Native Method)
03-19 21:24:28.633: E/AndroidRuntime(1467): Caused by: java.lang.SecurityException: ConnectivityService: Neither user 10042 nor current process has android.permission.ACCESS_NETWORK_STATE.
03-19 21:24:28.633: E/AndroidRuntime(1467): at android.os.Parcel.readException(Parcel.java:1327)
03-19 21:24:28.633: E/AndroidRuntime(1467): at android.os.Parcel.readException(Parcel.java:1281)
03-19 21:24:28.633: E/AndroidRuntime(1467): at android.net.IConnectivityManager$Stub$Proxy.getActiveNetworkInfo(IConnectivityManager.java:597)
03-19 21:24:28.633: E/AndroidRuntime(1467): at android.net.ConnectivityManager.getActiveNetworkInfo(ConnectivityManager.java:365)
03-19 21:24:28.633: E/AndroidRuntime(1467): at org.apache.cordova.NetworkManager$1.onReceive(NetworkManager.java:107)
03-19 21:24:28.633: E/AndroidRuntime(1467): at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:728)
03-19 21:24:28.633: E/AndroidRuntime(1467): ... 9 more
03-19 21:24:28.672: E/dalvikvm(1467): VM aborting
03-19 21:24:28.672: A/libc(1467): Fatal signal 11 (SIGSEGV) at 0xdeadd00d (code=1)

最佳答案

添加:

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

到您的 AndroidManifest.xml。

它实际上在你的异常消息中说明:

Caused by: java.lang.SecurityException: ConnectivityService: 
Neither user 10042 nor current process has android.permission.ACCESS_NETWORK_STATE.

关于java - android 应用程序在启动前崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15511841/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com