安卓 Logcat 错误

标签 android logcat android-logcat

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

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/

相关文章:

android - 如何从接收方的 gcm 获取 messageId

安卓应用 : logging on the device

android - 如何保存 logcat 消息

Android 如何将 emoji 转换成 Logcat 打印?

android - Google Play 控制台新的应用程序签名过程 : Do we need . pepk 和 .keystore 文件每次我们发布应用程序时?

java - 使用Gson解析不同字段的子类

android - 如何在 Android 上使用 Kotlin 将 FrameLayout 替换为 fragment

android - 在 Android Activity 中出现 nullPointerException,但不知道原因以及如何解决

android - 使用 Android API 的 bundle 显示 "java.lang.UnsatisfiedLinkError: android.util.Log.println_native"

android - 如何在通过命令行或直接通过存储卡部署独立签名的 APK 时通过 logcat 获得响应?