1

我正在按照教程获取附近的位置,我按照教程执行了每一步。但是当我运行我的应用程序时,出现以下错误:

10-08 10:57:37.125: E/dalvikvm(758): Could not find class 'com.google.api.client.http.javanet.NetHttpTransport', referenced from method com.androidhive.googleplacesandmaps.GooglePlaces.<clinit>
10-08 10:57:37.475: E/dalvikvm(758): Could not find class 'com.androidhive.googleplacesandmaps.GooglePlaces$1', referenced from method com.androidhive.googleplacesandmaps.GooglePlaces.createRequestFactory
10-08 10:57:37.515: E/dalvikvm(758): Could not find class 'com.google.api.client.http.GenericUrl', referenced from method com.androidhive.googleplacesandmaps.GooglePlaces.getPlaceDetails
10-08 10:57:37.566: E/dalvikvm(758): Could not find class 'com.google.api.client.http.GenericUrl', referenced from method com.androidhive.googleplacesandmaps.GooglePlaces.search
10-08 10:57:37.645: E/AndroidRuntime(758): FATAL EXCEPTION: AsyncTask #1
10-08 10:57:37.645: E/AndroidRuntime(758): java.lang.RuntimeException: An error occured while executing doInBackground()
10-08 10:57:37.645: E/AndroidRuntime(758):  at android.os.AsyncTask$3.done(AsyncTask.java:266)
10-08 10:57:37.645: E/AndroidRuntime(758):  at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
10-08 10:57:37.645: E/AndroidRuntime(758):  at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
10-08 10:57:37.645: E/AndroidRuntime(758):  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
10-08 10:57:37.645: E/AndroidRuntime(758):  at java.util.concurrent.FutureTask.run(FutureTask.java:137)
10-08 10:57:37.645: E/AndroidRuntime(758):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1081)
10-08 10:57:37.645: E/AndroidRuntime(758):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:574)
10-08 10:57:37.645: E/AndroidRuntime(758):  at java.lang.Thread.run(Thread.java:1020)
10-08 10:57:37.645: E/AndroidRuntime(758): Caused by: java.lang.ExceptionInInitializerError
10-08 10:57:37.645: E/AndroidRuntime(758):  at com.androidhive.googleplacesandmaps.MainActivity$LoadPlaces.doInBackground(MainActivity.java:170)
10-08 10:57:37.645: E/AndroidRuntime(758):  at com.androidhive.googleplacesandmaps.MainActivity$LoadPlaces.doInBackground(MainActivity.java:1)
10-08 10:57:37.645: E/AndroidRuntime(758):  at android.os.AsyncTask$2.call(AsyncTask.java:252)
10-08 10:57:37.645: E/AndroidRuntime(758):  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
10-08 10:57:37.645: E/AndroidRuntime(758):  ... 4 more
10-08 10:57:37.645: E/AndroidRuntime(758): Caused by: java.lang.NoClassDefFoundError: com.google.api.client.http.javanet.NetHttpTransport
10-08 10:57:37.645: E/AndroidRuntime(758):  at com.androidhive.googleplacesandmaps.GooglePlaces.<clinit>(GooglePlaces.java:23)
10-08 10:57:37.645: E/AndroidRuntime(758):  ... 8 more
10-08 10:57:38.715: E/WindowManager(758): Activity com.androidhive.googleplacesandmaps.MainActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@40936600 that was originally added here
10-08 10:57:38.715: E/WindowManager(758): android.view.WindowLeaked: Activity com.androidhive.googleplacesandmaps.MainActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@40936600 that was originally added here
10-08 10:57:38.715: E/WindowManager(758):   at android.view.ViewRoot.<init>(ViewRoot.java:288)
10-08 10:57:38.715: E/WindowManager(758):   at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:249)
10-08 10:57:38.715: E/WindowManager(758):   at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:193)
10-08 10:57:38.715: E/WindowManager(758):   at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:118)
10-08 10:57:38.715: E/WindowManager(758):   at android.view.Window$LocalWindowManager.addView(Window.java:532)
10-08 10:57:38.715: E/WindowManager(758):   at android.app.Dialog.show(Dialog.java:269)
10-08 10:57:38.715: E/WindowManager(758):   at com.androidhive.googleplacesandmaps.MainActivity$LoadPlaces.onPreExecute(MainActivity.java:162)
10-08 10:57:38.715: E/WindowManager(758):   at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:549)
10-08 10:57:38.715: E/WindowManager(758):   at android.os.AsyncTask.execute(AsyncTask.java:499)
10-08 10:57:38.715: E/WindowManager(758):   at com.androidhive.googleplacesandmaps.MainActivity.onCreate(MainActivity.java:102)
10-08 10:57:38.715: E/WindowManager(758):   at android.app.Activity.performCreate(Activity.java:4397)
10-08 10:57:38.715: E/WindowManager(758):   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
10-08 10:57:38.715: E/WindowManager(758):   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1779)
10-08 10:57:38.715: E/WindowManager(758):   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1831)
10-08 10:57:38.715: E/WindowManager(758):   at android.app.ActivityThread.access$500(ActivityThread.java:122)
10-08 10:57:38.715: E/WindowManager(758):   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1024)
10-08 10:57:38.715: E/WindowManager(758):   at android.os.Handler.dispatchMessage(Handler.java:99)
10-08 10:57:38.715: E/WindowManager(758):   at android.os.Looper.loop(Looper.java:132)
10-08 10:57:38.715: E/WindowManager(758):   at android.app.ActivityThread.main(ActivityThread.java:4123)
10-08 10:57:38.715: E/WindowManager(758):   at java.lang.reflect.Method.invokeNative(Native Method)
10-08 10:57:38.715: E/WindowManager(758):   at java.lang.reflect.Method.invoke(Method.java:491)
10-08 10:57:38.715: E/WindowManager(758):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
10-08 10:57:38.715: E/WindowManager(758):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
10-08 10:57:38.715: E/WindowManager(758):   at dalvik.system.NativeStart.main(Native Method)
10-08 11:04:08.085: E/dalvikvm(794): Could not find class 'com.google.api.client.http.javanet.NetHttpTransport', referenced from method com.androidhive.googleplacesandmaps.GooglePlaces.<clinit>
10-08 11:04:08.435: E/dalvikvm(794): Could not find class 'com.androidhive.googleplacesandmaps.GooglePlaces$1', referenced from method com.androidhive.googleplacesandmaps.GooglePlaces.createRequestFactory
10-08 11:04:08.485: E/dalvikvm(794): Could not find class 'com.google.api.client.http.GenericUrl', referenced from method com.androidhive.googleplacesandmaps.GooglePlaces.getPlaceDetails
10-08 11:04:08.655: E/dalvikvm(794): Could not find class 'com.google.api.client.http.GenericUrl', referenced from method com.androidhive.googleplacesandmaps.GooglePlaces.search
10-08 11:04:08.685: E/AndroidRuntime(794): FATAL EXCEPTION: AsyncTask #1
10-08 11:04:08.685: E/AndroidRuntime(794): java.lang.RuntimeException: An error occured while executing doInBackground()
10-08 11:04:08.685: E/AndroidRuntime(794):  at android.os.AsyncTask$3.done(AsyncTask.java:266)
10-08 11:04:08.685: E/AndroidRuntime(794):  at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
10-08 11:04:08.685: E/AndroidRuntime(794):  at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
10-08 11:04:08.685: E/AndroidRuntime(794):  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
10-08 11:04:08.685: E/AndroidRuntime(794):  at java.util.concurrent.FutureTask.run(FutureTask.java:137)
10-08 11:04:08.685: E/AndroidRuntime(794):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1081)
10-08 11:04:08.685: E/AndroidRuntime(794):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:574)
10-08 11:04:08.685: E/AndroidRuntime(794):  at java.lang.Thread.run(Thread.java:1020)
10-08 11:04:08.685: E/AndroidRuntime(794): Caused by: java.lang.ExceptionInInitializerError
10-08 11:04:08.685: E/AndroidRuntime(794):  at com.androidhive.googleplacesandmaps.MainActivity$LoadPlaces.doInBackground(MainActivity.java:170)
10-08 11:04:08.685: E/AndroidRuntime(794):  at com.androidhive.googleplacesandmaps.MainActivity$LoadPlaces.doInBackground(MainActivity.java:1)
10-08 11:04:08.685: E/AndroidRuntime(794):  at android.os.AsyncTask$2.call(AsyncTask.java:252)
10-08 11:04:08.685: E/AndroidRuntime(794):  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
10-08 11:04:08.685: E/AndroidRuntime(794):  ... 4 more
10-08 11:04:08.685: E/AndroidRuntime(794): Caused by: java.lang.NoClassDefFoundError: com.google.api.client.http.javanet.NetHttpTransport
10-08 11:04:08.685: E/AndroidRuntime(794):  at com.androidhive.googleplacesandmaps.GooglePlaces.<clinit>(GooglePlaces.java:23)
10-08 11:04:08.685: E/AndroidRuntime(794):  ... 8 more
10-08 11:04:09.786: E/WindowManager(794): Activity com.androidhive.googleplacesandmaps.MainActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@409365d0 that was originally added here
10-08 11:04:09.786: E/WindowManager(794): android.view.WindowLeaked: Activity com.androidhive.googleplacesandmaps.MainActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@409365d0 that was originally added here
10-08 11:04:09.786: E/WindowManager(794):   at android.view.ViewRoot.<init>(ViewRoot.java:288)
10-08 11:04:09.786: E/WindowManager(794):   at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:249)
10-08 11:04:09.786: E/WindowManager(794):   at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:193)
10-08 11:04:09.786: E/WindowManager(794):   at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:118)
10-08 11:04:09.786: E/WindowManager(794):   at android.view.Window$LocalWindowManager.addView(Window.java:532)
10-08 11:04:09.786: E/WindowManager(794):   at android.app.Dialog.show(Dialog.java:269)
10-08 11:04:09.786: E/WindowManager(794):   at com.androidhive.googleplacesandmaps.MainActivity$LoadPlaces.onPreExecute(MainActivity.java:162)
10-08 11:04:09.786: E/WindowManager(794):   at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:549)
10-08 11:04:09.786: E/WindowManager(794):   at android.os.AsyncTask.execute(AsyncTask.java:499)
10-08 11:04:09.786: E/WindowManager(794):   at com.androidhive.googleplacesandmaps.MainActivity.onCreate(MainActivity.java:102)
10-08 11:04:09.786: E/WindowManager(794):   at android.app.Activity.performCreate(Activity.java:4397)
10-08 11:04:09.786: E/WindowManager(794):   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
10-08 11:04:09.786: E/WindowManager(794):   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1779)
10-08 11:04:09.786: E/WindowManager(794):   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1831)
10-08 11:04:09.786: E/WindowManager(794):   at android.app.ActivityThread.access$500(ActivityThread.java:122)
10-08 11:04:09.786: E/WindowManager(794):   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1024)
10-08 11:04:09.786: E/WindowManager(794):   at android.os.Handler.dispatchMessage(Handler.java:99)
10-08 11:04:09.786: E/WindowManager(794):   at android.os.Looper.loop(Looper.java:132)
10-08 11:04:09.786: E/WindowManager(794):   at android.app.ActivityThread.main(ActivityThread.java:4123)
10-08 11:04:09.786: E/WindowManager(794):   at java.lang.reflect.Method.invokeNative(Native Method)
10-08 11:04:09.786: E/WindowManager(794):   at java.lang.reflect.Method.invoke(Method.java:491)
10-08 11:04:09.786: E/WindowManager(794):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
10-08 11:04:09.786: E/WindowManager(794):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
10-08 11:04:09.786: E/WindowManager(794):   at dalvik.system.NativeStart.main(Native Method)
10-08 11:08:51.366: E/dalvikvm(826): Could not find class 'com.google.api.client.http.javanet.NetHttpTransport', referenced from method com.androidhive.googleplacesandmaps.GooglePlaces.<clinit>
10-08 11:08:51.806: E/dalvikvm(826): Could not find class 'com.androidhive.googleplacesandmaps.GooglePlaces$1', referenced from method com.androidhive.googleplacesandmaps.GooglePlaces.createRequestFactory
10-08 11:08:51.885: E/dalvikvm(826): Could not find class 'com.google.api.client.http.GenericUrl', referenced from method com.androidhive.googleplacesandmaps.GooglePlaces.getPlaceDetails
10-08 11:08:51.935: E/dalvikvm(826): Could not find class 'com.google.api.client.http.GenericUrl', referenced from method com.androidhive.googleplacesandmaps.GooglePlaces.search
10-08 11:08:52.035: E/AndroidRuntime(826): FATAL EXCEPTION: AsyncTask #1
10-08 11:08:52.035: E/AndroidRuntime(826): java.lang.RuntimeException: An error occured while executing doInBackground()
10-08 11:08:52.035: E/AndroidRuntime(826):  at android.os.AsyncTask$3.done(AsyncTask.java:266)
10-08 11:08:52.035: E/AndroidRuntime(826):  at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
10-08 11:08:52.035: E/AndroidRuntime(826):  at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
10-08 11:08:52.035: E/AndroidRuntime(826):  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
10-08 11:08:52.035: E/AndroidRuntime(826):  at java.util.concurrent.FutureTask.run(FutureTask.java:137)
10-08 11:08:52.035: E/AndroidRuntime(826):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1081)
10-08 11:08:52.035: E/AndroidRuntime(826):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:574)
10-08 11:08:52.035: E/AndroidRuntime(826):  at java.lang.Thread.run(Thread.java:1020)
10-08 11:08:52.035: E/AndroidRuntime(826): Caused by: java.lang.ExceptionInInitializerError
10-08 11:08:52.035: E/AndroidRuntime(826):  at com.androidhive.googleplacesandmaps.MainActivity$LoadPlaces.doInBackground(MainActivity.java:170)
10-08 11:08:52.035: E/AndroidRuntime(826):  at com.androidhive.googleplacesandmaps.MainActivity$LoadPlaces.doInBackground(MainActivity.java:1)
10-08 11:08:52.035: E/AndroidRuntime(826):  at android.os.AsyncTask$2.call(AsyncTask.java:252)
10-08 11:08:52.035: E/AndroidRuntime(826):  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
10-08 11:08:52.035: E/AndroidRuntime(826):  ... 4 more
10-08 11:08:52.035: E/AndroidRuntime(826): Caused by: java.lang.NoClassDefFoundError: com.google.api.client.http.javanet.NetHttpTransport
10-08 11:08:52.035: E/AndroidRuntime(826):  at com.androidhive.googleplacesandmaps.GooglePlaces.<clinit>(GooglePlaces.java:23)
10-08 11:08:52.035: E/AndroidRuntime(826):  ... 8 more
10-08 11:08:53.145: E/WindowManager(826): Activity com.androidhive.googleplacesandmaps.MainActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@40936608 that was originally added here
10-08 11:08:53.145: E/WindowManager(826): android.view.WindowLeaked: Activity com.androidhive.googleplacesandmaps.MainActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@40936608 that was originally added here
10-08 11:08:53.145: E/WindowManager(826):   at android.view.ViewRoot.<init>(ViewRoot.java:288)
10-08 11:08:53.145: E/WindowManager(826):   at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:249)
10-08 11:08:53.145: E/WindowManager(826):   at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:193)
10-08 11:08:53.145: E/WindowManager(826):   at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:118)
10-08 11:08:53.145: E/WindowManager(826):   at android.view.Window$LocalWindowManager.addView(Window.java:532)
10-08 11:08:53.145: E/WindowManager(826):   at android.app.Dialog.show(Dialog.java:269)
10-08 11:08:53.145: E/WindowManager(826):   at com.androidhive.googleplacesandmaps.MainActivity$LoadPlaces.onPreExecute(MainActivity.java:162)
10-08 11:08:53.145: E/WindowManager(826):   at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:549)
10-08 11:08:53.145: E/WindowManager(826):   at android.os.AsyncTask.execute(AsyncTask.java:499)
10-08 11:08:53.145: E/WindowManager(826):   at com.androidhive.googleplacesandmaps.MainActivity.onCreate(MainActivity.java:102)
10-08 11:08:53.145: E/WindowManager(826):   at android.app.Activity.performCreate(Activity.java:4397)
10-08 11:08:53.145: E/WindowManager(826):   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
10-08 11:08:53.145: E/WindowManager(826):   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1779)
10-08 11:08:53.145: E/WindowManager(826):   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1831)
10-08 11:08:53.145: E/WindowManager(826):   at android.app.ActivityThread.access$500(ActivityThread.java:122)
10-08 11:08:53.145: E/WindowManager(826):   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1024)
10-08 11:08:53.145: E/WindowManager(826):   at android.os.Handler.dispatchMessage(Handler.java:99)
10-08 11:08:53.145: E/WindowManager(826):   at android.os.Looper.loop(Looper.java:132)
10-08 11:08:53.145: E/WindowManager(826):   at android.app.ActivityThread.main(ActivityThread.java:4123)
10-08 11:08:53.145: E/WindowManager(826):   at java.lang.reflect.Method.invokeNative(Native Method)
10-08 11:08:53.145: E/WindowManager(826):   at java.lang.reflect.Method.invoke(Method.java:491)
10-08 11:08:53.145: E/WindowManager(826):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
10-08 11:08:53.145: E/WindowManager(826):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
10-08 11:08:53.145: E/WindowManager(826):   at dalvik.system.NativeStart.main(Native Method)

我搜索以解决错误,但无法成功。我怎样才能克服这些错误?或者任何人都可以为我提供更好的解决方案来找到附近的位置吗?

4

1 回答 1

2

Your jars are not being added properly. You must explicit add library reference of google-http-client-1.5.0-beta.jar(right click project->Properties->Java Build Path->Add External JARs), don't believe class path. If you do not do this, in the apk file does not contain the required data. You can download Google plus library from here

Hmm... not working...??? Make sure one more thing as in pic that all options are checked e.g : enter image description here

于 2013-10-08T06:03:44.547 回答