谷歌地图android api应用程序崩溃getMapAsync()

时间:2017-10-03 12:22:06

标签: google-maps-android-api-2 android-maps

  Process:*****.googlemapapp, PID: 2402

java.lang.UnsatisfiedLinkError: Couldn't load rocket from loader bvt[DexPathList[[zip file "/data/data/com.google.android.gms/app_chimera/m/00000003/DynamiteModulesB_GmsCore_prod_alldpi_release.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]]: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:358)
at java.lang.System.loadLibrary(System.java:526)
at com.google.maps.api.android.lib6.rocket.a.onSurfaceCreated(:com.google.android.gms.DynamiteModulesB:119)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1501)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)

我在运行mapFragment.getMapAsync(this)时遇到错误 我第一次工作得非常好......当我再次开始给出错误时,如上所述...一切都很好,第一次......就像奇怪它甚至适用于应用程序崩溃。

1 个答案:

答案 0 :(得分:0)

    @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    context = MapsActivity.this;
    setContentView(R.layout.activity_maps);
    MarkerPoints = new ArrayList<>();



    nextBtn = (Button) findViewById(R.id.nextBtn);
    txtDistance = (TextView) findViewById(R.id.txtDistance);
    txtCheckpoint = (TextView) findViewById(R.id.txtCheckpoint);
    txtDistance.setText("Distance Travel : 0  Mtr");
    distance = new ArrayList<Float>();
    waypoints = new ArrayList<LatLng>();

    Intent i = getIntent();
    Places place = (Places) i.getParcelableExtra("data");
    Log.d("data", place.toString());
    startPoint = place.startPoint;
    endPoint = place.endPoint;
    waypoints=place.waypoints;
    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.map);
    int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
    if(resultCode == ConnectionResult.SUCCESS)
    {
        if(mapFragment != null) {
            mapFragment.getMapAsync(this);
        }
    }else
    Toast.makeText(context, "UnAvailable", Toast.LENGTH_SHORT).show();


}
   //here application crashes on alternative run on mapFragment.getMapAsync(this) , 

所有代码第二次第一次运行正常 java.lang.UnsatisfiedLinkError:无法从加载程序bvt加载火箭[DexPathList [[zip文件“/data/data/com.google.android.gms/app_chimera/m/00000003/DynamiteModulesB_GmsCore_prod_alldpi_release.apk”], nativeLibraryDirectories = [/ vendor / lib,/ system / lib]]]: findLibrary返回null 在java.lang.Runtime.loadLibrary(Runtime.java:358)

   //i initialize maps and then according to location i change panoroma image, here Fetchurl will save the path data in routes which is  List<List<HashMap<String, String>>> it is Asynchronous call
   @Override
public void onMapReady(GoogleMap googleMap) {
    try {
        mMap = googleMap;


        MarkerPoints.add(startPoint);

        startMarker.position(startPoint);
        startMarker.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN));
        m = mMap.addMarker(startMarker);
        m.setTitle("You");
        m.showInfoWindow();
        MarkerPoints.add(endPoint);
        endMarker.position(endPoint);
        endMarker.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED));
        Marker e = mMap.addMarker(endMarker);
        e.setTitle("Goal");


        LatLng origin = MarkerPoints.get(0);
        LatLng dest = MarkerPoints.get(1);
        String url = getUrl(origin, dest);

        FetchUrl FetchUrl = new FetchUrl();
        FetchUrl.execute(url);
        //move map camera

        mMap.moveCamera(CameraUpdateFactory.newLatLng(startPoint));
        mMap.animateCamera(CameraUpdateFactory.zoomTo(11));

        initializeSteatView();
    } catch (Exception e) {

    }

}`

   ///here i initialize streatview
  ` public void initializeSteatView() {
    SupportStreetViewPanoramaFragment streetViewPanoramaFragment =
            (SupportStreetViewPanoramaFragment)
                    getSupportFragmentManager().findFragmentById(R.id.mapPanaroma);
    streetViewPanoramaFragment.getStreetViewPanoramaAsync(
            new OnStreetViewPanoramaReadyCallback() {
                @Override
                public void onStreetViewPanoramaReady(final StreetViewPanorama panorama) {
                    panorama.setUserNavigationEnabled(false);
                    panorama.setPosition(startPoint);
                    nextBtn.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            if(!isRouteLoaded)return;
                            if (currentPosition == routes.get(0).size() - 1) return;
                            if (currentPosition == 0) {

                                String s1 = routes.get(0).get(currentPosition).get("lat");
                                String s2 = routes.get(0).get(currentPosition).get("lng");
                                double d1 = Double.parseDouble(s1);
                                double d2 = Double.parseDouble(s2);
                                LatLng newPosition = new LatLng(d1, d2);
                                mMap.moveCamera(CameraUpdateFactory.newLatLng(newPosition));
                                mMap.animateCamera(CameraUpdateFactory.zoomTo(17));
                                panorama.setPosition(newPosition);

                                m.setPosition(newPosition);
                                distance.add(totalDistance);
                                for (int i = 1; i < routes.get(0).size(); i++) {
                                    d1 = Double.parseDouble(routes.get(0).get(i - 1).get("lat"));
                                    d2 = Double.parseDouble(routes.get(0).get(i - 1).get("lng"));
                                    LatLng start = new LatLng(d1, d2);
                                    d1 = Double.parseDouble(routes.get(0).get(i).get("lat"));
                                    d2 = Double.parseDouble(routes.get(0).get(i).get("lng"));
                                    LatLng end = new LatLng(d1, d2);
                                    totalDistance += calculateDistance(start, end);
                                    distance.add(totalDistance);
                                    Log.d("distance", distance.toString());
                                }
                                final Handler handler = new Handler();

                                final TimerTask timertask = new TimerTask() {
                                    @Override
                                    public void run() {
                                        handler.post(new Runnable() {
                                            public void run() {
                                                distanceTravel++;
                                                txtDistance.setText("Distance Travel : " + distanceTravel + "  Mtr");
                                                checkDistance();

                                            }
                                        });
                                    }
                                };
                                Timer timer = new Timer();
                                timer.schedule(timertask, 0, 500);
                            }


                        }

                        public void checkDistance() {
                            if (currentPosition == routes.get(0).size() - 1) return;
                            checkPoint = distance.get(currentPosition + 1);
                            txtCheckpoint.setText("Checkpoint : " + checkPoint);
                            if (checkPoint < Float.parseFloat(distanceTravel + "")) {
                                currentPosition++;
                            } else {
                                return;
                            }
                            String s1 = routes.get(0).get(currentPosition).get("lat");
                            String s2 = routes.get(0).get(currentPosition).get("lng");
                            double d1 = Double.parseDouble(s1);
                            double d2 = Double.parseDouble(s2);
                            LatLng newPosition = new LatLng(d1, d2);
                            mMap.moveCamera(CameraUpdateFactory.newLatLng(newPosition));
                            mMap.animateCamera(CameraUpdateFactory.zoomTo(17));
                            panorama.setPosition(newPosition);
                            m.setPosition(newPosition);
                        }
                    });

                    panorama.setOnStreetViewPanoramaChangeListener(new StreetViewPanorama.OnStreetViewPanoramaChangeListener() {
                        @Override
                        public void onStreetViewPanoramaChange(StreetViewPanoramaLocation streetViewPanoramaLocation) {
                            if(!isRouteLoaded)return;
                            if (routes.size() > 0) {
                                double lat1 = Double.parseDouble(routes.get(0).get(currentPosition).get("lat"));
                                double lng1 = Double.parseDouble(routes.get(0).get(currentPosition).get("lng"));
                                double lat2 = Double.parseDouble(routes.get(0).get
                                        (currentPosition + 1).get("lat"));
                                double lng2 = Double.parseDouble(routes.get(0).get
                                        (currentPosition + 1).get("lng"));
                                double dLon = (lng2 - lng1);
                                double y = Math.sin(dLon) * Math.cos(lat2);
                                double x = Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1) * Math.cos(lat2) * Math.cos(dLon);
                                double brng = Math.toDegrees((Math.atan2(y, x)));
                                //   brng = (360 - ((brng + 360) % 360));
                                long duration = 1000;
                                StreetViewPanoramaCamera camera =
                                        new StreetViewPanoramaCamera.Builder()
                                                .zoom(panorama.getPanoramaCamera().zoom)
                                                .tilt(panorama.getPanoramaCamera().tilt)
                                                .bearing(Float.parseFloat(brng + ""))
                                                .build();

                                panorama.animateTo(camera, duration);
                            }

                        }
                    });

                }


            });
}

`