我刚刚开始学习Android。 我使用PhoneGap制作了一个简单测试的应用程序,但是没有触发deviceready事件。 所以,我读了LogCat并发现了一些错误。
02-24 21:10:18.110: D/dalvikvm(8584): GC_FOR_ALLOC freed 93K, 21% free 9617K/12168K, paused 20ms, total 20ms
02-24 21:10:18.110: I/dalvikvm-heap(8584): Grow heap (frag case) to 12.861MB for 1127536-byte allocation
02-24 21:10:18.130: D/dalvikvm(8584): GC_FOR_ALLOC freed <1K, 20% free 10718K/13272K, paused 18ms, total 18ms
02-24 21:10:18.145: I/webclipboard(8584): clipservice: android.sec.clipboard.ClipboardExManager@4322ffe0
02-24 21:10:18.200: I/CordovaLog(8584): Changing log level to DEBUG(3)
02-24 21:10:18.200: I/CordovaLog(8584): Found preference for useBrowserHistory=true
02-24 21:10:18.200: D/CordovaLog(8584): Found preference for useBrowserHistory=true
02-24 21:10:18.200: I/CordovaLog(8584): Found preference for exit-on-suspend=false
02-24 21:10:18.200: D/CordovaLog(8584): Found preference for exit-on-suspend=false
02-24 21:10:18.205: D/JsMessageQueue(8584): Set native->JS mode to 2
02-24 21:10:18.210: D/DroidGap(8584): DroidGap.init()
02-24 21:10:18.225: D/CordovaWebView(8584): >>> loadUrl(file:///android_asset/www/index.html)
02-24 21:10:18.225: D/PluginManager(8584): init()
02-24 21:10:18.230: D/CordovaWebView(8584): >>> loadUrlNow()
02-24 21:10:18.235: D/WebView(8584): loadUrlImpl: called
02-24 21:10:18.235: D/DroidGap(8584): Resuming the App
02-24 21:10:18.285: D/SoftKeyboardDetect(8584): Ignore this event
02-24 21:10:18.325: V/webkit(8584): BrowserFrame constructor: this=Handler (android.webkit.BrowserFrame) {43227980}
02-24 21:10:18.335: D/webcore(8584): CORE loadUrl: called
02-24 21:10:18.335: D/webkit(8584): Firewall not null
02-24 21:10:18.345: D/webkit(8584): euler: isUrlBlocked = false
02-24 21:10:18.360: D/libEGL(8584): loaded /system/lib/egl/libEGL_mali.so
02-24 21:10:18.370: D/libEGL(8584): loaded /system/lib/egl/libGLESv1_CM_mali.so
02-24 21:10:18.450: D/libEGL(8584): loaded /system/lib/egl/libGLESv2_mali.so
02-24 21:10:18.455: E/(8584): Device driver API match
02-24 21:10:18.455: E/(8584): Device driver API version: 23
02-24 21:10:18.455: E/(8584): User space API version: 23
02-24 21:10:18.455: E/(8584): mali: REVISION=Linux-r3p2-01rel3 BUILD_DATE=Fri Nov 29 14:18:37 KST 2013
02-24 21:10:18.535: D/OpenGLRenderer(8584): Enabling debug mode 0
02-24 21:10:18.540: D/WebView(8584): onSizeChanged - w:720 h:1230
02-24 21:10:18.570: D/DroidGap(8584): onMessage(onPageStarted,file:///android_asset/www/index.html)
02-24 21:10:18.570: D/SoftKeyboardDetect(8584): Ignore this event
02-24 21:10:19.005: D/CordovaLog(8584): onload event
02-24 21:10:19.005: D/CordovaLog(8584): file:///android_asset/www/index.html: Line 50 : onload event
02-24 21:10:19.005: I/Web Console(8584): onload event:50
02-24 21:10:19.010: I/GATE(8584): <GATE-M>DEV_ACTION_COMPLETED</GATE-M>
02-24 21:10:19.010: D/Cordova(8584): onPageFinished(file:///android_asset/www/index.html)
02-24 21:10:19.010: D/WebView(8584): loadUrlImpl: called
02-24 21:10:19.010: D/webcore(8584): CORE loadUrl: called
02-24 21:10:19.010: D/webkit(8584): Firewall not null
02-24 21:10:19.010: D/webkit(8584): euler: isUrlBlocked = false
02-24 21:10:19.015: D/DroidGap(8584): onMessage(onNativeReady,null)
02-24 21:10:19.015: D/DroidGap(8584): onMessage(onPageFinished,file:///android_asset/www/index.html)
02-24 21:10:19.060: E/SQLiteLog(8584): (14) cannot open file at line 32516 of [00bb9c9ce4]
02-24 21:10:19.060: E/SQLiteLog(8584): (14) os_unix.c:32516: (2) open(/CachedGeoposition.db) -
02-24 21:10:19.060: D/WebKit(8584): ERROR:
02-24 21:10:19.060: D/WebKit(8584): SQLite database failed to load from /CachedGeoposition.db
02-24 21:10:19.060: D/WebKit(8584): Cause - unable to open database file
02-24 21:10:19.060: D/WebKit(8584): external/webkit/Source/WebCore/platform/sql/SQLiteDatabase.cpp(71) : bool WebCore::SQLiteDatabase::open(const WTF::String&, bool)
02-24 21:10:21.015: D/DroidGap(8584): onMessage(spinner,stop)
02-24 21:10:21.050: D/TilesManager(8584): Starting TG #0, 0x4225c580
02-24 21:10:21.050: D/TilesManager(8584): new EGLContext from framework: 421dcb88
02-24 21:10:21.050: D/GLWebViewState(8584): Reinit shader
02-24 21:10:21.050: D/GLWebViewState(8584): Reinit transferQueue
我认为设备驱动程序API匹配错误是个问题..
这是 Manifest.xml 文件。
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.ex5"
android:versionCode="1"
android:versionName="1.0" >
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:resizeable="true"
android:anyDensity="true"/>
<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.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.RECORD_VIDEO"/>
<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" />
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.ex5.MainActivity"
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>
index.html 文件
<!DOCTYPE html>
<html>
<head>
<title>index</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<script type="text/javascript" src="cordova-2.2.0.js"></script>
<script type="text/javascript">
function onDeviceReady() {
console.log("deviceready");
alert('test');
}
function init() {
console.log('onload event');
document.addEventListener("deviceready", onDeviceReady, false);
}
</script>
</head>
<body onload="init();">
</body>
</html>
MainActivity.java 文件
package com.example.ex5;
import org.apache.cordova.DroidGap;
import android.os.Bundle;
import android.view.Menu;
public class MainActivity extends DroidGap {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/index.html");
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
我在Galaxy S3上测试的Android版本是4.3。 但是,测试Galaxy S2 Android版本4.0.3运行良好。
我不知道我的来源或Galaxy S3设备或Android版本有什么问题。
请让我知道我应该解决的问题。
答案 0 :(得分:0)
这个错误很有趣!我今天在S3上重置了usb密钥,之后又出现了错误。当我试图运行我的另一个应用程序时,错误消失了:D