[英]Android App Map Fragment not showing in release version
我使用Map Fragment創建了一個小型的android應用,並使用jetbrains-studio對其進行了測試。 我已經獲得了API密鑰,無論手機是通過USB電纜插入筆記本電腦還是隨身攜帶(無論是否包含跟蹤元素,我都需要這樣做),它都能正常工作。
我已通過API和服務信息中心啟用了“ Maps SDK for Android” API。
當我上傳應用程序時,我轉到“應用程序簽名”並下載了名為“ deployment_cert.der”的Google證書。 當需要編譯我的應用程序時,
keytool -importcert-文件deployment_cert.der -keystore keystore.jks
(密鑰庫是我去編譯該應用的發行版作為簽名的apk時創建的文件;當我上傳該應用時,谷歌並沒有抱怨並接受它)
我讓我的妻子通過從手機和平板電腦上的Playstore下載來測試該應用程序,但沒有顯示地圖,而是一個灰色框,上面帶有Google徽標,+ /-縮放按鈕和“居家中心”在右上角圓圈。 該應用程序上的其他所有內容均正常運行。
我不知道有什么問題嗎? 有人可以提供一些提示嗎? 我對尋找的東西感到困惑。
我已經檢查了設備的兼容性,並且我使用過的所有設備都在設備目錄中列為“確定”。
我的清單文件如下:
<?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指紋。
同樣,當您使用Google的應用簽名時,當您上傳apk時,Google會為您生成SHA-1指紋,因此您需要像使用調試指紋那樣在Google Cloud Platform Console中添加該指紋。
您可以轉到Google Play控制台->版本管理->應用簽名來查看生成的指紋
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.