我在为Android创建应用时遇到了一些麻烦,我想使用JsonFactory,但是当我创建一个应用程序时,应用程序崩溃了。
我导入了:
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.jackson2.JacksonFactory;
然后我用了:
private static final JsonFactory factory = new JacksonFactory();
我还在构建路径中添加了“google-http-client-jackson2-1.16.0-rc.jar”和“google-http-client-1.16.0-rc.jar”库。
因此,模拟器和物理设备都提供“不幸的是,## apname ##已停止”
Logcat提供以下内容:
08-29 13:28:27.754: E/AndroidRuntime(990): FATAL EXCEPTION: main
08-29 13:28:27.754: E/AndroidRuntime(990): java.lang.ExceptionInInitializerError
08-29 13:28:27.754: E/AndroidRuntime(990): at java.lang.Class.newInstanceImpl(Native Method)
08-29 13:28:27.754: E/AndroidRuntime(990): at java.lang.Class.newInstance(Class.java:1319)
08-29 13:28:27.754: E/AndroidRuntime(990): at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
08-29 13:28:27.754: E/AndroidRuntime(990): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
08-29 13:28:27.754: E/AndroidRuntime(990): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
08-29 13:28:27.754: E/AndroidRuntime(990): at android.app.ActivityThread.access$600(ActivityThread.java:141)
08-29 13:28:27.754: E/AndroidRuntime(990): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
08-29 13:28:27.754: E/AndroidRuntime(990): at android.os.Handler.dispatchMessage(Handler.java:99)
08-29 13:28:27.754: E/AndroidRuntime(990): at android.os.Looper.loop(Looper.java:137)
08-29 13:28:27.754: E/AndroidRuntime(990): at android.app.ActivityThread.main(ActivityThread.java:5039)
08-29 13:28:27.754: E/AndroidRuntime(990): at java.lang.reflect.Method.invokeNative(Native Method)
08-29 13:28:27.754: E/AndroidRuntime(990): at java.lang.reflect.Method.invoke(Method.java:511)
08-29 13:28:27.754: E/AndroidRuntime(990): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
08-29 13:28:27.754: E/AndroidRuntime(990): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
08-29 13:28:27.754: E/AndroidRuntime(990): at dalvik.system.NativeStart.main(Native Method)
08-29 13:28:27.754: E/AndroidRuntime(990): Caused by: java.lang.NoClassDefFoundError: com.fasterxml.jackson.core.JsonFactory
08-29 13:28:27.754: E/AndroidRuntime(990): at com.google.api.client.json.jackson2.JacksonFactory.<init>(JacksonFactory.java:45)
08-29 13:28:27.754: E/AndroidRuntime(990): at com.example.youtubesearch.MainActivity.<clinit>(MainActivity.java:42)
08-29 13:28:27.754: E/AndroidRuntime(990): ... 15 more
08-29 13:28:27.764: W/ActivityManager(288): Force finishing activity com.example.youtubesearch/.MainActivity
非常感谢帮助!! 提前致谢
答案 0 :(得分:0)
解决方案很简单:
从logcat中可以看到缺少以下内容:
com.fasterxml.jackson.core.JsonFactory
所以我刚刚将this添加到我的构建路径
对不起,如果我浪费了任何人的时间