简体   繁体   中英

Android App Map Fragment not showing in release version

I've created a small android app using a Map Fragment and been testing it using jetbrains-studio. I've obtained an API key and it works fine, whether the phone is plugged into the laptop via the USB cable or whether I carry it around standalone (I need to do this as it has a tracking element involved).

I have "Maps SDK for Android" API enabled via the APIs and services dashboard.

When I uploaded the App I went to "App signing" and downloaded the Google certificate, called "deployment_cert.der". When it came time to compile my app,

keytool -importcert -file deployment_cert.der -keystore keystore.jks

(keystore was the file created when I went to compile the release version of the app as a signed apk; when I uploaded the app, Google didn't grumble and accepted it)

I got my wife to test out the app by downloading from the playstore on her phone and tablet but instead of the map, I get a grey box, with the Google logo in the corner, +/- zoom buttons and the "home centre" circle in the top right hand corner. Everything else on the app is working.

I don't have a clue what could be wrong? Could someone please provide some hints? I am stumped as to what to look for.

I've checked device compatibility and all the devices I've used are listed in the device directory as being OK.

My Manifest file is as follows:

<?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>

My build.gradle file is:

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'

}

My activity file is as follows:

<?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>

Basically, what this produces is, a top row containing an image button, then next to it, filling up the rest of the row is the title of the app Then below is the map, filling up the most of the space The very bottom is a row containing a text edit box, and a button on the right hand side. I can't see anything obviously amiss in the source code

Your app generates different SHA-1 fingerprints depending on your build variant.

Also when you use Google's App Signing, Google generates a SHA-1 fingerprint for you when you upload your apk, so you need to add that fingerprint in your Google Cloud Platform Console like you did with your debug fingerprint.

You can view the generated fingerprint by going to Google Play Console -> Release Management -> App signing

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM