Reputation: 173
I want to devlop a hybrid Android mobile app using phone gap.
first: I already developed responsive web application which is working fine in web browser.Also used Ripple emulator addon(chrome browser) to simulate in android .
Now
I want it to be converted to ANDROID MobileAPP ,so I chose phonegap.
I have gone thru some basic tutorials and put all css/ js / images/ etc folders in asset->www-> folder and
In index.html i refer cordova.js
I made changes in java file to loadurl(file:/// .........index.html)
and heres the result...
the emulator shows a alert message.."Unfortunately 'appname' has stopped working...."
and the logcat errors are: I m not sure what it points...so need help on this. I feel great if i saw my app wrking on mobile device..
Note: "hello world" index.html works fine,but not my own index.html and..I used angular js, less.js(less.js is compiled fine I coudl see if from the logs)
-> 11-09 13:06:37.768: E/CordovaWebView(1549): CordovaWebView: TIMEOUT ERROR!
-> 11-09 13:06:37.778: D/Cordova(1549): CordovaWebViewClient.onReceivedError:
Error code=-6 Description=The connection to the server was unsuccessful. URL=file:///android_asset/www/index.html
-> 11-09 13:06:37.778: D/CordovaActivity(1549): onMessage(onReceivedError,{"errorCode":-6,"url":"file:\/\/\/android_asset\/www\/index.html","description":"The connection to the server was unsuccessful."})
-> 11-09 13:06:38.128: I/Choreographer(1549): Skipped 78 frames! The application may be doing too much work on its main thread.
-> 11-09 13:06:38.128: D/SoftKeyboardDetect(1549): Ignore this event
-> 11-09 13:06:38.528: I/Choreographer(1549): Skipped 68 frames! The application may be doing too much work on its main thread.
-> 11-09 13:06:40.118: D/AndroidRuntime(1549): Shutting down VM
-> 11-09 13:06:40.118: W/dalvikvm(1549): threadid=1: thread exiting with uncaught exception (group=0xb3a3bb90)
-> 11-09 13:06:40.148: E/AndroidRuntime(1549): FATAL EXCEPTION: main
-> 11-09 13:06:40.148: E/AndroidRuntime(1549): Process: com.example.test, PID: 1549
-> 11-09 13:06:40.148: E/AndroidRuntime(1549): java.lang.RuntimeException: Error receiving broadcast Intent { act=android.net.conn.CONNECTIVITY_CHANGE flg=0x4000010 (has extras) } in org.apache.cordova.NetworkManager$1@b3e0a2e0
-> 11-09 13:06:40.148: E/AndroidRuntime(1549): at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:778)
-> 11-09 13:06:40.148: E/AndroidRuntime(1549): at android.os.Handler.handleCallback(Handler.java:733)
-> 11-09 13:06:40.148: E/AndroidRuntime(1549): at android.os.Handler.dispatchMessage(Handler.java:95)
-> 11-09 13:06:40.148: E/AndroidRuntime(1549): at android.os.Looper.loop(Looper.java:137)
-> 11-09 13:06:40.148: E/AndroidRuntime(1549): at android.app.ActivityThread.main(ActivityThread.java:4998)
-> 11-09 13:06:40.148: E/AndroidRuntime(1549): at java.lang.reflect.Method.invokeNative(Native Method)
-> 11-09 13:06:40.148: E/AndroidRuntime(1549): at java.lang.reflect.Method.invoke(Method.java:515)
-> 11-09 13:06:40.148: E/AndroidRuntime(1549): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
-> 11-09 13:06:40.148: E/AndroidRuntime(1549): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
-> 11-09 13:06:40.148: E/AndroidRuntime(1549): at dalvik.system.NativeStart.main(Native Method)
-> 11-09 13:06:40.148: E/AndroidRuntime(1549): Caused by: java.lang.SecurityException: ConnectivityService: Neither user 10051 nor current process has android.permission.ACCESS_NETWORK_STATE.
-> 11-09 13:06:40.148: E/AndroidRuntime(1549): at android.os.Parcel.readException(Parcel.java:1461)
-> 11-09 13:06:40.148: E/AndroidRuntime(1549): at android.os.Parcel.readException(Parcel.java:1415)
-> 11-09 13:06:40.148: E/AndroidRuntime(1549): at android.net.IConnectivityManager$Stub$Proxy.getActiveNetworkInfo(IConnectivityManager.java:813)
-> 11-09 13:06:40.148: E/AndroidRuntime(1549): at android.net.ConnectivityManager.getActiveNetworkInfo(ConnectivityManager.java:560)
-> 11-09 13:06:40.148: E/AndroidRuntime(1549): at org.apache.cordova.NetworkManager$1.onReceive(NetworkManager.java:107)
-> 11-09 13:06:40.148: E/AndroidRuntime(1549): at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:768)
-> 11-09 13:06:40.148: E/AndroidRuntime(1549): ... 9 more
-> 11-09 13:06:40.188: W/System.err(1549): java.lang.SecurityException: ConnectivityService: Neither user 10051 nor current process has android.permission.ACCESS_NETWORK_STATE.
-> 11-09 13:06:40.248: W/System.err(1549): at android.os.Parcel.readException(Parcel.java:1461)
-> 11-09 13:06:40.248: W/System.err(1549): at android.os.Parcel.readException(Parcel.java:1415)
-> 11-09 13:06:40.258: W/System.err(1549): at android.net.IConnectivityManager$Stub$Proxy.getActiveNetworkInfo(IConnectivityManager.java:813)
-> 11-09 13:06:40.258: W/System.err(1549): at android.net.ConnectivityManager.getActiveNetworkInfo(ConnectivityManager.java:560)
-> 11-09 13:06:40.258: W/System.err(1549): at org.apache.cordova.NetworkManager.execute(NetworkManager.java:127)
-> 11-09 13:06:40.258: W/System.err(1549): at org.apache.cordova.api.CordovaPlugin.execute(CordovaPlugin.java:66)
-> 11-09 13:06:40.258: W/System.err(1549): at org.apache.cordova.api.PluginManager.exec(PluginManager.java:215)
-> 11-09 13:06:40.268: W/System.err(1549): at org.apache.cordova.ExposedJsApi.exec(ExposedJsApi.java:51)
-> 11-09 13:06:40.268: W/System.err(1549): at com.android.org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
-> 11-09 13:06:40.268: W/System.err(1549): at com.android.org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:27)
-> 11-09 13:06:40.268: W/System.err(1549): at android.os.Handler.dispatchMessage(Handler.java:102)
-> 11-09 13:06:40.268: W/System.err(1549): at android.os.Looper.loop(Looper.java:137)
-> 11-09 13:06:40.358: W/System.err(1549): at android.os.HandlerThread.run(HandlerThread.java:61)
-> 11-09 13:06:58.018: I/Process(1549): Sending signal. PID: 1549 SIG: 9
}
Update: doing the follwing steps resolved by issues.....
connection to the server was unsuccessful. can be resolved by increasing timeout...
<preference name="load-url-timeout" value="60000" />
paste it in config.xml or
make ur index.html look like this
<!doctype html>
<html>
<head>
<title>tittle</title>
<script>
window.location='./main.html';
</script>
<body>
</body>
</html>
and before that move index.html content to main.html...
and the other (java.lang.RuntimeException: Error receiving broadcast Intent )errors can be handler by properly defining permissions
<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.activity names in manifest.xml...
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale"
android:name="com.example.test.MainActivity" // u can use yours..ofcourse its //automatically generated by eclipse IDE
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>
Upvotes: 1
Views: 1589
Reputation: 1525
The line
Neither user 10051 nor current process has android.permission.ACCESS_NETWORK_STATE
points out, that your app doesn't get this permission.
Check your AndroidManifest.xml
and add the line
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
lg
fastrde
Upvotes: 3