Appcompat Dependencies Error When Add Firebase To App

I develop a simple app that shows me the IMEI of the device and the Latitude and Longitude after pressing a button. Now, I want to save this data (lat, long, IMEI) in FireStore, and I have some understanding problem where and what should I do to save this data into firestore. When I try I add realtime firebase to my app from tools I have some errors

I have tried to change the dependencies version but it's not fixing the problem.

package com.example.locatieimei;

import android.Manifest;
import android.content.Context;
import android.location.Location;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;


import org.w3c.dom.Text;

public class MainActivity extends AppCompatActivity {

private FusedLocationProviderClient client;
private TextView imei;

protected void onCreate(Bundle savedInstanceState) {
    imei = findViewById(;

    client = LocationServices.getFusedLocationProviderClient(this);
    Button button = findViewById(;
    button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            if (ActivityCompat.checkSelfPermission(MainActivity.this, 
 Manifest.permission.ACCESS_FINE_LOCATION) != 
 PackageManager.PERMISSION_GRANTED && 
 Manifest.permission.ACCESS_COARSE_LOCATION) != 
                // TODO: Consider calling
                //    ActivityCompat#requestPermissions
                // here to request the missing permissions, and then 
                //   public void onRequestPermissionsResult(int 
requestCode, String[] permissions,
                //                                          int[] 
                 // to handle the case where the user grants the 
permission. See the documentation
                // for ActivityCompat#requestPermissions for more details.
OnSuccessListener<Location>() {
                public void onSuccess(Location location) {
                    if (location!=null){
                        TextView textView = findViewById(;

                        Double longitude = location.getLongitude();
                        Double latitude = location.getLatitude();





public void loadIMEI() {
    // Check if the READ_PHONE_STATE permission is already available.
    if (ActivityCompat.checkSelfPermission(this, 
            != PackageManager.PERMISSION_GRANTED) {
        if (ActivityCompat.shouldShowRequestPermissionRationale(this,
                Manifest.permission.READ_PHONE_STATE)) {
//                get_imei_data();
        } else {
            ActivityCompat.requestPermissions(this, new String[] 
    } else {

        TelephonyManager mngr = 

        IMEI = mngr.getDeviceId();

        // READ_PHONE_STATE permission is already been granted.

private String device_unique_id;
private static String IMEI;
private static final int MY_PERMISSIONS_REQUEST_READ_PHONE_STATE = 0;


those are the errors

    ERROR: In project 'app' a resolved Google Play services library dependency 
    depends on another at an exact version (e.g. "[11.0.
    1]", but isn't being resolved to that version. Behavior exhibited by the 
    library will be unknown.

    Dependency failing: - 
    >[email protected][
    11.0.1], but play-services-tasks version was 16.0.1.

    The following dependencies are project dependencies that are direct or 
    have transitive dependencies that lead to the art
    ifact with the issue.
    -- Project 'app' depends onto 
    [email protected]{strictly 16.0.4}
    -- Project 'app' depends onto 
    [email protected]{strictly 16.0.1}
    -- Project 'app' depends onto 
    [email protected]{strictly 16.0.1}
    -- Project 'app' depends onto[email protected]
    -- Project 'app' depends onto 
    [email protected]{strictly 16.0.3}
    -- Project 'app' depends onto 
    [email protected]{strictly 11.0.1}
    -- Project 'app' depends onto 
    [email protected]

    For extended debugging info execute Gradle from the command line with 
    ./gradlew --info :app:assembleDebug to see the dep
    endency paths to the artifact. This error message came from the google- 
    services Gradle plugin, report issues at https:// and disable by adding 
    "googleServices { disableVersionCheck = false }" to your b
    uild.gradle file.

 And if i change to 17.0.0 version from 11.0.1 in ' 
services-location:17.0.0' the it is showing the following error

    ERROR: Manifest merger failed : Attribute [email protected] 
    value=( from 
    [] AndroidManifest.xml:22:18-91
    is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 
    Suggestion: add 'tools:replace="android:appComponentFactory"' to 
    <application> element at AndroidManifest.xml:10:5-24:19 to override.



This release is a MAJOR version update and breaking change.

The latest update to Google Play services and Firebase includes the following changes:

Migration from Android Support Libraries to Jetpack (AndroidX) Libraries. Libraries will not work unless you make the following changes in your app:

  • Upgrade to v3.2.1 or later.
  • Upgrade compileSdkVersion to 28 or later.
  • Update your app to use Jetpack

(AndroidX); follow the instructions in Migrating to AndroidX.

Firebase Bill of Materials (BoM)

The problem is the latest firebase and play-services dependencies are migrated to androidx. So one fix is to migrate your project to androidx, see migrate to androidx (which I prefer because all the new upgrades are using androidx). Or else you can downgrade the firebase-core and play services to version before this update.