pcridesagain pcridesagain - 2 months ago 21
Android Question

'unfortunately, app has stopped' Android/Cordova app

I just set up an Android/Cordova 2.0.0 app with pretty nothing in it except the simple index page from the Cordova "getting started" guide.

But I am getting "unfortunately, app has stopped instantly when I run the project in the 4.0.3 simulator. I can run older projects I've done with no problem.

Here is the logCat content:

08-21 09:13:30.881: E/AndroidRuntime(529): FATAL EXCEPTION: main
08-21 09:13:30.881: E/AndroidRuntime(529): java.lang.SecurityException: ConnectivityService: Neither user 10040 nor current process has android.permission.ACCESS_NETWORK_STATE.
08-21 09:13:30.881: E/AndroidRuntime(529): at android.os.Parcel.readException(Parcel.java:1327)
08-21 09:13:30.881: E/AndroidRuntime(529): at android.os.Parcel.readException(Parcel.java:1281)
08-21 09:13:30.881: E/AndroidRuntime(529): at android.net.IConnectivityManager$Stub$Proxy.getActiveNetworkInfo(IConnectivityManager.java:597)
08-21 09:13:30.881: E/AndroidRuntime(529): at android.net.ConnectivityManager.getActiveNetworkInfo(ConnectivityManager.java:365)
08-21 09:13:30.881: E/AndroidRuntime(529): at org.apache.cordova.NetworkManager.execute(NetworkManager.java:124)
08-21 09:13:30.881: E/AndroidRuntime(529): at org.apache.cordova.api.PluginManager.exec(PluginManager.java:218)
08-21 09:13:30.881: E/AndroidRuntime(529): at org.apache.cordova.CordovaChromeClient.onJsPrompt(CordovaChromeClient.java:207)
08-21 09:13:30.881: E/AndroidRuntime(529): at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:600)
08-21 09:13:30.881: E/AndroidRuntime(529): at android.os.Handler.dispatchMessage(Handler.java:99)
08-21 09:13:30.881: E/AndroidRuntime(529): at android.os.Looper.loop(Looper.java:137)
08-21 09:13:30.881: E/AndroidRuntime(529): at android.app.ActivityThread.main(ActivityThread.java:4424)
08-21 09:13:30.881: E/AndroidRuntime(529): at java.lang.reflect.Method.invokeNative(Native Method)
08-21 09:13:30.881: E/AndroidRuntime(529): at java.lang.reflect.Method.invoke(Method.java:511)
08-21 09:13:30.881: E/AndroidRuntime(529): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
08-21 09:13:30.881: E/AndroidRuntime(529): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
08-21 09:13:30.881: E/AndroidRuntime(529): at dalvik.system.NativeStart.main(Native Method)


Here's my androidManifest file:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.active.myApp"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk android:minSdkVersion="15" />

<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".myAppActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>


and my activity file:

package com.active.myApp;

import android.app.Activity;
import android.os.Bundle;
import org.apache.cordova.*;

public class myAppActivity extends DroidGap {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
super.loadUrl("file:///android_asset/www/index.html");
}
}


any help please?

Answer

Add this to your manifest:

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