gpt4 book ai didi

安卓 Logcat 错误

转载 作者:行者123 更新时间:2023-11-29 15:29:15 24 4
gpt4 key购买 nike

谁能告诉我这个运行时错误背后的原因是什么?

java.lang.RuntimeException: Unable to instantiate activity ComponentInfo Caused by: java.lang.InstantiationException

我正在尝试按照 Joe Blough 在 GitHub 上的 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();
}

最佳答案

实例化异常:

Thrown when a program attempts to access a constructor which is not accessible from the location where the reference is made.

来自 The Docs

我不能说出究竟是什么导致了您的异常,但是如果您发布 Logcat 的全部错误以及发生异常的行,或者发生异常的代码块,这可能会有所帮助。

关于安卓 Logcat 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8570310/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com