android gdata 日历不工作:( 强制关闭
我正在尝试使用 gdata api 连接到谷歌日历.. 我是 Android 新手,所以我想我犯了一些错误。 我已经在项目中添加了 3 个外部 jar。 日历、客户端和核心..
应用程序刚刚关闭..:( 这是主要活动:
package caleda.qwe;
import java.net.URL;
import com.google.gdata.client.calendar.CalendarService;
import com.google.gdata.data.calendar.CalendarEntry;
import com.google.gdata.data.calendar.CalendarFeed;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
public class rrr extends Activity {
String res;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// new GetMostWanted().execute();
CalendarService myService = new CalendarService("calendar");
try{
myService.setUserCredentials("username", "password");
// Send the request and print the response
URL feedUrl = new URL("https://www.google.com/calendar/feeds/default/owncalendars/full");
CalendarFeed resultFeed = myService.getFeed(feedUrl, CalendarFeed.class);
// System.out.println("Calendars you own:");
// System.out.println();
for (int i = 0; i < resultFeed.getEntries().size(); i++) {
CalendarEntry entry = resultFeed.getEntries().get(0);
// System.out.println("\t" + entry.getTitle().getPlainText());
res=entry.getTitle().getPlainText();
}
}
catch (Exception e) {
// TODO: handle exception
//System.out.println("not working");
res=e.toString();
}
// new DownloadFilesTask().execute();
TextView qw = (TextView) findViewById(R.id.TextView01);
qw.setText(res);
}
}
log cat 显示以下内容..
03-06 16:27:40.259: 错误/dalvikvm(3252):无法打开 堆栈跟踪文件 '/data/anr/traces.txt':权限 拒绝 03-06 16:30:04.759: 错误/Android运行时(3316):错误: 螺纹连接失败 03-06 16:30:06.910: 错误/Android运行时(3329):错误: 螺纹连接失败 03-06 16:30:06.910: 错误/AndroidRuntime(3335):未捕获 处理程序:线程主退出由于 未捕获的异常 03-06 16:30:06.910: 错误/Android运行时(3335): java.lang.ExceptionInInitializerError 03-06 16:30:06.910: 错误/Android运行时(3335):位于 caleda.qwe.rrr.onCreate(rrr.java:25) 03-06 16:30:06.910: 错误/Android运行时(3335):位于 android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 03-06 16:30:06.910: 错误/Android运行时(3335):位于 android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459) 03-06 16:30:06.910: 错误/Android运行时(3335):位于 android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512) 03-06 16:30:06.910: 错误/Android运行时(3335):位于 android.app.ActivityThread.access$2200(ActivityThread.java:119) 03-06 16:30:06.910: 错误/Android运行时(3335):位于 android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863) 03-06 16:30:06.910: 错误/Android运行时(3335):位于 android.os.Handler.dispatchMessage(Handler.java:99) 03-06 16:30:06.910: 错误/Android运行时(3335):位于 android.os.Looper.loop(Looper.java:123) 03-06 16:30:06.910: 错误/Android运行时(3335):位于 android.app.ActivityThread.main(ActivityThread.java:4363) 03-06 16:30:06.910: 错误/Android运行时(3335):位于 java.lang.reflect.Method.invokeNative(本机 方法)03-06 16:30:06.910: 错误/Android运行时(3335):位于 java.lang.reflect.Method.invoke(Method.java:521) 03-06 16:30:06.910: 错误/Android运行时(3335):位于 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 03-06 16:30:06.910: 错误/Android运行时(3335):位于 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 03-06 16:30:06.910: 错误/Android运行时(3335):位于 dalvik.system.NativeStart.main(本机 方法)03-06 16:30:06.910: 错误/AndroidRuntime(3335):原因: java.lang.NoClassDefFoundError: com.google.common.collect.Maps 03-06 16:30:06.910: 错误/Android运行时(3335):位于 com.google.gdata.wireformats.AltRegistry。(AltRegistry.java:118) 03-06 16:30:06.910: 错误/Android运行时(3335):位于 com.google.gdata.wireformats.AltRegistry。(AltRegistry.java:100) 03-06 16:30:06.910: 错误/Android运行时(3335):位于 com.google.gdata.client.Service。(Service.java:555) 03-06 16:30:06.910: 错误/Android运行时(3335):... 14 更多 03-06 16:30:06.910: 错误/dalvikvm(3335):无法打开 堆栈跟踪文件 '/data/anr/traces.txt':权限 被拒绝
请帮帮我..
I am trying to connect to google calendar using gdata api..
I am new to android so I think I am commiting some mistkaes.
I have added 3 external jar to the projects..
calendar,client & core ..
The apllication just closes .. :(
here is main activity :
package caleda.qwe;
import java.net.URL;
import com.google.gdata.client.calendar.CalendarService;
import com.google.gdata.data.calendar.CalendarEntry;
import com.google.gdata.data.calendar.CalendarFeed;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
public class rrr extends Activity {
String res;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// new GetMostWanted().execute();
CalendarService myService = new CalendarService("calendar");
try{
myService.setUserCredentials("username", "password");
// Send the request and print the response
URL feedUrl = new URL("https://www.google.com/calendar/feeds/default/owncalendars/full");
CalendarFeed resultFeed = myService.getFeed(feedUrl, CalendarFeed.class);
// System.out.println("Calendars you own:");
// System.out.println();
for (int i = 0; i < resultFeed.getEntries().size(); i++) {
CalendarEntry entry = resultFeed.getEntries().get(0);
// System.out.println("\t" + entry.getTitle().getPlainText());
res=entry.getTitle().getPlainText();
}
}
catch (Exception e) {
// TODO: handle exception
//System.out.println("not working");
res=e.toString();
}
// new DownloadFilesTask().execute();
TextView qw = (TextView) findViewById(R.id.TextView01);
qw.setText(res);
}
}
log cat shows the following..
03-06 16:27:40.259:
ERROR/dalvikvm(3252): Unable to open
stack trace file
'/data/anr/traces.txt': Permission
denied 03-06 16:30:04.759:
ERROR/AndroidRuntime(3316): ERROR:
thread attach failed 03-06
16:30:06.910:
ERROR/AndroidRuntime(3329): ERROR:
thread attach failed 03-06
16:30:06.910:
ERROR/AndroidRuntime(3335): Uncaught
handler: thread main exiting due to
uncaught exception 03-06 16:30:06.910:
ERROR/AndroidRuntime(3335):
java.lang.ExceptionInInitializerError
03-06 16:30:06.910:
ERROR/AndroidRuntime(3335): at
caleda.qwe.rrr.onCreate(rrr.java:25)
03-06 16:30:06.910:
ERROR/AndroidRuntime(3335): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-06 16:30:06.910:
ERROR/AndroidRuntime(3335): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
03-06 16:30:06.910:
ERROR/AndroidRuntime(3335): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
03-06 16:30:06.910:
ERROR/AndroidRuntime(3335): at
android.app.ActivityThread.access$2200(ActivityThread.java:119)
03-06 16:30:06.910:
ERROR/AndroidRuntime(3335): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
03-06 16:30:06.910:
ERROR/AndroidRuntime(3335): at
android.os.Handler.dispatchMessage(Handler.java:99)
03-06 16:30:06.910:
ERROR/AndroidRuntime(3335): at
android.os.Looper.loop(Looper.java:123)
03-06 16:30:06.910:
ERROR/AndroidRuntime(3335): at
android.app.ActivityThread.main(ActivityThread.java:4363)
03-06 16:30:06.910:
ERROR/AndroidRuntime(3335): at
java.lang.reflect.Method.invokeNative(Native
Method) 03-06 16:30:06.910:
ERROR/AndroidRuntime(3335): at
java.lang.reflect.Method.invoke(Method.java:521)
03-06 16:30:06.910:
ERROR/AndroidRuntime(3335): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
03-06 16:30:06.910:
ERROR/AndroidRuntime(3335): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
03-06 16:30:06.910:
ERROR/AndroidRuntime(3335): at
dalvik.system.NativeStart.main(Native
Method) 03-06 16:30:06.910:
ERROR/AndroidRuntime(3335): Caused by:
java.lang.NoClassDefFoundError:
com.google.common.collect.Maps 03-06
16:30:06.910:
ERROR/AndroidRuntime(3335): at
com.google.gdata.wireformats.AltRegistry.(AltRegistry.java:118)
03-06 16:30:06.910:
ERROR/AndroidRuntime(3335): at
com.google.gdata.wireformats.AltRegistry.(AltRegistry.java:100)
03-06 16:30:06.910:
ERROR/AndroidRuntime(3335): at
com.google.gdata.client.Service.(Service.java:555)
03-06 16:30:06.910:
ERROR/AndroidRuntime(3335): ... 14
more 03-06 16:30:06.910:
ERROR/dalvikvm(3335): Unable to open
stack trace file
'/data/anr/traces.txt': Permission
denied
Please help me out..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在我们的应用程序中包含两个外部 jar 文件..
这两个文件位于 gdata 的 deps 文件夹中
include two external jar files in our application..
Those two files are available in deps folder of gdata