引用.jar库时无法解析超类错误

时间:2022-09-03 22:30:43
  1. I did an Android project and run it. It ran successfully.
  2. 我做了一个Android项目并运行它。它运行成功。
  3. I developed a web service in Java and hosted it. It ran successfully.
  4. 我用Java开发了一个Web服务并托管它。它运行成功。
  5. I exported the webservice into a .jar and added it to my Android project.
  6. 我将webservice导出到.jar并将其添加到我的Android项目中。
  7. When I try to call a method in the web service I get an Unable to resolve superclass error.
  8. 当我尝试在Web服务中调用方法时,我得到一个Unable来解决超类错误。

My error log:

我的错误日志:

Unable to resolve superclass of Lweb/service/RandomWordGeneratorService; (73)
Link of class 'Lweb/service/RandomWordGeneratorService;' failed 
Could not find class 'web.service.RandomWordGeneratorService',
    referenced from method tam.miru.Login$1.onClick
VFY: unable to resolve new-instance 110 Lweb/service/RandomWordGeneratorService;)
    in Ltam/miru/Login$1; 
VFY: replacing opcode 0x22 at 0x005a    
VFY: dead code 0x005c-006e in Ltam/miru/Login$1;.onClick (Landroid/view/View;)

8 个解决方案

#1


71  

Just started to get this issue after upgrading to ADT 17.

刚升级到ADT 17后才开始解决这个问题。

Discovered that external .jar files need to be in a 'libs' (with an s) folder otherwise their classes are not included in the .dex file that is created. Before the upgrade everything worked fine with my .jar files in a 'lib' folder (no s).

发现外部.jar文件需要位于“libs”(带有s)文件夹中,否则它们的类不包含在创建的.dex文件中。在升级之前,我的.jar文件在'lib'文件夹(没有s)中一切正常。

#2


14  

In my case I had to go to Properties->Java Build Path->Order and Export and check Android Private Libraries, then cleaned the project and worked fine.

在我的情况下,我不得不去Properties-> Java Build Path-> Order and Export并检查Android私有库,然后清理项目并且工作正常。

#3


4  

Create lib folder, libs folder is for native libraries. I made it, add library to lib and to build path as internal library and it works!

创建lib文件夹,libs文件夹用于本机库。我做了它,将库添加到lib并构建路径作为内部库,它的工作原理!

#4


2  

Are you using eclipse? If so, did you add the library to the build path as described in Adding a library/JAR to an Eclipse Android project?

你在用eclipse吗?如果是这样,您是否将库添加到构建路径,如将Eclipse / JAR添加到Eclipse Android项目中所述?

#5


2  

I know that this a post on a really old thread, but after I read the answer by @rabidgremlin, I checked the folder structure, and found that it was already in "libs". However, on seeing the support.jar, I figured that using this was what was causing the issue.

我知道这是一个非常老的帖子上的帖子,但在我读完@rabidgremlin的答案之后,我检查了文件夹结构,发现它已经在“libs”中了。但是,在看到support.jar时,我发现使用它是导致问题的原因。

I was extending "FragmentActivity" but it turns out, that was referencing the support.jar, which had issues in itself. Once I removed the extends clause, the app miraculously stopped crashing.

我正在扩展“FragmentActivity”,但事实证明,这是引用了support.jar,它本身就存在问题。一旦我删除了extends子句,该应用程序奇迹般地停止了崩溃。

Just an FYI in case someone comes looking. Cheers!

只是一个FYI,以防有人来看。干杯!

#6


1  

I had the same problem, I tried to mark the Android Private Libraries under Order and Export and it didn't work for me. Then I noticed that my libs folder wasn't referenced under the Java Build Path. So I just added it to Libraries and it worked.

我有同样的问题,我试图在订单和导出下标记Android私有库,但它对我不起作用。然后我注意到我的libs文件夹没有在Java Build Path下引用。所以我只是将它添加到库中并且它有效。

#7


1  

I had the same error message. Took me some time to figure out the problem: Android requires Java 1.6 to work. And the superclass of my Activity implemented an interface from a Java project that had Java 1.7 as compiler. That was enough for the dex builder not to be able to link the superclass and this resulted in the class not found exception.

我有相同的错误消息。花了一些时间来弄清楚问题:Android需要Java 1.6才能运行。我的Activity的超类实现了一个Java项目的接口,该项目将Java 1.7作为编译器。这足以让dex构建器无法链接超类,这导致了类找不到异常。

#8


-1  

I ran into a different cause for this error on Eclipse. I was experimenting with putting eclipse workspaces into google drive directories and discovered that certain superclasses can't be resolved from android activities.

我在Eclipse上遇到了这个错误的另一个原因。我正在尝试将eclipse工作区放入google驱动器目录,并发现无法从Android活动中解析某些超类。

Paused google drive and everything began working fine. In my case the superclass that wouldn't load was from a protocol buffers generated class. This class and all others I tested worked fine in non-android java programs, even while google drive was running.

暂停谷歌驱动器,一切都开始正常工作。在我的例子中,不加载的超类来自协议缓冲生成的类。这个类和我测试的所有其他类在非android java程序中运行良好,即使在谷歌驱动器运行时也是如此。

#1


71  

Just started to get this issue after upgrading to ADT 17.

刚升级到ADT 17后才开始解决这个问题。

Discovered that external .jar files need to be in a 'libs' (with an s) folder otherwise their classes are not included in the .dex file that is created. Before the upgrade everything worked fine with my .jar files in a 'lib' folder (no s).

发现外部.jar文件需要位于“libs”(带有s)文件夹中,否则它们的类不包含在创建的.dex文件中。在升级之前,我的.jar文件在'lib'文件夹(没有s)中一切正常。

#2


14  

In my case I had to go to Properties->Java Build Path->Order and Export and check Android Private Libraries, then cleaned the project and worked fine.

在我的情况下,我不得不去Properties-> Java Build Path-> Order and Export并检查Android私有库,然后清理项目并且工作正常。

#3


4  

Create lib folder, libs folder is for native libraries. I made it, add library to lib and to build path as internal library and it works!

创建lib文件夹,libs文件夹用于本机库。我做了它,将库添加到lib并构建路径作为内部库,它的工作原理!

#4


2  

Are you using eclipse? If so, did you add the library to the build path as described in Adding a library/JAR to an Eclipse Android project?

你在用eclipse吗?如果是这样,您是否将库添加到构建路径,如将Eclipse / JAR添加到Eclipse Android项目中所述?

#5


2  

I know that this a post on a really old thread, but after I read the answer by @rabidgremlin, I checked the folder structure, and found that it was already in "libs". However, on seeing the support.jar, I figured that using this was what was causing the issue.

我知道这是一个非常老的帖子上的帖子,但在我读完@rabidgremlin的答案之后,我检查了文件夹结构,发现它已经在“libs”中了。但是,在看到support.jar时,我发现使用它是导致问题的原因。

I was extending "FragmentActivity" but it turns out, that was referencing the support.jar, which had issues in itself. Once I removed the extends clause, the app miraculously stopped crashing.

我正在扩展“FragmentActivity”,但事实证明,这是引用了support.jar,它本身就存在问题。一旦我删除了extends子句,该应用程序奇迹般地停止了崩溃。

Just an FYI in case someone comes looking. Cheers!

只是一个FYI,以防有人来看。干杯!

#6


1  

I had the same problem, I tried to mark the Android Private Libraries under Order and Export and it didn't work for me. Then I noticed that my libs folder wasn't referenced under the Java Build Path. So I just added it to Libraries and it worked.

我有同样的问题,我试图在订单和导出下标记Android私有库,但它对我不起作用。然后我注意到我的libs文件夹没有在Java Build Path下引用。所以我只是将它添加到库中并且它有效。

#7


1  

I had the same error message. Took me some time to figure out the problem: Android requires Java 1.6 to work. And the superclass of my Activity implemented an interface from a Java project that had Java 1.7 as compiler. That was enough for the dex builder not to be able to link the superclass and this resulted in the class not found exception.

我有相同的错误消息。花了一些时间来弄清楚问题:Android需要Java 1.6才能运行。我的Activity的超类实现了一个Java项目的接口,该项目将Java 1.7作为编译器。这足以让dex构建器无法链接超类,这导致了类找不到异常。

#8


-1  

I ran into a different cause for this error on Eclipse. I was experimenting with putting eclipse workspaces into google drive directories and discovered that certain superclasses can't be resolved from android activities.

我在Eclipse上遇到了这个错误的另一个原因。我正在尝试将eclipse工作区放入google驱动器目录,并发现无法从Android活动中解析某些超类。

Paused google drive and everything began working fine. In my case the superclass that wouldn't load was from a protocol buffers generated class. This class and all others I tested worked fine in non-android java programs, even while google drive was running.

暂停谷歌驱动器,一切都开始正常工作。在我的例子中,不加载的超类来自协议缓冲生成的类。这个类和我测试的所有其他类在非android java程序中运行良好,即使在谷歌驱动器运行时也是如此。