简体   繁体   English

致命异常:main java.lang.NoClassDefFoundError:外部library.jar.class Android Studio

[英]FATAL EXCEPTION: main java.lang.NoClassDefFoundError: external library.jar.class Android studio

I am developing an android app which process speech and I have speech basic project (dependency for android project) ready on JAVA so I compiled JAVA project in eclipse in JAVA 7 compiler and exported that java project as a runnable jar. 我正在开发一个处理语音的android应用,并且我已经在JAVA上准备好了语音基本项目(依赖Android项目),因此我在Eclipse中用JAVA 7编译器编译了JAVA项目,并将该Java项目导出为可运行的jar。 I put this jar into my android studio project's libs folder and by right clicking selected AS A library, I got build successful message. 我将此罐子放入我的android studio项目的l​​ibs文件夹中,然后通过右键单击选定的AS A库,获得了构建成功的消息。 But when I try run the android project it gives me error saying, 但是当我尝试运行android项目时,它给我错误提示,

FATAL EXCEPTION: main Process: in.automator.automator, PID: 4242
java.lang.NoClassDefFoundError: jar_filename.Storage.class_in_jar_file

but the said class is there in the jar file, the only doubtful thing is the mentioned class file looks something like this 但是jar文件中存在所述类,唯一值得怀疑的是所提到的类文件看起来像这样

import javax.sound.sampled.AudioFileFormat;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioFormat.Encoding;
import marf.util.InvalidSampleFormatException;

public class MARFAudioFileFormat extends AudioFileFormat {
....

 ...

....

}

It refers javax.sound.sampled, so possibly that might causing the problem. 它引用javax.sound.sampled,因此可能会导致问题。

I tried searching on the google for the problem but didn't got the solution which can resolve the issue. 我尝试在Google上搜索该问题,但没有解决该问题的解决方案。 I tried everything. 我尝试了一切。 I am using JRE 7 in android studio and exporting java project in Compiler & itself. 我在android studio中使用JRE 7,并在Compiler&本身中导出java项目。

How to resolve this error? 如何解决这个错误? Thanks in advance. 提前致谢。

You are correct, the problem lies in the fact that the library you're trying to depend on, in turn depends on the javax package hierarchy. 没错,问题在于您要依赖的库又依赖于javax包层次结构。 Android does not provide javax , so those classes don't exist at runtime (even though they do exist in your computer's JDK, so your compiler doesn't complain - it's basically the same as not having a particular DLL installed that a program on your PC needs). Android不提供javax ,因此这些类在运行时不存在(即使它们确实存在于计算机的JDK中,因此您的编译器也不会抱怨-基本上与在您的程序上未安装特定的DLL相同) PC需求)。

The NoClassDefFoundError is being thrown on the class that first references the invalid class dependencies, which is probably what's confusing. NoClassDefFoundError被抛出在首先引用无效的类依赖关系的类上,这可能是令人困惑的。 That class may indeed actually exist in your jar, but it requires classes that don't exist in order to complete its definition - so in effect, your class is not fully defined. 该类实际上可能确实存在于您的jar中,但是它需要不存在的类才能完成其定义-因此,实际上,您的类尚未完全定义。

The only way around this is to figure out a way to do whatever you're after, without the javax namespace. 解决此问题的唯一方法是找出一种无需javax命名空间即可完成所有工作的方法。 I have heard of a few attempts to try to port javax.* into Android, but they never end well - many of the javax classes end up boiling down to native calls, which also won't exist on Android. 我听说过几次尝试将javax.*移植到Android的尝试,但是它们都以失败告终-许多javax类最终都陷入了本机调用的javax ,这在Android上也不存在。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 致命异常:main java.lang.NoClassDefFoundError:org.apache.commons.net.ftp.FTPClient Android Studio - FATAL EXCEPTION: main java.lang.NoClassDefFoundError: org.apache.commons.net.ftp.FTPClient Android Studio ssj-2.5.jar库中的线程“ main”中的异常java.lang.NoClassDefFoundError - Exception in thread “main” java.lang.NoClassDefFoundError on ssj-2.5.jar library 用ant构建jar:线程“ main”中的异常java.lang.NoClassDefFoundError - Built jar with ant: Exception in thread “main” java.lang.NoClassDefFoundError JAR中的线程“ main”中的异常java.lang.NoClassDefFoundError - Exception in thread “main” java.lang.NoClassDefFoundError from JAR 致命异常:主要java.lang.NoClassDefFoundError:com.google.analytics.tracking.android.EasyTracker - FATAL EXCEPTION: main java.lang.NoClassDefFoundError: com.google.analytics.tracking.android.EasyTracker 线程“ main”中的异常java.lang.NoclassDefFoundError:cal / class - exception in thread “main” java.lang.NoclassDefFoundError: cal/class 包中的类 - 线程“main”中的异常 java.lang.NoClassDefFoundError - Class in a package - Exception in thread "main" java.lang.NoClassDefFoundError Android Studio启动失败,并出现“线程“ main”中的异常” java.lang.NoClassDefFoundError:javax.swing.UIManager” - Android Studio starts fail with “Exception in thread ”main“ java.lang.NoClassDefFoundError: javax.swing.UIManager” Eclipse jar库[java.lang.NoClassDefFoundError] - Eclipse jar library [java.lang.NoClassDefFoundError] 线程“ main”中的异常java.lang.NoClassDefFoundError: - Exception in thread “main” java.lang.NoClassDefFoundError:
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM