2013-08-21 115 views
0

我正在嘗試使用cordova 2.2版本的設備的聯繫人。當我在模擬器中運行應用程序時,它顯示應用程序意外停止。 logcat顯示以下錯誤。Cordova Android - 應用程序意外停止,請重試

08-21 19:04:27.999: E/AndroidRuntime(4650): FATAL EXCEPTION: main 
08-21 19:04:27.999: E/AndroidRuntime(4650): java.lang.SecurityException:      
            ConnectivityService: Neither user 10035 nor current                                 process has android.permission.ACCESS_NETWORK_STATE. 
08-21 19:04:27.999: E/AndroidRuntime(4650): at                         android.os.Parcel.readException(Parcel.java:1322) 
08-21 19:04:27.999: E/AndroidRuntime(4650):  at android.os.Parcel.readException(Parcel.java:1276) 

08-21 19:04:27.999: E/AndroidRuntime(4650):  at android.net.IConnectivityManager$Stub$Proxy.getActiveNetworkInfo(IConnectivityManager.java:345) 

08-21 19:04:27.999: E/AndroidRuntime(4650):  at android.net.ConnectivityManager.getActiveNetworkInfo(ConnectivityManager.java:251) 

08-21 19:04:27.999: E/AndroidRuntime(4650):  at org.apache.cordova.NetworkManager.execute(NetworkManager.java:127) 

08-21 19:04:27.999: E/AndroidRuntime(4650):  at org.apache.cordova.api.CordovaPlugin.execute(CordovaPlugin.java:61) 

08-21 19:04:27.999: E/AndroidRuntime(4650):  at org.apache.cordova.api.PluginManager.exec(PluginManager.java:224) 
08-21 19:04:27.999: E/AndroidRuntime(4650):  at org.apache.cordova.ExposedJsApi.exec(ExposedJsApi.java:43) 

08-21 19:04:27.999: E/AndroidRuntime(4650):  at org.apache.cordova.CordovaChromeClient.onJsPrompt(CordovaChromeClient.java:213) 

08-21 19:04:27.999: E/AndroidRuntime(4650):  at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:566) 
08-21 19:04:27.999: E/AndroidRuntime(4650):  at android.os.Handler.dispatchMessage(Handler.java:99) 

08-21 19:04:27.999: E/AndroidRuntime(4650):  at android.os.Looper.loop(Looper.java:123) 

08-21 19:04:27.999: E/AndroidRuntime(4650):  at android.app.ActivityThread.main(ActivityThread.java:3683) 

08-21 19:04:27.999: E/AndroidRuntime(4650):  at java.lang.reflect.Method.invokeNative(Native Method) 

08-21 19:04:27.999: E/AndroidRuntime(4650):  at java.lang.reflect.Method.invoke(Method.java:507) 

08-21 19:04:27.999: E/AndroidRuntime(4650):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 

08-21 19:04:27.999: E/AndroidRuntime(4650):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 

08-21 19:04:27.999: E/AndroidRuntime(4650):  at dalvik.system.NativeStart.main(Native Method) 

回答

0

您是否已將所有權限添加到您的AndroidManifest.xml文件中?基於該錯誤消息,它看起來像出於某種原因,應用程序沒有權限訪問android.permission.ACCESS_NETWORK_STATE

在2.2可用權限的列表(不知道爲什麼你需要的聯繫人的許可。):

<uses-permission android:name="android.permission.CAMERA" /> 
<uses-permission android:name="android.permission.VIBRATE" /> 
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> 
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" /> 
<uses-permission android:name="android.permission.READ_PHONE_STATE" /> 
<uses-permission android:name="android.permission.INTERNET" /> 
<uses-permission android:name="android.permission.RECEIVE_SMS" /> 
<uses-permission android:name="android.permission.RECORD_AUDIO" /> 
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> 
<uses-permission android:name="android.permission.READ_CONTACTS" /> 
<uses-permission android:name="android.permission.WRITE_CONTACTS" /> 
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
<uses-permission android:name="android.permission.GET_ACCOUNTS" /> 
<uses-permission android:name="android.permission.BROADCAST_STICKY" /> 

基礎上的文檔2.2聯繫人:http://cordova.apache.org/docs/en/2.2.0/cordova_contacts_contacts.md.html#Contacts你將需要添加:

<uses-permission android:name="android.permission.GET_ACCOUNTS" /> 
<uses-permission android:name="android.permission.READ_CONTACTS" /> 
<uses-permission android:name="android.permission.WRITE_CONTACTS" /> 
+0

亞..謝謝.. MBillau它得到的工作。再次感謝 – Muthukumar

+0

真棒,太棒了。請隨時「接受」此答案,以便我們知道您的問題已得到解決。 – MBillau

相關問題