为什么谷歌地图API第2不工作的API 8和更低? [英] Why google maps api v2 not working on api 8 and lower?

查看:147
本文介绍了为什么谷歌地图API第2不工作的API 8和更低?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发展与 Google地图应用API V2 谷歌播放服务并i'ts当我尝试运行我的API级别8应用做工精细。但设备(XPERIA弧/旧设备),它不加载并坠毁。 但较高的API的设备它的正常工作(如:S4,注3,S5)。

I'm develop app with google maps api v2 from google play service and i'ts work fine .but when i try to run my app on api level 8 device.(xperia arc/old device) it is not loaded and crashed. but on higher api's device it's works fine(like: s4,note3,s5).

我得到了我的位置是这样的信息:

I get the information about my location like this:

    LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);

    Criteria criteria = new Criteria();
    String provider = locationManager.getBestProvider(criteria, true);
    Location location = locationManager.getLastKnownLocation(provider);
    double latitude = location.getLatitude();
    double longitude = location.getLongitude();

    //Get location info
    Geocoder gc = new Geocoder(this);
    List<Address> list = gc.getFromLocation(latitude, longitude, 1);
    String country = list.get(0).getCountryName();
    String city = list.get(0).getLocality();
    String street = list.get(0).getAddressLine(0);

    Toast.makeText(MainActivity.this,"country: "+country+"\nCity: "+city+"\nAddress: "+street, 2000).show();

logcat的错误:

logcat error:

05-19 00:17:11.876: E/AndroidRuntime(2201): FATAL EXCEPTION: main
05-19 00:17:11.876: E/AndroidRuntime(2201): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.bis.work/com.bis.work.MainActivity}: java.lang.NullPointerException
05-19 00:17:11.876: E/AndroidRuntime(2201):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1659)
05-19 00:17:11.876: E/AndroidRuntime(2201):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1675)
05-19 00:17:11.876: E/AndroidRuntime(2201):     at android.app.ActivityThread.access$1500(ActivityThread.java:121)
05-19 00:17:11.876: E/AndroidRuntime(2201):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:943)
05-19 00:17:11.876: E/AndroidRuntime(2201):     at android.os.Handler.dispatchMessage(Handler.java:99)
05-19 00:17:11.876: E/AndroidRuntime(2201):     at android.os.Looper.loop(Looper.java:130)
05-19 00:17:11.876: E/AndroidRuntime(2201):     at android.app.ActivityThread.main(ActivityThread.java:3701)
05-19 00:17:11.876: E/AndroidRuntime(2201):     at java.lang.reflect.Method.invokeNative(Native Method)
05-19 00:17:11.876: E/AndroidRuntime(2201):     at java.lang.reflect.Method.invoke(Method.java:507)
05-19 00:17:11.876: E/AndroidRuntime(2201):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
05-19 00:17:11.876: E/AndroidRuntime(2201):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)
05-19 00:17:11.876: E/AndroidRuntime(2201):     at dalvik.system.NativeStart.main(Native Method)
05-19 00:17:11.876: E/AndroidRuntime(2201): Caused by: java.lang.NullPointerException
05-19 00:17:11.876: E/AndroidRuntime(2201):     at com.bibas.workclock.MainActivity.map(MainActivity.java:1890)
05-19 00:17:11.876: E/AndroidRuntime(2201):     at com.bibas.workclock.MainActivity.onCreate(MainActivity.java:150)
05-19 00:17:11.876: E/AndroidRuntime(2201):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-19 00:17:11.876: E/AndroidRuntime(2201):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1623)
05-19 00:17:11.876: E/AndroidRuntime(2201):     ... 11 more

我该如何解决? 感谢的:)

how can i fix it? thank's :)

推荐答案

您需要使用谷歌播放服务升级Froyo 这是现在从分离谷歌播放服务如果你需要支持旧版本。还是谷歌播放服务升级Froyo 将努力在新版本太多,所以你并不需要2个独立的应用程序,虽然建立。

You need to use Google Play Services for Froyo which is now separate from Google Play Services if you need to support older versions. still Google Play Services for Froyo will work on newer versions too so you do not need 2 separate app builds though.

请参阅: http://developer.android.com/google/play-服务/ setup.html

注:谷歌播放服务4.0.30(2013年11月发布)和新   版本需要的Andr​​oid 2.3或更高版本。如果您的应用程序支持的Andr​​oid   2.2,您可以继续发展与谷歌播放服务SDK,而必须安装谷歌从SDK播放服务升级Froyo   经理。

Note: Google Play services 4.0.30 (released November 2013) and newer versions require Android 2.3 or higher. If your app supports Android 2.2, you can continue development with the Google Play services SDK, but must instead install Google Play services for Froyo from the SDK Manager.

这篇关于为什么谷歌地图API第2不工作的API 8和更低?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆