我从 Eclipse 新的 android 应用程序向导制作了一个简单的应用程序。在这一点上,一切正常。
将pdfnet.res添加到项目后,程序无法启动不崩溃。错误是
10-20 15:28:41.035: E/AndroidRuntime(16287): FATAL EXCEPTION: main
10-20 15:28:41.035: E/AndroidRuntime(16287): Process: at.aec.solutions.pdftronviewer, PID: 16287
10-20 15:28:41.035: E/AndroidRuntime(16287): java.lang.RuntimeException: Unable to start activity ComponentInfo{at.aec.solutions.pdftronviewer/at.aec.solutions.pdftronviewer.MainActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x7f030000
10-20 15:28:41.035: E/AndroidRuntime(16287): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
10-20 15:28:41.035: E/AndroidRuntime(16287): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
10-20 15:28:41.035: E/AndroidRuntime(16287): at android.app.ActivityThread.access$800(ActivityThread.java:135)
10-20 15:28:41.035: E/AndroidRuntime(16287): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
10-20 15:28:41.035: E/AndroidRuntime(16287): at android.os.Handler.dispatchMessage(Handler.java:102)
10-20 15:28:41.035: E/AndroidRuntime(16287): at android.os.Looper.loop(Looper.java:136)
10-20 15:28:41.035: E/AndroidRuntime(16287): at android.app.ActivityThread.main(ActivityThread.java:5001)
10-20 15:28:41.035: E/AndroidRuntime(16287): at java.lang.reflect.Method.invokeNative(Native Method)
10-20 15:28:41.035: E/AndroidRuntime(16287): at java.lang.reflect.Method.invoke(Method.java:515)
10-20 15:28:41.035: E/AndroidRuntime(16287): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
10-20 15:28:41.035: E/AndroidRuntime(16287): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
10-20 15:28:41.035: E/AndroidRuntime(16287): at dalvik.system.NativeStart.main(Native Method)
10-20 15:28:41.035: E/AndroidRuntime(16287): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f030000
10-20 15:28:41.035: E/AndroidRuntime(16287): at android.content.res.Resources.getValue(Resources.java:1123)
10-20 15:28:41.035: E/AndroidRuntime(16287): at android.content.res.Resources.loadXmlResourceParser(Resources.java:2309)
10-20 15:28:41.035: E/AndroidRuntime(16287): at android.content.res.Resources.getLayout(Resources.java:939)
10-20 15:28:41.035: E/AndroidRuntime(16287): at android.view.LayoutInflater.inflate(LayoutInflater.java:395)
10-20 15:28:41.035: E/AndroidRuntime(16287): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
10-20 15:28:41.035: E/AndroidRuntime(16287): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
10-20 15:28:41.035: E/AndroidRuntime(16287): at android.app.Activity.setContentView(Activity.java:1929)
10-20 15:28:41.035: E/AndroidRuntime(16287): at at.aec.solutions.pdftronviewer.MainActivity.onCreate(MainActivity.java:13)
10-20 15:28:41.035: E/AndroidRuntime(16287): at android.app.Activity.performCreate(Activity.java:5231)
10-20 15:28:41.035: E/AndroidRuntime(16287): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
10-20 15:28:41.035: E/AndroidRuntime(16287): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
10-20 15:28:41.035: E/AndroidRuntime(16287): ... 11 more
但我没有改变项目本身的任何东西。
这是清单:
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="21" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".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>
顺便说一句,任何其他原始资源都可以正常工作。只有 pdfnet.res 有问题。正如入门指南中所说,没有这个 res 文件我什么都做不了。
VIsual Studio 2005 可能有问题吗?我正在使用 Eclipse 进行 Android 开发,但扩展名 .res 与 VS 2005 相关联。
在此先感谢,卢卡斯