我正在使用Eclipse在Mac OSX 10.7.3中使用PhoneGap 1.4应用程序构建Android。这是一个非常简单的应用程序,html很简单,没有JS。
我得到了致命的意外,这是logcat:
03-08 15:04:29.920: E/AndroidRuntime(594): FATAL EXCEPTION: main
03-08 15:04:29.920: E/AndroidRuntime(594): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myphone.test/com.myphone.test.MyPhone}: android.content.res.Resources$NotFoundException: Resource ID #0x0
03-08 15:04:29.920: E/AndroidRuntime(594): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
03-08 15:04:29.920: E/AndroidRuntime(594): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
03-08 15:04:29.920: E/AndroidRuntime(594): at android.app.ActivityThread.access$600(ActivityThread.java:123)
03-08 15:04:29.920: E/AndroidRuntime(594): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
03-08 15:04:29.920: E/AndroidRuntime(594): at android.os.Handler.dispatchMessage(Handler.java:99)
03-08 15:04:29.920: E/AndroidRuntime(594): at android.os.Looper.loop(Looper.java:137)
03-08 15:04:29.920: E/AndroidRuntime(594): at android.app.ActivityThread.main(ActivityThread.java:4424)
03-08 15:04:29.920: E/AndroidRuntime(594): at java.lang.reflect.Method.invokeNative(Native Method)
03-08 15:04:29.920: E/AndroidRuntime(594): at java.lang.reflect.Method.invoke(Method.java:511)
03-08 15:04:29.920: E/AndroidRuntime(594): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
03-08 15:04:29.920: E/AndroidRuntime(594): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-08 15:04:29.920: E/AndroidRuntime(594): at dalvik.system.NativeStart.main(Native Method)
03-08 15:04:29.920: E/AndroidRuntime(594): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x0
03-08 15:04:29.920: E/AndroidRuntime(594): at android.content.res.Resources.getValue(Resources.java:1019)
03-08 15:04:29.920: E/AndroidRuntime(594): at android.content.res.Resources.loadXmlResourceParser(Resources.java:2107)
03-08 15:04:29.920: E/AndroidRuntime(594): at android.content.res.Resources.getXml(Resources.java:907)
03-08 15:04:29.920: E/AndroidRuntime(594): at com.phonegap.api.PluginManager.loadPlugins(PluginManager.java:82)
03-08 15:04:29.920: E/AndroidRuntime(594): at com.phonegap.api.PluginManager.<init>(PluginManager.java:62)
03-08 15:04:29.920: E/AndroidRuntime(594): at com.phonegap.DroidGap$1.run(DroidGap.java:518)
03-08 15:04:29.920: E/AndroidRuntime(594): at android.app.Activity.runOnUiThread(Activity.java:4170)
03-08 15:04:29.920: E/AndroidRuntime(594): at com.phonegap.DroidGap.loadUrlIntoView(DroidGap.java:494)
03-08 15:04:29.920: E/AndroidRuntime(594): at com.phonegap.DroidGap.loadUrl(DroidGap.java:460)
03-08 15:04:29.920: E/AndroidRuntime(594): at com.myphone.test.MyPhone.onCreate(MyPhone.java:11)
03-08 15:04:29.920: E/AndroidRuntime(594): at android.app.Activity.performCreate(Activity.java:4465)
03-08 15:04:29.920: E/AndroidRuntime(594): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
03-08 15:04:29.920: E/AndroidRuntime(594): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
03-08 15:04:29.920: E/AndroidRuntime(594): ... 11 more
和清单文件:
<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.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" />
<uses-sdk android:minSdkVersion="8" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".MyPhone"
android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.phonegap.DroidGap"
android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden">
<intent-filter> </intent-filter>
</activity>
</application>
如果有人可以帮助我,那就太好了:)预先感谢
最佳答案
您将得到一个ResourceNotFoundException
,确保您不尝试加载不存在的资源。