Тип программы уже присутствует: com.bumptech.glide.GeneratedAppGlideModule

#java #android #google-maps #google-places

#java #Android #google-карты #google-места

Вопрос:

Я продолжаю получать эту ошибку при попытке запустить проект, даже когда я не использую зависимости Glide. Я пытаюсь реализовать карты с помощью placeAutocomplete. Тип программы уже присутствует: com.bumptech.glide.Сообщение GeneratedAppGlideModule{вид = ОШИБКА, текст= Тип программы уже присутствует: com.bumptech.glide.GeneratedAppGlideModule, исходные данные = [Неизвестный исходный файл], имя инструмента = Необязательно.of(D8)}

Вот моя сборка

 apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.rough.tuber.tuber"
        minSdkVersion 16
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    //noinspection GradleCompatible
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.google.android.libraries.places:places:1.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    //noinspection GradleCompatible
    implementation 'com.google.firebase:firebase-messaging:11.8.0'
    implementation 'com.google.firebase:firebase-storage:11.8.0'
    implementation 'com.google.firebase:firebase-auth:11.8.0'
    implementation 'com.google.firebase:firebase-firestore:11.8.0'
//    implementation 'com.google.firebase:firebase-auth:11.8.0'
  //  implementation 'com.google.android.gms:play-services-maps:11.8.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    implementation 'com.android.volley:volley:1.0.0'
    implementation 'com.google.firebase:firebase-core:11.8.0'
    implementation 'com.google.firebase:firebase-database:11.8.0'
    implementation 'com.firebase:firebase-client-android:2.4.0'
    implementation ('com.google.android.gms:play-services:11.8.0')
            {
                exclude group: 'com.google.android.gms', module: 'play-services-places'
            }
    implementation 'com.crashlytics.sdk.android:crashlytics:2.9.1'
    implementation 'com.android.support:multidex:1.0.3'


    implementation 'com.android.support:design:26.1.0'
    implementation 'com.firebaseui:firebase-ui:0.6.0'


    implementation 'com.squareup.picasso:picasso:2.71828'


}
apply plugin: 'com.google.gms.google-services'
  

Вот мой xml для карт

 <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:android="http://schemas.android.com/apk/res/android">



    <LinearLayout
        android:id="@ id/layout_panel"
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <fragment
            android:id="@ id/autocomplete_fragment"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:name="com.google.android.libraries.places.widget.AutocompleteSupportFragment"
            android:layout_margin="10dp"
            android:layout_weight="5"/>


    </LinearLayout>

    <fragment xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:map="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_below="@ id/layout_panel"
        android:id="@ id/map"
        android:name="com.google.android.gms.maps.SupportMapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true"
        tools:context=".Maps_location_Activity"
        tools:ignore="RtlCompat" />


    <ImageButton
        android:id="@ id/zoom_in"
        android:layout_width="56dp"
        android:layout_height="55dp"
        android:layout_alignParentEnd="true"
        android:layout_alignParentTop="true"
        android:layout_marginTop="52dp"
        android:onClick="onZoom"
        app:srcCompat="@android:drawable/arrow_up_float"
        tools:ignore="RtlCompat" />

    <ImageButton
        android:id="@ id/zoom_out"
        android:layout_width="57dp"
        android:layout_height="56dp"
        android:layout_alignParentEnd="true"
        android:layout_below="@ id/zoom_in"
        android:onClick="onZoom"
        app:srcCompat="@android:drawable/arrow_down_float"
        tools:ignore="RtlCompat" />

    <ImageButton
        android:id="@ id/type"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentEnd="true"
        android:layout_marginBottom="16dp"
        android:layout_marginEnd="14dp"
        android:onClick="changeType"
        app:srcCompat="@android:drawable/ic_menu_mapmode"
        tools:ignore="RtlCompat" />




</RelativeLayout>
  

И это мой Java-код.

 package com.rough.tuber.tuber;

import android.Manifest;
import android.content.pm.PackageManager;
import android.location.Address;
import android.location.Geocoder;
import android.os.Build;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

import com.google.android.gms.common.api.Status;


//import com.google.android.libraries.places.api.Places;

import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.LatLngBounds;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;

//import com.google.android.libraries.places.api.model.Place;
//import com.google.android.libraries.places.widget.AutocompleteFragment;
//import com.google.android.libraries.places.widget.AutocompleteSupportFragment;
//import com.google.android.libraries.places.widget.listener.PlaceSelectionListener;


import java.util.Arrays;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;

public class Maps_location_Activity extends FragmentActivity implements OnMapReadyCallback {

    private static final int MY_REQUEST_INT = 177;
    private GoogleMap mMap;
    private static final String TAG = "Maps_location_Activity";

Marker marker;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_maps_location_);



        /*PlaceAutocompleteFragment.setPlaceFields(Arrays.asList(Place.Field.ID, Place.Field.NAME));
        placeAutocompleteFragment.setOnPlaceSelectedListener(new PlaceSelectionListener() {
            @Override
            public void onPlaceSelected(Place place) {
                final LatLng latLagLoc = place.getLatLng();

                if (marker!=null){
                    marker.remove();
                }
                marker = mMap.addMarker(new MarkerOptions().position(latLagLoc).title(place.getName().toString()));
                mMap.animateCamera(CameraUpdateFactory.zoomTo(12),2000,null);
            }

            @Override
            public void onError(Status status) {
                Toast.makeText(Maps_location_Activity.this,"" status.toString(),Toast.LENGTH_SHORT).show();
            }
        }); */
        // Obtain the SupportMapFragment and get notified when the map is ready to be used.
        SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
                .findFragmentById(R.id.map);
        mapFragment.getMapAsync(this);


        /*if (!Places.isInitialized()) {
            Places.initialize(getApplicationContext(), "your api key");
        }
        AutocompleteSupportFragment placeAutocompleteFragment = (AutocompleteSupportFragment) getSupportFragmentManager().findFragmentById(R.id.autocomplete_fragment);

        placeAutocompleteFragment.setPlaceFields(Arrays.asList(Place.Field.ID, Place.Field.NAME));

        placeAutocompleteFragment.setOnPlaceSelectedListener(new PlaceSelectionListener() {
            @Override
            public void onPlaceSelected(Place place) {
                // TODO: Get info about the selected place.
                Log.i(TAG, "Place: "   place.getName()   ", "   place.getId());
            }

            @Override
            public void onError(Status status) {
                // TODO: Handle the error.
                Log.i(TAG, "An error occurred: "   status);
            }
        });*/
    }

/*public void onSearch(View view){
    EditText location_tf = (EditText)findViewById(R.id.Search);
    String location = location_tf.getText().toString();
List<Address> addressList = null;
    if (location != null || !location.equals("")){

        Geocoder geocoder = new Geocoder(this);

        try{
          addressList = geocoder.getFromLocationName(location,1);
        } catch (IOException e) {
            e.printStackTrace();
        }
        Address address = addressList.get(0);
        LatLng latLng = new LatLng(address.getLatitude(), address.getLongitude());
        mMap.addMarker(new MarkerOptions().position(latLng).title("This is my marker"));
        mMap.animateCamera(CameraUpdateFactory.newLatLng(latLng));

    }
}*/

public void onZoom(View view){
        if(view.getId()== R.id.zoom_in){
            mMap.animateCamera(CameraUpdateFactory.zoomIn());
        }
        if (view.getId() == R.id.zoom_out){
            mMap.animateCamera(CameraUpdateFactory.zoomOut());
        }
}
public void changeType(View view) {
    if (mMap.getMapType() == GoogleMap.MAP_TYPE_NORMAL) {
        mMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
    }
    else {
        mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
    }
}
    /**
     * Manipulates the map once available.
     * This callback is triggered when the map is ready to be used.
     * This is where we can add markers or lines, add listeners or move the camera. In this case,
     * we just add a marker near Sydney, Australia.
     * If Google Play services is not installed on the device, the user will be prompted to install
     * it inside the SupportMapFragment. This method will only be triggered once the user has
     * installed Google Play services and returned to the app.
     */
    @Override
    public void onMapReady(GoogleMap googleMap) {
        mMap = googleMap;
        mMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
mMap.getUiSettings().setAllGesturesEnabled(false);
        // Add a marker in Sydney and move the camera
       // LatLng sydney = new LatLng(0, 0);
      LatLng gate1 =   new LatLng(29.454482242994565,-98.56836338953309);
      LatLng gate2 = new LatLng(29.44891046566121,-98.56295840989685);
      LatLng gate3 = new LatLng(29.45126734383246,-98.56090615697059);
      LatLng stmu = new LatLng(29.45249260178782,-98.56478047528071);
        if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED amp;amp; ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
            // TODO: Consider calling
            //    ActivityCompat#requestPermissions
            // here to request the missing permissions, and then overriding
            //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
            //                                          int[] grantResults)
            // to handle the case where the user grants the permission. See the documentation
            // for ActivityCompat#requestPermissions for more details.
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){
                requestPermissions(new String[]{Manifest.permission.ACCESS_COARSE_LOCATION,Manifest.permission.ACCESS_FINE_LOCATION},MY_REQUEST_INT);
            }
            return;
        }
        else{
            mMap.setMyLocationEnabled(true);
        }

        mMap.addMarker(new MarkerOptions().position(new LatLng(0,0)).title("This is my marker"));

        mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(stmu,15));
    }
}
  

Я не уверен, что не так, может кто-нибудь помочь мне с этой ошибкой.

Комментарии:

1. Здесь то же самое, переход на новый Places SDK, верно?

2. Похоже, вы не используете Glide напрямую, вы можете просмотреть другие библиотеки, которые могут использовать Glide, которые конфликтуют с новейшим дополнением к вашему build.gradle (в данном случае, похоже, это Places SDK)