问题描述
我刚开始学的谷歌Android-API的Java客户端。添加了未来3库到项目中。 (我不使用Maven。)
I just started studying google-api-java-client on Android.Added next 3 libraries into project. (I don't use Maven.)
- 在谷歌的API客户端-1.4.1-beta.jar
- 谷歌API的客户googleapis-1.4.1-beta.jar
- 谷歌API的客户googleapis - 扩展 - 的Andr ??
和采摘的样品code一起工作。在示例,它采用GoogleTransport这似乎是现在不可用。
And picked sample code to work with. In the sample, it used GoogleTransport which seems not available now.
HttpTransport transport = GoogleTransport.create();
所以我把它改为NetHttpTransport(),在网络上找到。
So I changed it to NetHttpTransport(), found on the web.
import com.google.api.client.http.javanet.NetHttpTransport;
...
HttpTransport transport = new NetHttpTransport();
不过,我有例外。
But, I got exception.
05-24 15:54:33.310: ERROR/AndroidRuntime(4586): java.lang.NoClassDefFoundError: com.google.common.base.Preconditions
05-24 15:54:33.310: ERROR/AndroidRuntime(4586): at com.google.api.client.util.ClassInfo.<init>(ClassInfo.java:324)
05-24 15:54:33.310: ERROR/AndroidRuntime(4586): at com.google.api.client.util.ClassInfo.of(ClassInfo.java:77)
05-24 15:54:33.310: ERROR/AndroidRuntime(4586): at com.google.api.client.util.GenericData.<init>(GenericData.java:44)
05-24 15:54:33.310: ERROR/AndroidRuntime(4586): at com.google.api.client.http.HttpHeaders.<init>(HttpHeaders.java:37)
05-24 15:54:33.310: ERROR/AndroidRuntime(4586): at com.google.api.client.http.HttpTransport.<init>(HttpTransport.java:82)
05-24 15:54:33.310: ERROR/AndroidRuntime(4586): at com.google.api.client.http.javanet.NetHttpTransport.<init>(NetHttpTransport.java:35)
05-24 15:54:33.310: ERROR/AndroidRuntime(4586): at net.DailyTimer.test.MainActivity.onCreate(MainActivity.java:290)
什么是错的呢?
What is wrong with this?
推荐答案
正如你可以在错误看到,你有一个类失踪,从的。您可以下载番石榴lib和在类路径中添加或使用的Maven(或常春藤)来管理你的依赖你。
As you can see in the error, you have a class missing, coming from Guava. You can either download the guava lib and add it in your classpath, or use maven (or Ivy) to manage your dependencies for you.
这篇关于谷歌-API的Java客户端NetHttpTransport导致的NoClassDefFoundError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!