番石榴:java.lang.NoClassDefFoundError的 - com.google.common.collect.HashBiMap [英] Guava: java.lang.NoClassDefFoundError - com.google.common.collect.HashBiMap

查看:487
本文介绍了番石榴:java.lang.NoClassDefFoundError的 - com.google.common.collect.HashBiMap的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

利用从这里下载番石榴库时com.google.common.collect.HashBiMap:

我目前面临java.lang.NoClassDefFoundError的问题: HTTP://$c$c.google.com/p/guava-libraries/

我已经加番石榴12.0.jar到我的项目作为参考库,但我仍然得到错误。愿你给什么问题会是一些建议吗?谢谢你们的帮助,

 包my.project;

进口android.app.Activity;
进口android.os.Bundle;

进口com.google.common.collect.BiMap;
进口com.google.common.collect.HashBiMap;

公共类MainActivity延伸活动{

     私人BIMAP<字符串,字符串> bidiMap;

    @覆盖
    公共无效的onCreate(包savedInstanceState){
        super.onCreate(savedInstanceState);
          的setContentView(R.layout.bible_help_cal);

        bidiMap = HashBiMap.create();
        bidiMap.put(一,100);
        bidiMap.put(B,200);


    }


}
 

错误消息我收到

  05-29 18:35:19.737:E / AndroidRuntime(376):致命异常:主要
05-29 18:35:19.737:E / AndroidRuntime(376):java.lang.NoClassDefFoundError的:com.google.common.collect.HashBiMap
05-29 18:35:19.737:E / AndroidRuntime(376):在my.project.MainActivity.onCreate(MainActivity.java:18)
05-29 18:35:19.737:E / AndroidRuntime(376):在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
05-29 18:35:19.737:E / AndroidRuntime(376):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1712)
05-29 18:35:19.737:E / AndroidRuntime(376):在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1764)
05-29 18:35:19.737:E / AndroidRuntime(376):在android.app.ActivityThread.access $ 1500(ActivityThread.java:122)
05-29 18:35:19.737:E / AndroidRuntime(376):在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1002)
05-29 18:35:19.737:E / AndroidRuntime(376):在android.os.Handler.dispatchMessage(Handler.java:99)
05-29 18:35:19.737:E / AndroidRuntime(376):在android.os.Looper.loop(Looper.java:132)
05-29 18:35:19.737:E / AndroidRuntime(376):在android.app.ActivityThread.main(ActivityThread.java:4025)
05-29 18:35:19.737:E / AndroidRuntime(376):在java.lang.reflect.Method.invokeNative(本机方法)
05-29 18:35:19.737:E / AndroidRuntime(376):在java.lang.reflect.Method.invoke(Method.java:491)
05-29 18:35:19.737:E / AndroidRuntime(376):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:841)
05-29 18:35:19.737:E / AndroidRuntime(376):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
05-29 18:35:19.737:E / AndroidRuntime(376):在dalvik.system.NativeStart.main(本机方法)
 

解决方案

这个错误意味着类是在编译时间,但可以在运行时不会被发现。它最常见的发生在你的编译时类路径是从运行时类路径有所不同。

这是非常有可能的运行时类路径中不包含番石榴罐子。为了验证这一点,请尝试打印你的classpath 在code。

在命令行中,你可以使用:  java命令路径/要/ guava.jarMyMainClass

或替代,设置CLASSPATH环境变量包括JAR。

I currently face the problem of java.lang.NoClassDefFoundError: com.google.common.collect.HashBiMap when using guava libraries downloaded from here: http://code.google.com/p/guava-libraries/

I already add guava-12.0.jar into my project as a reference library but I still get the error. May you give some advice on what the problem would be? Thankyou for your help

package my.project;

import android.app.Activity;
import android.os.Bundle;

import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;

public class MainActivity extends Activity{

     private BiMap<String,String>  bidiMap; 

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);     
          setContentView(R.layout.bible_help_cal);

        bidiMap = HashBiMap.create();           
        bidiMap.put("a","100");
        bidiMap.put("b","200");


    }


}

Error Message I get

05-29 18:35:19.737: E/AndroidRuntime(376): FATAL EXCEPTION: main
05-29 18:35:19.737: E/AndroidRuntime(376): java.lang.NoClassDefFoundError: com.google.common.collect.HashBiMap
05-29 18:35:19.737: E/AndroidRuntime(376):  at my.project.MainActivity.onCreate(MainActivity.java:18)
05-29 18:35:19.737: E/AndroidRuntime(376):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
05-29 18:35:19.737: E/AndroidRuntime(376):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1712)
05-29 18:35:19.737: E/AndroidRuntime(376):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1764)
05-29 18:35:19.737: E/AndroidRuntime(376):  at android.app.ActivityThread.access$1500(ActivityThread.java:122)
05-29 18:35:19.737: E/AndroidRuntime(376):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1002)
05-29 18:35:19.737: E/AndroidRuntime(376):  at android.os.Handler.dispatchMessage(Handler.java:99)
05-29 18:35:19.737: E/AndroidRuntime(376):  at android.os.Looper.loop(Looper.java:132)
05-29 18:35:19.737: E/AndroidRuntime(376):  at android.app.ActivityThread.main(ActivityThread.java:4025)
05-29 18:35:19.737: E/AndroidRuntime(376):  at java.lang.reflect.Method.invokeNative(Native Method)
05-29 18:35:19.737: E/AndroidRuntime(376):  at java.lang.reflect.Method.invoke(Method.java:491)
05-29 18:35:19.737: E/AndroidRuntime(376):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
05-29 18:35:19.737: E/AndroidRuntime(376):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
05-29 18:35:19.737: E/AndroidRuntime(376):  at dalvik.system.NativeStart.main(Native Method)

解决方案

This error means that the class was available at compile time, but cannot be found during run time. It most commonly happens when your compile time classpath is different from your runtime classpath.

It is very likely that your runtime classpath doesn't contain the guava jar. To verify this, try printing your classpath in your code.

on the command line, you can use: java -cp "path/to/guava.jar" MyMainClass

or alternatively, set the CLASSPATH environment variable to include the jar.

这篇关于番石榴:java.lang.NoClassDefFoundError的 - com.google.common.collect.HashBiMap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆