0

Google지도가 내 안드로이드 응용 프로그램에 있습니다. 내 안드로이드 장치의 대부분에서 내 Google지도가 제대로 작동하지만 한 장치에서 내 Google지도가 작동하지 않습니다. 내 구글 맵 클래스는 다음과 같습니다Google지도 클래스가 작동하지 않습니다.

public class Map extends Activity { 

    // Google Map 
    private GoogleMap googleMap; 
    Intent intent; 
    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.map); 

     try { 
      // Loading map 
      initilizeMap(); 


     } catch (Exception e) { 
      e.printStackTrace(); 
     } 

    } 

    /** 
    * function to load map. If map is not created it will create it for you 
    * */ 
    private void initilizeMap() { 
      double latitude = 0 ; 
      double longitude = 0; 

     if (googleMap == null) { 
      googleMap = ((MapFragment) getFragmentManager().findFragmentById(
        R.id.map)).getMap(); 


      intent=getIntent(); 

      String location=intent.getStringExtra("location"); 


     /*  GPS gps = new GPS(this); 
      if(gps.canGetLocation()){ // gps enabled} // return boolean true/false 

      latitude=gps.getLatitude(); // returns latitude 
      longitude=gps.getLongitude(); // returns longitude 
      } 
      */ 

     // Toast.makeText(getApplicationContext(), location, Toast.LENGTH_LONG).show(); 
      String[] arr = location.split(" ", 2); 
      latitude=Double.valueOf(arr[0]); 
      longitude=Double.valueOf(arr[1]); 



      // googleMap.setMyLocationEnabled(true); 
      // create marker 
      MarkerOptions marker = new MarkerOptions().position(new LatLng(latitude, longitude)); 

      // adding marker 
      googleMap.addMarker(marker); 
      CameraUpdate center= 
        CameraUpdateFactory.newLatLng(new LatLng(latitude, 
                  longitude)); 
       CameraUpdate zoom=CameraUpdateFactory.zoomTo(15); 

       googleMap.moveCamera(center); 
       googleMap.animateCamera(zoom); 

      // check if map is created successfully or not 

      if (googleMap == null) { 
       Toast.makeText(getApplicationContext(), 
         "Sorry! unable to create maps", Toast.LENGTH_SHORT) 
         .show(); 
      } 
     } 
    } 

    @Override 
    protected void onResume() { 
     super.onResume(); 
     initilizeMap(); 
    } 

} 

이 장치에 대한 나의 로그 캣은 다음과 같습니다

10-24 03:46:02.535: D/ActivityThread(3501): ACT-AM_ON_PAUSE_CALLED ActivityRecord{418378f0 [email protected] {soft.b.peopleassist/soft.b.peopleassist.Respond}} 
10-24 03:46:02.546: D/ActivityThread(3501): ACT-PAUSE_ACTIVITY handled : 1/[email protected] 
10-24 03:46:02.551: D/ThemeManager(3501): packageName=====soft.b.peopleassist 
10-24 03:46:02.551: D/ThemeManager(3501): packageName=soft.b.peopleassist 
10-24 03:46:02.551: D/RRR(3501): path=other/bottom/bottom7.png 
10-24 03:46:02.553: D/ThemeManager(3501): sIconWidth=64----sIconHeight=64 
10-24 03:46:02.555: D/ThemeManagerHH(3501): infoDrawable=72 
10-24 03:46:02.589: W/GooglePlayServicesUtil(3501): Google Play services is missing. 
10-24 03:46:02.590: W/GooglePlayServicesUtil(3501): Google Play services is missing. 
10-24 03:46:02.593: W/GooglePlayServicesUtil(3501): Google Play services is missing. 
10-24 03:46:02.596: W/GooglePlayServicesUtil(3501): Google Play services is missing. 
10-24 03:46:02.598: W/GooglePlayServicesUtil(3501): Google Play services is missing. 
10-24 03:46:02.603: W/GooglePlayServicesUtil(3501): Google Play services is missing. 
10-24 03:46:02.605: W/System.err(3501): java.lang.NullPointerException 
10-24 03:46:02.606: W/System.err(3501):  at soft.b.peopleassist.Map.initilizeMap(Map.java:76) 
10-24 03:46:02.607: W/System.err(3501):  at soft.b.peopleassist.Map.onCreate(Map.java:30) 
10-24 03:46:02.607: W/System.err(3501):  at android.app.Activity.performCreate(Activity.java:4510) 
10-24 03:46:02.608: W/System.err(3501):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1050) 
10-24 03:46:02.609: W/System.err(3501):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2048) 
10-24 03:46:02.609: W/System.err(3501):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2111) 
10-24 03:46:02.610: W/System.err(3501):  at android.app.ActivityThread.access$600(ActivityThread.java:134) 
10-24 03:46:02.610: W/System.err(3501):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1251) 
10-24 03:46:02.610: W/System.err(3501):  at android.os.Handler.dispatchMessage(Handler.java:99) 
10-24 03:46:02.611: W/System.err(3501):  at android.os.Looper.loop(Looper.java:137) 
10-24 03:46:02.612: W/System.err(3501):  at android.app.ActivityThread.main(ActivityThread.java:4666) 
10-24 03:46:02.612: W/System.err(3501):  at java.lang.reflect.Method.invokeNative(Native Method) 
10-24 03:46:02.613: W/System.err(3501):  at java.lang.reflect.Method.invoke(Method.java:511) 
10-24 03:46:02.614: W/System.err(3501):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809) 
10-24 03:46:02.614: W/System.err(3501):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576) 
10-24 03:46:02.615: W/System.err(3501):  at dalvik.system.NativeStart.main(Native Method) 
10-24 03:46:02.617: W/GooglePlayServicesUtil(3501): Google Play services is missing. 
10-24 03:46:02.618: D/AndroidRuntime(3501): Shutting down VM 
10-24 03:46:02.619: W/dalvikvm(3501): threadid=1: thread exiting with uncaught exception (group=0x40e61258) 
10-24 03:46:02.624: E/AndroidRuntime(3501): FATAL EXCEPTION: main 
10-24 03:46:02.624: E/AndroidRuntime(3501): java.lang.RuntimeException: Unable to resume activity {soft.b.peopleassist/soft.b.peopleassist.Map}: java.lang.NullPointerException 
10-24 03:46:02.624: E/AndroidRuntime(3501):  at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2602) 
10-24 03:46:02.624: E/AndroidRuntime(3501):  at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2630) 
10-24 03:46:02.624: E/AndroidRuntime(3501):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2116) 
10-24 03:46:02.624: E/AndroidRuntime(3501):  at android.app.ActivityThread.access$600(ActivityThread.java:134) 
10-24 03:46:02.624: E/AndroidRuntime(3501):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1251) 
10-24 03:46:02.624: E/AndroidRuntime(3501):  at android.os.Handler.dispatchMessage(Handler.java:99) 
10-24 03:46:02.624: E/AndroidRuntime(3501):  at android.os.Looper.loop(Looper.java:137) 
10-24 03:46:02.624: E/AndroidRuntime(3501):  at android.app.ActivityThread.main(ActivityThread.java:4666) 
10-24 03:46:02.624: E/AndroidRuntime(3501):  at java.lang.reflect.Method.invokeNative(Native Method) 
10-24 03:46:02.624: E/AndroidRuntime(3501):  at java.lang.reflect.Method.invoke(Method.java:511) 
10-24 03:46:02.624: E/AndroidRuntime(3501):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809) 
10-24 03:46:02.624: E/AndroidRuntime(3501):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576) 
10-24 03:46:02.624: E/AndroidRuntime(3501):  at dalvik.system.NativeStart.main(Native Method) 
10-24 03:46:02.624: E/AndroidRuntime(3501): Caused by: java.lang.NullPointerException 
10-24 03:46:02.624: E/AndroidRuntime(3501):  at soft.b.peopleassist.Map.initilizeMap(Map.java:76) 
10-24 03:46:02.624: E/AndroidRuntime(3501):  at soft.b.peopleassist.Map.onResume(Map.java:98) 
10-24 03:46:02.624: E/AndroidRuntime(3501):  at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1159) 
10-24 03:46:02.624: E/AndroidRuntime(3501):  at android.app.Activity.performResume(Activity.java:4584) 
10-24 03:46:02.624: E/AndroidRuntime(3501):  at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2588) 
10-24 03:46:02.624: E/AndroidRuntime(3501):  ... 12 more 

답변

1

그것은 google play services이 이후 나던 장치가지도를 사용하는 로그 캣에서 분명 당신은 google play services을 필요로하는 왜 그것이 추락하는지.

W/GooglePlayServicesUtil(3501): Google Play services is missing. 

this에 따르면, 많은 진저 브레드 폰은 구글 플레이 서비스와 함께 제공되지 않는 잘 알려진 문제입니다, 그래서 대신 당신은 사용자에게 안전하게 응용 프로그램 시작시 설치 검사를 해결하고, 필요 그들의 장치가 그것을 지원하지 않거나이 장치가 시장에서 앱을 다운로드하지 못하게합니다.

희망이 당신을 도울 수 있기를 희망하고, 무엇을 해야할지 실마리를주었습니다.

+0

단서를 주셔서 감사합니다.이 문제를 해결하는 방법을 알려주세요. – Talib

+1

수표 [우편 번호. # 2] (https://code.google.com/p/android/issues/detail?id=42543), 문제의 원인과 해결 방법에 대해 설명합니다. 나는 한번도 시도한 적이 없지만 합리적으로 보인다. – Coderji

+1

또는 사용자 장치를 감지하고 'Google Play 서비스'가 없는지 확인한 후에 수동으로 'Google Play 서비스'를 수동으로 다운로드 할 수있는 페이지로 안내 할 수 있습니다. [이 코드를 확인하십시오] (http://www.androidpolice.com/2012/09/26/google-play-services-can-now-be-installed-manually-from-the-play-store/) – Coderji

0

Google지도 API를 사용하기 전에 기기에서 Google Play 서비스를 사용할 수 있는지 확인해야합니다.

public static boolean isGooglePlayServicesAvailable(SplashScreenActivity context) { 
     int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(context); 
     if (ConnectionResult.SUCCESS == status) { 
      return true; 
     } else { 
      //GooglePlayServicesUtil.getErrorDialog(status, context, 0).show(); 
      return false; 
     } 
    } 

Google Play 서비스를 사용할 수없는 경우 사용자를 Playstore로 이동하여 Google Play 서비스를 설치할 수 있습니다.

startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id="+ GoogleApiAvailability.GOOGLE_PLAY_SERVICES_PACKAGE))); 
관련 문제