Android Studio Error when Creating a Project with a Google Maps Activity

google maps android studio
google map activity
how to make an app with google maps
google api android studio
google map library android
integrating google maps into app
google map setup
google maps implementation

When I create a new project in Android Studio with a Google Maps Activity I get the following error when I do the initial build of the project:

Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91 is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory). Suggestion: add 'tools:replace="android:appComponentFactory"' to element at AndroidManifest.xml:12:5-41:19 to override.

When I add:

tools:replace="android:appComponentFactory

to my AndroidManifest.xml file I get the error below:

Manifest merger failed with multiple errors, see logs

I've found several potential solutions on StackOverflow but none work.

I've tried several potential solutions that I've found on StackOverflow including:

  • migrating to AndroidX

  • Adding the following lines to my manifest

tools:replace="android:appComponentFactory android:appComponentFactory="whateverString"

  • Removing implementation com.android.support:appcompat-v7:28.0.0-rc01

Main Activity code

import android.support.v4.app.FragmentActivity;
import android.os.Bundle;

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.MarkerOptions;

public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {

    private GoogleMap mMap;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_maps);
        // 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);
    }

Android Manifest:

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">

    <!--
         The API key for Google Maps-based APIs is defined as a string resource.
         (See the file "res/values/google_maps_api.xml").
         Note that the API key is linked to the encryption key used to sign the APK.
         You need a different API key for each encryption key, including the release key that is used to
         sign the APK for publishing.
         You can define the keys for the debug and release targets in src/debug/ and src/release/.
    -->
    <meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="@string/google_maps_key" />

    <activity
        android:name=".MapsActivity"
        android:label="@string/title_activity_maps">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

Migrating to androidX should do the trick, add these two flags to your gradle.properties file. Refactor by going to Refactor > Migrate to AndroidX in android studio menu bar

android.useAndroidX=true
android.enableJetifier=true

I cannot use Google Maps API even with default project Android , I cannot use Google Maps API even with default project Android Studio created. tutorial and just created Google Maps Activity and create API key and the first error (My coworker is successful in using GoogleMaps API on  Creating the Project in Android Studio. To get started, we need to create an Android project and select Google maps activity. 2. Steps for getting the Google Map API key:

The answer should be tied to AndroidX and making sure you have all support libraries migrated to AndroidX. This would include design libraries. I had the same issue and once I migrated them over it worked. Check out all possible libraries here https://developer.android.com/jetpack/androidx/migrate

Get Started | Maps SDK for Android, Follow these steps to create a new app project including a map activity: Start Android Android Studio starts Gradle and builds your project. This may take a few  The Google map can be implemented easily in android studio project because android studio gives a ready to use activity. There are few things you have to do to reach this point, first make a new android studio project or open an existing one. In the root directory right-click on the folder and select the new activity and Google Maps Activity.

All you need to do is to update your android studio and you are good to go. I created a new project and it ran fine.

Project Configuration | Maps SDK for Android, Project and module organization; Gradle-based build system; Dependencies; Test code any actual path maps that could be used to specify any unresolved relative paths, path variables, Click Add No Activity, and then click Finish. While Eclipse ADT uses the Android Support Library and Google Play services Library,  Step 1: Create a new project and name It MapExample. Step 2: Open Gradle Scripts > build.gradle and add Retrofit and RecyclerView Library dependency in it. apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultConfig { applicationId "com.abhiandroid.MapRouteExample" minSdkVersion 15 targetSdkVersion 23 versionCode 1 versionName "1.0

Migrate to Android Studio, Create a new Android Studio project. Name the new app "Wander". Accept the defaults until you get to the Add an Activity page. Select the Google Maps Activity​  Add Google Play services to Android Studio. Step 3. Create a Google Maps project. Follow these steps to create a new app project including a map activity: Start Android Studio. Create a new project as follows: If you see the Welcome to Android Studio dialog, choose Start a new Android Studio project, available under 'Quick Start' on the right

9.1: Adding a Google Map to your app · GitBook, Step 1: Create a New Android Project and name it GoogleMaps. Step 2: Now select Google Maps Activity and then click Next and finish. Step 5: Now open build.gradle and add compile 'com.google.android.gms:play-services:8.4.0' in  Android Google Maps Tutorial. November 10, 2017. Google maps can be integrated into your android application using Google maps Android API which is part of Google play services API. For that, you need to include Google play services client library in your project and use Google maps Android API to implement maps feature in your app.

Google Maps Tutorial With Example In Android Studio [Step by Step], In this lesson, you will create a Google Maps app called Wander that displays customized maps and If you run into any issues (code bugs, grammatical errors​, unclear wording, etc.) How to refactor code and rename variables using Android Studio. Follow the prompts to create a project in the Google API Console. Create an activity. To create the activity under test, add the code shown in the following snippet: @RunWith(AndroidJUnit4::class) class MyTestSuite { @Test fun testEvent() { val scenario = launchActivity<MyActivity>() } } After creating the activity, ActivityScenario transitions the activity to the RESUMED state. This state indicates that your

Comments
  • Actually I would rather not use androidx. It was just a suggestion on another question that I thought was worth trying.