- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试实现一个 pdf 查看器,该应用程序会检测存储在 sd 卡中的 PDF,如图所示。
http://img225.imageshack.us/img225/3852/pdfs.png
但是当我点击任何文件来查看它时......错误。
这是 LOGCAT:
06-28 07:32:46.963: WARN/dalvikvm(330): Unable to resolve superclass of Lcom/example/trypdf/Second; (496)
06-28 07:32:46.983: WARN/dalvikvm(330): Link of class 'Lcom/example/trypdf/Second;' failed
06-28 07:32:46.983: ERROR/dalvikvm(330): Could not find class 'com.example.trypdf.Second', referenced from method com.example.trypdf.PDFViewerActivity.openPdfIntent
06-28 07:32:47.013: WARN/dalvikvm(330): VFY: unable to resolve const-class 419 (Lcom/example/trypdf/Second;) in Lcom/example/trypdf/PDFViewerActivity;
06-28 07:32:47.013: DEBUG/dalvikvm(330): VFY: replacing opcode 0x1c at 0x0002
06-28 07:32:47.013: DEBUG/dalvikvm(330): VFY: dead code 0x0004-000e in Lcom/example/trypdf/PDFViewerActivity;.openPdfIntent (Ljava/lang/String;)V
06-28 07:32:47.373: INFO/ActivityManager(59): Displayed activity com.example.trypdf/.PDFViewerActivity: 1665 ms (total 1665 ms)
06-28 07:32:52.593: DEBUG/dalvikvm(131): GC_EXPLICIT freed 1336 objects / 74064 bytes in 149ms
06-28 07:33:28.634: DEBUG/SntpClient(59): request time failed: java.net.SocketException: Address family not supported by protocol
06-28 07:33:55.655: DEBUG/AndroidRuntime(330): Shutting down VM
06-28 07:33:55.663: WARN/dalvikvm(330): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
06-28 07:33:55.684: ERROR/AndroidRuntime(330): FATAL EXCEPTION: main
06-28 07:33:55.684: ERROR/AndroidRuntime(330): java.lang.NoClassDefFoundError: com.example.trypdf.Second
06-28 07:33:55.684: ERROR/AndroidRuntime(330): at com.example.trypdf.PDFViewerActivity.openPdfIntent(PDFViewerActivity.java:46)
06-28 07:33:55.684: ERROR/AndroidRuntime(330): at com.example.trypdf.PDFViewerActivity.onListItemClick(PDFViewerActivity.java:41)
06-28 07:33:55.684: ERROR/AndroidRuntime(330): at android.app.ListActivity$2.onItemClick(ListActivity.java:321)
06-28 07:33:55.684: ERROR/AndroidRuntime(330): at android.widget.AdapterView.performItemClick(AdapterView.java:284)
06-28 07:33:55.684: ERROR/AndroidRuntime(330): at android.widget.ListView.performItemClick(ListView.java:3382)
06-28 07:33:55.684: ERROR/AndroidRuntime(330): at android.widget.AbsListView$PerformClick.run(AbsListView.java:1696)
06-28 07:33:55.684: ERROR/AndroidRuntime(330): at android.os.Handler.handleCallback(Handler.java:587)
06-28 07:33:55.684: ERROR/AndroidRuntime(330): at android.os.Handler.dispatchMessage(Handler.java:92)
06-28 07:33:55.684: ERROR/AndroidRuntime(330): at android.os.Looper.loop(Looper.java:123)
06-28 07:33:55.684: ERROR/AndroidRuntime(330): at android.app.ActivityThread.main(ActivityThread.java:4627)
06-28 07:33:55.684: ERROR/AndroidRuntime(330): at java.lang.reflect.Method.invokeNative(Native Method)
06-28 07:33:55.684: ERROR/AndroidRuntime(330): at java.lang.reflect.Method.invoke(Method.java:521)
06-28 07:33:55.684: ERROR/AndroidRuntime(330): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
06-28 07:33:55.684: ERROR/AndroidRuntime(330): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
06-28 07:33:55.684: ERROR/AndroidRuntime(330): at dalvik.system.NativeStart.main(Native Method)
06-28 07:33:55.693: WARN/ActivityManager(59): Force finishing activity com.example.trypdf/.PDFViewerActivity
06-28 07:33:56.213: WARN/ActivityManager(59): Activity pause timeout for HistoryRecord{44fe47a0 com.example.trypdf/.PDFViewerActivity}
06-28 07:32:46.983: ERROR/dalvikvm(330): Could not find class 'com.example.trypdf.Second', referenced from method com.example.trypdf.PDFViewerActivity.openPdfIntent
06-28 07:33:55.684: ERROR/AndroidRuntime(330): java.lang.NoClassDefFoundError: com.example.trypdf.Second
package com.example.trypdf;
import java.io.File;
import java.io.FilenameFilter;
import com.example.trypdf.Second;
import net.sf.andpdf.pdfviewer.PdfViewerActivity;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Environment;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class PDFViewerActivity extends ListActivity {
String[] pdflist;
File[] imagelist;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.main);
File images = Environment.getExternalStorageDirectory();
imagelist = images.listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return ((name.endsWith(".pdf")));
}
});
pdflist = new String[imagelist.length];
for (int i = 0; i < imagelist.length; i++) {
pdflist[i] = imagelist[i].getName();
}
this.setListAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, pdflist));
}
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
String path = imagelist[(int) id].getAbsolutePath();
openPdfIntent(path);
}
private void openPdfIntent(String path) {
try {
final Intent intent = new Intent(PDFViewerActivity.this, Second.class);
intent.putExtra(PdfViewerActivity.EXTRA_PDFFILENAME, path);
startActivity(intent);
} catch (Exception e) {
e.printStackTrace();
}
}
}
package com.example.trypdf;
import net.sf.andpdf.pdfviewer.PdfViewerActivity;
import net.sf.andpdf.pdfviewer.R;
import net.sf.andpdf.pdfviewer.R.drawable;
import net.sf.andpdf.pdfviewer.R.id;
import net.sf.andpdf.pdfviewer.R.layout;
import android.os.Bundle;
public class Second extends PdfViewerActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
}
public int getPreviousPageImageResource() {
return R.drawable.left_arrow;
}
public int getNextPageImageResource() {
return R.drawable.right_arrow;
}
public int getZoomInImageResource() {
return R.drawable.zoom_in;
}
public int getZoomOutImageResource() {
return R.drawable.zoom_out;
}
public int getPdfPasswordLayoutResource() {
return R.layout.pdf_file_password;
}
public int getPdfPageNumberResource() {
return R.layout.dialog_pagenumber;
}
public int getPdfPasswordEditField() {
return R.id.etPassword;
}
public int getPdfPasswordOkButton() {
return R.id.btOK;
}
public int getPdfPasswordExitButton() {
return R.id.btExit;
}
public int getPdfPageNumberEditField() {
return R.id.pagenum_edit;
}
}
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.trypdf"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name="com.example.trypdf.PDFViewerActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.trypdf.Second"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
最佳答案
要解决此问题,您需要:
关于android - java.lang.NoClassDefFoundError,而打开pdf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11257064/
我一直在尝试在我的代码中使用 Jar 文件作为库,并且它编译得很好。但是,在运行时,我不断收到 NoClassDefFoundError信息。为什么会这样?我也在编译路径和运行时路径中包含了 Jar
关于Apache-Kafka messaging queue . 我已经从 Kafka 下载页面下载了 Apache Kafka。我已将其提取到 /opt/apache/installed/kafka
我正在尝试使用 Apache DefaultHttpClient 来执行 JSON POST 请求,当我尝试实例化它时它给我一个 NoClassDefFound 错误。 HttpClient clie
当我在模拟器(Nexus One API 22)上测试我的应用程序时,它运行顺利,没有失败。然而,当我在自己的个人手机(三星 Galaxy S5,Android 版本 5.0)上测试该应用程序时,它崩
我需要在python中使用java代码来减少,所以我选择了Jython。一段时间后,我设法弄清楚了如何运行我的代码,但我遇到了最奇怪的事情。当我写作时 from vohmm.corpus import
这是我的mybatis配置。这是我的pom.xml。。当我运行项目时,它显示了错误的原因:org/mybatis/spring/mapper/MapperScannerConfigurer.有没有人能
所以我正在尝试构建一个简单的gradle应用,当我运行它时, geb.ConfigurationLoader$UnableToLoadException: Unable to load configu
假设我有一个主类应用程序,它使用 URLClassLoader 加载子目录 plugins 中的所有 jar: public class App(){ public static void m
我在尝试运行 Netbeans (7.2) 时遇到一个反复出现的错误,上次遇到它时,我发现某个地方可以将所有文件移动到一个新项目。这可能会奏效,但我的项目的规模让这很麻烦。这是踪迹... Except
这个问题已经有答案了: Including all the jars in a directory within the Java classpath (25 个回答) 已关闭 6 年前。 我得到一个
在这里,我正在下载网页源代码,然后将其存储在文本文件中。然后我读取该文件并将其与正则表达式匹配以搜索特定字符串。 没有编译器错误。 Exception in thread "main" java.la
我正在一个“大”的 Maven/Java 项目中工作,无法理解运行应用程序时遇到的错误(它编译正常)。我得到的错误代码是: java.lang.NoClassDefFoundError: Could
对于学校的作业,我需要创建一个类 Blender 来实现一些预定义的东西。我收到了一个 JAR 文件 imagecompositor.jar,它可以完成所有操作并使用 Blender 类。 JAR 文
我遇到了一个问题,即抛出 NoClasDefFoundError。这让我感到困惑,因为我正在使用接口(interface),并且没有类定义应该可用。我已经阅读了一些指向类路径的帖子,但我不认为这是这里
我正在使用 hibernate,在使用 hibernate Connection 时出现如下错误 java.lang.NoClassDefFoundError: Could not initializ
我有一个使用 SubVersion 的 Android 项目。我使用 Subclipse 将项目导入我的 Eclipse Wordspace。 现在我有一个问题: java.lang.NoClass
我需要编译一个外部 java 文件(比如 a.java)。这是我为此编写的代码。 (字符串路径包含java和class文件的路径) command[0] = "javac"; comm
我正在尝试运行一个基本的 Hibernate 程序。当我运行它时,出现以下错误 java.lang.NoClassDefFoundError: org/jboss/logging/BasicLogge
标题:Eclipse插件开发由于java.lang.NoClassDefFoundError无法实例化类: 试图构建一个 eclipse 插件,但遇到一些运行时错误.. 我知道这是由于代码所依赖的类文
我是新手,我无法让它工作......:/ 我的 build.sbt: val apacheDeps = Seq( "commons-validator" % "commons-validator"
我是一名优秀的程序员,十分优秀!