我是 Android 开发新手,遇到了一个奇怪的问题。我正在尝试从 AsyncTask 中提取和显示日历事件。这在调试模式下工作,但如果我尝试通过 apk 安装应用程序,应用程序会因以下错误而崩溃:
12-18 08:57:16.768: E/AndroidRuntime(8642): FATAL EXCEPTION: AsyncTask #2
12-18 08:57:16.768: E/AndroidRuntime(8642): java.lang.RuntimeException: An error occured while executing doInBackground()
12-18 08:57:16.768: E/AndroidRuntime(8642): at android.os.AsyncTask$3.done(AsyncTask.java:299)
12-18 08:57:16.768: E/AndroidRuntime(8642): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
12-18 08:57:16.768: E/AndroidRuntime(8642): at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
12-18 08:57:16.768: E/AndroidRuntime(8642): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
12-18 08:57:16.768: E/AndroidRuntime(8642): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
12-18 08:57:16.768: E/AndroidRuntime(8642): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
12-18 08:57:16.768: E/AndroidRuntime(8642): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
12-18 08:57:16.768: E/AndroidRuntime(8642): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
12-18 08:57:16.768: E/AndroidRuntime(8642): at java.lang.Thread.run(Thread.java:856)
12-18 08:57:16.768: E/AndroidRuntime(8642): Caused by: java.lang.IllegalArgumentException: unable to create new instance of class com.a.b.b.a.a.b because it has no accessible default constructor
12-18 08:57:16.768: E/AndroidRuntime(8642): at com.a.b.a.e.aa.a(Unknown Source)
12-18 08:57:16.768: E/AndroidRuntime(8642): at com.a.b.a.e.aa.a(Unknown Source)
12-18 08:57:16.768: E/AndroidRuntime(8642): at com.a.b.a.e.i.b(Unknown Source)
12-18 08:57:16.768: E/AndroidRuntime(8642): at com.a.b.a.d.g.a(Unknown Source)
12-18 08:57:16.768: E/AndroidRuntime(8642): at com.a.b.a.d.g.a(Unknown Source)
12-18 08:57:16.768: E/AndroidRuntime(8642): at com.a.b.a.d.g.a(Unknown Source)
12-18 08:57:16.768: E/AndroidRuntime(8642): at com.a.b.a.d.g.a(Unknown Source)
12-18 08:57:16.768: E/AndroidRuntime(8642): at com.a.b.a.d.g.a(Unknown Source)
12-18 08:57:16.768: E/AndroidRuntime(8642): at com.a.b.a.d.g.a(Unknown Source) 12-18 08:57:16.768: E/AndroidRuntime(8642): at com.a.b.a.d.g.a(Unknown Source)
12-18 08:57:16.768: E/AndroidRuntime(8642): at com.a.b.a.d.g.a(Unknown Source)
12-18 08:57:16.768: E/AndroidRuntime(8642): at com.a.b.a.d.f.a(Unknown Source)
12-18 08:57:16.768: E/AndroidRuntime(8642): at com.a.b.a.d.f.a(Unknown Source)
12-18 08:57:16.768: E/AndroidRuntime(8642): at com.a.b.a.c.t.a(Unknown Source)
12-18 08:57:16.768: E/AndroidRuntime(8642): at com.a.b.a.b.d.c.d(Unknown Source)
12-18 08:57:16.768: E/AndroidRuntime(8642): at com.promevo.bookit.a.f(Unknown Source)
12-18 08:57:16.768: E/AndroidRuntime(8642): at com.promevo.bookit.a.a(Unknown Source)
12-18 08:57:16.768: E/AndroidRuntime(8642): at com.promevo.bookit.f.a(Unknown Source)
12-18 08:57:16.768: E/AndroidRuntime(8642): at com.promevo.bookit.f.doInBackground(Unknown Source)
12-18 08:57:16.768: E/AndroidRuntime(8642): at android.os.AsyncTask$2.call(AsyncTask.java:287)
12-18 08:57:16.768: E/AndroidRuntime(8642): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
12-18 08:57:16.768: E/AndroidRuntime(8642): ... 5 more
12-18 08:57:16.768: E/AndroidRuntime(8642): Caused by: java.lang.InstantiationException: can't instantiate class com.a.b.b.a.a.b; no empty constructor
12-18 08:57:16.768: E/AndroidRuntime(8642): at java.lang.Class.newInstanceImpl(Native Method)
12-18 08:57:16.768: E/AndroidRuntime(8642): at java.lang.Class.newInstance(Class.java:1319)
我正在打的电话:
Events feed = client.events().list(CalendarSampleActivity.getCalId()).setTimeMin(startPass)
.setTimeMax(endPass).setSingleEvents(true).execute();
有人有想法么?提前致谢。
好的,经过一些故障排除后,使用 Proguard 时似乎出现了问题。如果我从我的 project.properties 文件中删除这一行,我的应用程序现在可以工作:
proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt:proguard-google-api-client.txt
任何人都知道为什么这会有所作为?