我从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链接。
提前致谢,Lukas
答案 0 :(得分:0)
你用什么来编译项目? Visual Studio 2005?
您是否可以尝试使用Eclipse(https://developer.android.com/sdk/index.html?hl=i)或Android Studio来查看资源文件是否仍有问题?
确保将其放入相应的文件夹(即res / raw)并将其命名为:
PDFNet.initialize(this, R.raw.pdfnet);