我的手机中没有显示地图活动,因为我有很多活动

时间:2017-12-04 10:48:34

标签: java android google-maps

我创建了一个新活动,即地图活动。我想我AndroidManofest.xml有问题。 如果我使用地图活动创建新项目,我的手机将完美运行。如果我将它添加到我的项目,它有很多活动,它不起作用。我不知道为什么。

问题在于活动   AndroidManofest.xml

我检查了APU启用的所有内容

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>

错误

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 个答案:

答案 0 :(得分:0)

更改您的Google地图set < string, cmp > genPerm ( const string& ); 。你不能在不同的项目中使用相同的API key Api

答案 1 :(得分:0)

使用备用密钥:

 <meta-data
    android:name="com.google.android.backup.api_key"
    android:value="backupkey" />

答案 2 :(得分:0)

转到Google Developer控制台,然后点击启用API和服务&#39;选项以及“信息中心”标签顶部的加号图标。然后是“谷歌地图Api”#39;地图类别下的选项,选择该选项然后有&#39;管理&#39;选项将启用您的谷歌地图apis。

之后,您可以使用包名为项目创建地图密钥,然后在清单中使用它。

注意 - 使用密钥后,请重新安装应用程序以反映地图更改。