有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java生成Google地图发布密钥

所以我在我的应用程序中使用谷歌地图api。我添加了活动,并将api密钥放入google_maps_api。然后创建了一个不同的api密钥,并将其放入google_maps_api。xml在/release下,我必须去文件浏览器找到它。如果我在安卓 studio中通过绿色的play按钮启动应用程序,地图加载就可以了。但当我在构建下生成apk时,地图不会加载。我相信这是因为api不起作用。我担心的一个问题是,编辑google_maps_api(发布版)的唯一方法是在浏览器中找到它。非常感谢您的帮助

以下是清单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
    package="com.nick.mowen.receiptmanager" >

    <uses-permission 安卓:name="安卓.permission.ACCESS_FINE_LOCATION" />
    <uses-permission 安卓:name="安卓.permission.INTERNET" />
    <uses-permission 安卓:name="安卓.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission 安卓:name="安卓.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission 安卓:name="安卓.permission.ACCESS_COARSE_LOCATION" />

    <application
        安卓:allowBackup="true"
        安卓:fullBackupContent="true"
        安卓:icon="@mipmap/ic_launcher"
        安卓:label="@string/app_name"
        安卓:theme="@style/AppTheme" >

        <service 安卓:name=".GeofenceTransitionsIntentService" />

        <activity
            安卓:name=".MainActivity"
            安卓:label="@string/app_name" >
            <intent-filter>
                <action 安卓:name="安卓.intent.action.MAIN" />

                <category 安卓:name="安卓.intent.category.LAUNCHER" />
            </intent-filter>

            <meta-data
                安卓:name="安卓.app.default_searchable"
                安卓:value=".SearchableActivity" />
        </activity>
        <activity
            安卓:name=".SettingsActivity"
            安卓:label="@string/Settings"
            安卓:parentActivityName=".MainActivity" >
            <meta-data
                安卓:name="安卓.support.PARENT_ACTIVITY"
                安卓:value=".MainActivity" />
        </activity>
        <activity
            安卓:name=".ViewCodeActivity"
            安卓:label="Receipt Code"
            安卓:parentActivityName=".MainActivity" >
            <meta-data
                安卓:name="安卓.support.PARENT_ACTIVITY"
                安卓:value=".MainActivity" />
        </activity>
        <activity
            安卓:name=".GetHelp"
            安卓:label="@string/get_help_title"
            安卓:parentActivityName=".SettingsActivity" >
            <meta-data
                安卓:name="安卓.support.PARENT.ACTIVITY"
                安卓:value=".SettingsActivity" />
        </activity>
        <activity
            安卓:name=".CodeAdder"
            安卓:label="@string/title_activity_code_adder"
            安卓:parentActivityName=".MainActivity"
            安卓:theme="@style/AppTheme.NoActionBar" >
            <meta-data
                安卓:name="安卓.support.PARENT_ACTIVITY"
                安卓:value="com.nick.mowen.receiptmanager.MainActivity" />
        </activity>
        <activity 安卓:name=".SearchActivity" >
            <intent-filter>
                <action 安卓:name="安卓.intent.action.SEARCH" />
            </intent-filter>

            <meta-data
                安卓:name="安卓.app.searchable"
                安卓:resource="@xml/searchable" />
        </activity>
        <!--
             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
            安卓:name="com.google.安卓.geo.API_KEY"
            安卓:value="@string/google_maps_key" />

        <activity
            安卓:name=".LocationPicker"
            安卓:label="@string/title_activity_location_picker" >
            <meta-data
                安卓:name="安卓.support.PARENT_ACTIVITY"
                安卓:value="com.nick.mowen.receiptmanager.CodeAdder" />

            <intent-filter>
                <action 安卓:name="安卓.intent.action.MAIN" />

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

</manifest>

这是构建。格雷德尔:

apply plugin: 'com.安卓.application'

安卓 {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "com.nick.mowen.receiptmanager"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-安卓.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.安卓.support:appcompat-v7:23.0.1'
    compile 'com.安卓.support:design:23.0.1'
    compile 'com.安卓.support:recyclerview-v7:23.0.1'
    compile 'com.google.安卓.gms:play-services-maps:8.1.0'
    compile 'com.google.安卓.gms:play-services:8.1.0'
}

共 (2) 个答案

  1. # 1 楼答案