Android Logcat错误
任何人都可以告诉我这个运行时错误背后的原因是什么?
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo Caused by: java.lang.InstantiationException
我正在尝试按照 GitHub 上的 Joe Blough 的 Android PDF 查看器库制作一个 PDF 阅读器应用程序: https ://github.com/jblough/Android-Pdf-Viewer-Library。我遵循了一切,最终出现了这个错误。
12-20 03:43:14.037: E/AndroidRuntime(29822): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.traininghandouts.app/com.traininghandouts.app.PdfViewer}: java.lang.InstantiationException: com.traininghandouts.app.PdfViewer
12-20 03:43:14.037: E/AndroidRuntime(29822): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
12-20 03:43:14.037: E/AndroidRuntime(29822): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
12-20 03:43:14.037: E/AndroidRuntime(29822): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
12-20 03:43:14.037: E/AndroidRuntime(29822): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
12-20 03:43:14.037: E/AndroidRuntime(29822): at android.os.Handler.dispatchMessage(Handler.java:99)
12-20 03:43:14.037: E/AndroidRuntime(29822): at android.os.Looper.loop(Looper.java:123)
12-20 03:43:14.037: E/AndroidRuntime(29822): at android.app.ActivityThread.main(ActivityThread.java:4627)
12-20 03:43:14.037: E/AndroidRuntime(29822): at java.lang.reflect.Method.invokeNative(Native Method)
12-20 03:43:14.037: E/AndroidRuntime(29822): at java.lang.reflect.Method.invoke(Method.java:521)
12-20 03:43:14.037: E/AndroidRuntime(29822): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
12-20 03:43:14.037: E/AndroidRuntime(29822): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
12-20 03:43:14.037: E/AndroidRuntime(29822): at dalvik.system.NativeStart.main(Native Method)
12-20 03:43:14.037: E/AndroidRuntime(29822): Caused by: java.lang.InstantiationException: com.traininghandouts.app.PdfViewer
12-20 03:43:14.037: E/AndroidRuntime(29822): at java.lang.Class.newInstanceImpl(Native Method)
12-20 03:43:14.037: E/AndroidRuntime(29822): at java.lang.Class.newInstance(Class.java:1429)
12-20 03:43:14.037: E/AndroidRuntime(29822): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
12-20 03:43:14.037: E/AndroidRuntime(29822): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
12-20 03:43:14.037: E/AndroidRuntime(29822): ... 11 more
这是我的代码:
try{
String path = "mnt/sdcard/android-android-ui-design-patterns.pdf";
Intent intent = new Intent(this, PdfViewer.class);
intent.putExtra(PdfViewerActivity.EXTRA_PDFFILENAME, path);
startActivity(intent);
}catch(Exception e){
e.printStackTrace();
}
Anyone can tell me what's the reason behind this run-time error?
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo Caused by: java.lang.InstantiationException
i'm trying to make a PDF reader app following Joe Blough's Android PDF Viewer library at GitHub: https://github.com/jblough/Android-Pdf-Viewer-Library. I followed everything and I end up with this error.
12-20 03:43:14.037: E/AndroidRuntime(29822): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.traininghandouts.app/com.traininghandouts.app.PdfViewer}: java.lang.InstantiationException: com.traininghandouts.app.PdfViewer
12-20 03:43:14.037: E/AndroidRuntime(29822): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
12-20 03:43:14.037: E/AndroidRuntime(29822): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
12-20 03:43:14.037: E/AndroidRuntime(29822): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
12-20 03:43:14.037: E/AndroidRuntime(29822): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
12-20 03:43:14.037: E/AndroidRuntime(29822): at android.os.Handler.dispatchMessage(Handler.java:99)
12-20 03:43:14.037: E/AndroidRuntime(29822): at android.os.Looper.loop(Looper.java:123)
12-20 03:43:14.037: E/AndroidRuntime(29822): at android.app.ActivityThread.main(ActivityThread.java:4627)
12-20 03:43:14.037: E/AndroidRuntime(29822): at java.lang.reflect.Method.invokeNative(Native Method)
12-20 03:43:14.037: E/AndroidRuntime(29822): at java.lang.reflect.Method.invoke(Method.java:521)
12-20 03:43:14.037: E/AndroidRuntime(29822): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
12-20 03:43:14.037: E/AndroidRuntime(29822): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
12-20 03:43:14.037: E/AndroidRuntime(29822): at dalvik.system.NativeStart.main(Native Method)
12-20 03:43:14.037: E/AndroidRuntime(29822): Caused by: java.lang.InstantiationException: com.traininghandouts.app.PdfViewer
12-20 03:43:14.037: E/AndroidRuntime(29822): at java.lang.Class.newInstanceImpl(Native Method)
12-20 03:43:14.037: E/AndroidRuntime(29822): at java.lang.Class.newInstance(Class.java:1429)
12-20 03:43:14.037: E/AndroidRuntime(29822): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
12-20 03:43:14.037: E/AndroidRuntime(29822): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
12-20 03:43:14.037: E/AndroidRuntime(29822): ... 11 more
here's my code:
try{
String path = "mnt/sdcard/android-android-ui-design-patterns.pdf";
Intent intent = new Intent(this, PdfViewer.class);
intent.putExtra(PdfViewerActivity.EXTRA_PDFFILENAME, path);
startActivity(intent);
}catch(Exception e){
e.printStackTrace();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
实例化异常:
那来自 The Docs
我不能说到底是什么导致了你的异常,但是如果您发布 Logcat 中的整个错误以及发生异常的行,或者发生异常的代码块,这可能会有所帮助。
InstantiationException:
That came from The Docs
I can't say what EXACTLY caused your exception, but if you post the entirety of the error from Logcat and the line where the exception happens, or a block of code where the exception happens, that may help a little more.