0

I created new activity which is map activity. I think I have problem in AndroidManofest.xml. My phone works perfectly if I create new project with just map activity. If I add it to my project, which has a lot of activities, it does not work. I do not know why.

the problem is about the activities AndroidManofest.xml

I checked every thing APU is enable

AndroidManofest.xml

    <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.abdullahalhajri.smarttutor">

    <!--
         The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
         Google Maps Android API v2, but you must specify either coarse or fine
         location permissions for the 'MyLocation' functionality. 
    -->
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".activities.LoginActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".activities.RegisterActivity"
            android:screenOrientation="portrait" />
        <activity
            android:name=".activities.HomePage"
            android:screenOrientation="portrait" />
        <activity
            android:name=".activities.SearchPage"
            android:screenOrientation="portrait" />
        <activity
            android:name=".activities.SearchRating"
            android:screenOrientation="portrait" />
        <activity
            android:name=".activities.SearchSubject"
            android:screenOrientation="portrait" />
        <activity
            android:name=".activities.MathTutor"
            android:screenOrientation="portrait" />
        <activity
            android:name=".activities.ReviewComment"
            android:screenOrientation="portrait" />
        <activity
            android:name=".activities.TutorProfile"
            android:screenOrientation="portrait" />
        <activity
            android:name=".activities.UsersActivity"
            android:screenOrientation="portrait" />
        <activity
            android:name="com.google.android.gms.ads.AdActivity"
            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
            android:theme="@android:style/Theme.Translucent" />

        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />

        <!--
             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=".activities.MapsActivity"
            android:label="@string/title_activity_maps">

        </activity>
    </application>

</manifest>

Error

12-04 04:31:22.639 25820-26431/com.example.abdullahalhajri.smarttutor E/Google Maps Android API: In the Google Developer Console (https://console.developers.google.com)
                                                                                                 Ensure that the "Google Maps Android API v2" is enabled.
                                                                                                 Ensure that the following Android Key exists:
                                                                                                    API Key: <<redacted>>

3 Answers3

0

change your google Map API key. you cant use Same Api key in different projects

Kapil Parmar
  • 881
  • 8
  • 19
0

Use backup key:

 <meta-data
    android:name="com.google.android.backup.api_key"
    android:value="backupkey" />
jakir hussain
  • 316
  • 2
  • 18
0

Go to the Google Developer console then click on the 'Enable API's and Services' option along with plus icon on the top of the Dashboard tab.Then there is a 'Google Maps Api' option under the Maps Category,select that then there is 'Manage' option which will enable your google maps apis.

After then you can create the map key for your project using your package name and then use it in your manifest.

Note- After using key please reinstall your app ones to reflect the map changes.

sanil
  • 482
  • 1
  • 7
  • 23