Android应用程序地图片段未在发布版本中显示



我使用Map Fragment创建了一个小型android应用程序,并使用jetbrains studio对其进行了测试。我已经获得了一个API密钥,无论手机是通过USB电缆插入笔记本电脑,还是我单独携带(我需要这样做,因为它包含跟踪元素),它都能正常工作。

我通过API和服务面板启用了"Android地图SDK"API。

当我上传应用程序时,我进入了"应用程序签名"并下载了名为"deployment_cert.der"的谷歌证书编译我的应用程序

keytool-importcert-文件部署cert.der-密钥库keystore.jks

(密钥库是我将该应用程序的发布版本编译为签名apk时创建的文件;当我上传该应用程序时,谷歌没有抱怨并接受了它)

我让妻子从手机和平板电脑上的游戏商店下载应用程序来测试这个应用程序,但我得到的不是地图,而是一个灰色的盒子,角落里有谷歌标志,+/-缩放按钮,右上角有"家庭中心"圆圈。应用程序上的其他一切都在工作。

我不知道可能出了什么问题?有人能提供一些提示吗?我不知道该找什么。

我已经检查了设备兼容性,我使用过的所有设备都列在设备目录中

我的清单文件如下:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mydomain.ge">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

<application
android:allowBackup="true"
android:icon="@drawable/gmarkerblank"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key" />
<activity
android:name=".GE"
android:label="@string/title_activity_ge">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

</application>

我的build.gradle文件是:

apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.mydomain.ge"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
//implementation 'com.google.android.gms:play-services:12.0.1'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.android.support:design:27.1.1'
implementation 'com.github.pengrad:mapscaleview:1.4.1'
}

我的活动文件如下:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1"
android:id="@+id/tlll"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/llhelpgraphic"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".08"
android:background="#000000"
android:orientation="horizontal">
<ImageButton
android:id="@+id/helpButton"
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:layout_margin="3dp"
android:adjustViewBounds="true"
android:src="@drawable/help5"
/>
<ImageView
android:id="@+id/titleview"
android:layout_height="match_parent"
android:layout_width="fill_parent"
android:layout_weight="1"
android:src="@drawable/title"
/>
</LinearLayout>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/frlayout"
android:layout_weight=".82"
android:layout_width="match_parent"
android:layout_height="0dp"
>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".GE" />
</FrameLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".10"
android:background="#004D79"
android:orientation="horizontal">
<EditText
android:id="@+id/addressText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="10dp"
android:layout_marginTop="7dp"
android:layout_weight="1"
android:background="#FFFFFF"
android:text="Enter UK address or postcode">
</EditText>
<Button
android:id="@+id/findButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="Find">
</Button>
</LinearLayout>

基本上,这会产生一个包含图像按钮的最上面一行,然后在它旁边,填充该行的其余部分就是应用程序的标题下面是地图,占据了大部分空间最底部是一行,其中包含一个文本编辑框和右侧的一个按钮。我看不出源代码有任何明显的错误

您的应用程序会根据您的构建变体生成不同的SHA-1指纹。

此外,当你使用谷歌的应用程序签名时,谷歌会在你上传apk时为你生成SHA-1指纹,所以你需要在谷歌云平台控制台中添加指纹,就像你使用调试指纹一样。

您可以通过进入Google Play控制台->发布管理->应用程序签名来查看生成的指纹

最新更新