我想使用手机间隙开发混合Android移动应用程序。
第一 我已经开发了响应式Web应用程序,它在Web浏览器中运行良好。也使用Ripple模拟器插件(chrome浏览器)在android中进行模拟。
立即
我希望它转换为ANDROID MobileAPP,所以我选择了phonegap。
我已经通过一些基本教程并将所有css / js / images / etc文件夹放在asset-> www->文件夹和
在index.html中我引用cordova.js
我在java文件中更改为loadurl(file:/// ......... index.html)
并且结果是......
模拟器显示一条警告消息..“很遗憾'appname'已停止工作...... ”
并且logcat错误是:我不确定它是什么意思...所以需要帮助。如果我在移动设备上看到我的应用程序,我感觉很棒。
注意:“hello world”index.html工作正常,但不是我自己的index.html 并且..我使用了角度js,less.js(less.js被编译得很好我可以看看是否来自日志)
-> 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
}
更新:执行以下问题解决问题......
与服务器的连接失败。可以通过增加超时来解决...
<preference name="load-url-timeout" value="60000" />
将其粘贴到config.xml或
中让你的index.html看起来像这样
<!doctype html>
<html>
<head>
<title>tittle</title>
<script>
window.location='./main.html';
</script>
<body>
</body>
</html>
之前将index.html内容移至main.html ...
和另一个( java.lang.RuntimeException:接收广播Intent 时出错)错误可以通过正确定义权限来处理
<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. 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>
答案 0 :(得分:3)
该行
Neither user 10051 nor current process has android.permission.ACCESS_NETWORK_STATE
指出,您的应用未获得此权限。
检查您的AndroidManifest.xml
并添加
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
LG
fastrde