本文介绍了在Android中查找附近位置的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注教程以获取附近的位置,我按照教程进行了每个步骤.但是,当我运行我的应用程序时,出现以下错误:

I'm following this tutorial to get nearby location, I followed each and every step as per tutorial. But when I run my app, I'm getting following errors:

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)

我进行了搜索以解决错误,但未能成功.我该如何克服这些错误?还是有人可以向我提供更好的解决方案来找到附近的位置?

I searched to solve errors, but can't succeeded. How can I overcome those errors?Or Can anyone provide me better solution to find nearby location?

推荐答案

您的jar文件未正确添加.您必须显式添加google-http-client-1.5.0-beta.jar的库引用(右键单击project-> Properties-> Java Build Path-> Add External JARs),不要相信类路径.如果不这样做,则apk文件中将不包含所需的数据.您可以从此处

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 :

这篇关于在Android中查找附近位置的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-12 22:10