Я получаю ошибку 13 в месте автозаполнения фрагмента - PullRequest
0 голосов
/ 25 ноября 2018

Я пытаюсь использовать PlaceAutocompleteFragment, но всякий раз, когда я нажимаю на строку поиска, она просто закрывает ее и переходит к onError и показывает это как сообщение об ошибке:

error : 13
error : Status{statusCode=ERROR, resolution=null}  

Я отправляю сообщениевесь Logcat:

 11-25 03:43:50.569 2321-2321/com.example.admin.nearbyplaces D/AppTracker: App Event: stop
11-25 03:43:50.687 2321-2321/com.example.admin.nearbyplaces I/zzbz: Making Creator dynamically
11-25 03:43:50.699 2321-2321/com.example.admin.nearbyplaces I/DynamiteModule: Considering local module com.google.android.gms.maps_dynamite:0 and remote module com.google.android.gms.maps_dynamite:221
    Selected remote version of com.google.android.gms.maps_dynamite, version >= 221
11-25 03:43:50.710 2321-2321/com.example.admin.nearbyplaces I/asset: Successfully loaded resource /system/framework/oxygen-framework-res.apk
11-25 03:43:50.731 2321-2321/com.example.admin.nearbyplaces W/System: ClassLoader referenced unknown path: /data/data/com.google.android.gms/app_chimera/m/00000048/n/armeabi-v7a
11-25 03:43:50.732 2321-2321/com.example.admin.nearbyplaces W/System: ClassLoader referenced unknown path: /data/data/com.google.android.gms/app_chimera/m/00000048/n/armeabi
11-25 03:43:50.736 2321-2321/com.example.admin.nearbyplaces I/asset: Successfully loaded resource /system/framework/oxygen-framework-res.apk
11-25 03:43:50.781 2321-2321/com.example.admin.nearbyplaces I/Google Maps Android API: Google Play services client version: 11400000
11-25 03:43:50.796 2321-2321/com.example.admin.nearbyplaces I/Google Maps Android API: Google Play services package version: 14574018
11-25 03:43:51.295 2321-2589/com.example.admin.nearbyplaces W/System: ClassLoader referenced unknown path: /system/framework/tcmclient.jar
11-25 03:43:51.355 2321-2321/com.example.admin.nearbyplaces D/AppTracker: App Event: start
11-25 03:43:51.362 2321-2321/com.example.admin.nearbyplaces I/Choreographer: Skipped 45 frames!  The application may be doing too much work on its main thread.
11-25 03:43:51.404 2321-2321/com.example.admin.nearbyplaces D/AbstractTracker: Event success
11-25 03:43:51.416 2321-2321/com.example.admin.nearbyplaces D/===SelectMapActivity: map ready
11-25 03:43:51.428 2321-2321/com.example.admin.nearbyplaces D/AbstractTracker: Event success
11-25 03:43:51.658 2321-2331/com.example.admin.nearbyplaces I/art: Background partial concurrent mark sweep GC freed 12870(1308KB) AllocSpace objects, 25(3MB) LOS objects, 40% free, 22MB/37MB, paused 7.348ms total 38.169ms
11-25 03:43:51.796 2321-2331/com.example.admin.nearbyplaces I/art: Background sticky concurrent mark sweep GC freed 2303(79KB) AllocSpace objects, 2(2MB) LOS objects, 4% free, 36MB/37MB, paused 9.847ms total 37.316ms
11-25 03:43:53.378 2321-2646/com.example.admin.nearbyplaces W/DynamiteModule: Local module descriptor class for com.google.android.gms.googlecertificates not found.
11-25 03:43:53.392 2321-2646/com.example.admin.nearbyplaces I/DynamiteModule: Considering local module com.google.android.gms.googlecertificates:0 and remote module com.google.android.gms.googlecertificates:4
    Selected remote version of com.google.android.gms.googlecertificates, version >= 4
11-25 03:43:53.402 2321-2646/com.example.admin.nearbyplaces W/System: ClassLoader referenced unknown path: /data/data/com.google.android.gms/app_chimera/m/00000047/n/armeabi-v7a
11-25 03:43:53.404 2321-2646/com.example.admin.nearbyplaces W/System: ClassLoader referenced unknown path: /data/data/com.google.android.gms/app_chimera/m/00000047/n/armeabi
11-25 03:43:53.409 2321-2646/com.example.admin.nearbyplaces I/asset: Successfully loaded resource /system/framework/oxygen-framework-res.apk

Вот активность:

    public class SelectMapActivity extends AppCompatActivity implements OnMapReadyCallback, View.OnClickListener{
    Context context;
//    Toolbar toolbar;
    @BindView(R.id.btn_searchMap)
    Button btnSearchMap;
    private PlaceAutocompleteFragment placeAutocompleteFragment;
    double latitude = 28.5535361 , longitude = 77.0986829;
    private MapView mapView;
    LatLng latLng = null;
    Marker mapMarker;
    GoogleMap map;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_select_location);
        ButterKnife.bind(this);
        context = this;

        MapsInitializer.initialize(SelectMapActivity.this);
        mapView = (MapView) findViewById(R.id.mapView_searchMap);
        mapView.onCreate(savedInstanceState);
        mapView.getMapAsync(this);

        placeAutocompleteFragment = (PlaceAutocompleteFragment) this.getFragmentManager().findFragmentById(R.id.place_autocomplete_fragment);

        AutocompleteFilter autocompleteFilter = new AutocompleteFilter.Builder().setTypeFilter(AutocompleteFilter.TYPE_FILTER_ADDRESS).build();

        placeAutocompleteFragment.setFilter(autocompleteFilter);

        placeAutocompleteFragment.setOnPlaceSelectedListener(new PlaceSelectionListener() {
            @Override
            public void onPlaceSelected(Place place) {
                Toast.makeText(getApplicationContext(), place.getName().toString(), Toast.LENGTH_SHORT).show();
                Log.d("===autoCompleteGoogle", "place  : lat : " + place.getLatLng().latitude + " lon : " + place.getLatLng().longitude);
                latitude = place.getLatLng().latitude;
                longitude = place.getLatLng().longitude;

                btnSearchMap.setVisibility(View.VISIBLE);
                createMarker(latitude,longitude,place.getName().toString());
            }

            @Override
            public void onError(Status status) {

                Log.d("===autoCompleteGoogle", "error : " + status.getStatusMessage());
                Log.d("===autoCompleteGoogle", "error : " + status.getStatusCode());
                Log.d("===autoCompleteGoogle", "error : " + status.getStatus());
                Log.d("===autoCompleteGoogle", "error : " + status.getResolution());

            }
        });
    }

    private void createMarker(double latitude, double longitude, String name) {
        BitmapDescriptor icon = BitmapDescriptorFactory.defaultMarker();

        latLng = new LatLng(latitude,longitude);
        if(mapMarker!=null)
            mapMarker.remove();
        mapMarker =  map.addMarker(new MarkerOptions()
                .position(latLng)
                .anchor(0.5f, 0.5f)
                .title(name)
                .icon(icon));

        CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(latLng, 10);
        map.animateCamera(cameraUpdate);

    }

    public void onResume() {
        super.onResume();
        mapView.onResume();
    }

    ;

    public void onPause() {
        super.onPause();
        mapView.onPause();
    }

    ;

    public void onDestroy() {
        super.onDestroy();
        mapView.onDestroy();
    }

    ;

    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        mapView.onSaveInstanceState(outState);
    }

    ;

    public void onLowMemory() {
        super.onLowMemory();
        mapView.onLowMemory();
    }

    GoogleMap.OnMarkerClickListener onMarkerClickListener = new GoogleMap.OnMarkerClickListener() {
        @Override
        public boolean onMarkerClick(Marker marker) {
            String title = marker.getTitle();

            return false;
        }
    };

    GoogleMap.OnInfoWindowClickListener onInfoWindowClickListener = new GoogleMap.OnInfoWindowClickListener() {

        @Override
        public void onInfoWindowClick(Marker marker) {
            String title = marker.getTitle();
        }
    };
    @Override
    public void onMapReady(GoogleMap googleMap) {
        Log.d("===SelectMapActivity","map ready");
        map = googleMap;
        map.setOnMarkerClickListener(onMarkerClickListener);
        map.setOnInfoWindowClickListener(onInfoWindowClickListener);
        //set marker here
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.btn_searchMap:
                if(latitude!=0&&longitude!=0) {
                    Intent intent = new Intent(this, MainActivity.class);
                    intent.putExtra("latitude", latitude);
                    intent.putExtra("longitude", longitude);
                    startActivity(intent);
                    Toast.makeText(this, "clicked", Toast.LENGTH_SHORT).show();
                }

        }
    }
}  
...