1

I am new to android development and this is my first app. I have been trying to implement google maps with the bottom navigation view however the google maps shows up blank with only the logo at the bottom. I have tried all solutions I found however nothing fixed it. Please let me know how to fix it if possible, this one error is stopping me from continuing this project :(

Screenshot: https://i.stack.imgur.com/iQVPe.jpg

Btw, I was following this guys tutorial if that helps: https://www.youtube.com/watch?v=Cy4EraxUan4


ANDROID MANIFEST

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.weatherreminder.weatherreminder">

    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="@string/google_maps_key"/>

        <activity
            android:name=".MapsActivity"
            android:label="@string/title_activity_maps"></activity>
    </application>

</manifest>



GRADLE

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.weatherreminder.weatherreminder"
        minSdkVersion 15
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner 
"android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 
'proguard-rules.pro'
        }
    }

    // ignore app:lint issues
    lintOptions {
        abortOnError false
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    implementation 'com.android.support:support-vector-drawable:27.1.1'

    // GooglePlayServices maps api
    implementation 'com.google.android.gms:play-services-maps:10.2.1'

    implementation 'com.android.support:support-v4:27.1.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'
}



MAINACTIVITY

package com.weatherreminder.weatherreminder;

import android.app.Dialog;
import android.app.FragmentManager;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomNavigationView;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.MenuItem;
import android.widget.TextView;
import android.widget.Toast;

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GoogleApiAvailability;

public class MainActivity extends AppCompatActivity {

    private TextView mTextMessage;
    private static final int ERROR_DIALOG_REQUEST = 9001;

    private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
        = new BottomNavigationView.OnNavigationItemSelectedListener() {

        @Override
        public boolean onNavigationItemSelected(@NonNull MenuItem item) {
            switch (item.getItemId()) {
                case R.id.navigation_weather:
                    mTextMessage.setText(R.string.title_weather);
                    return true;
                case R.id.navigation_map:
                    MapsFragment map = new MapsFragment();
                    android.support.v4.app.FragmentManager manager = getSupportFragmentManager();
                    manager.beginTransaction().replace(R.id.mapLayout, map).commit();

                    return true;
                case R.id.navigation_settings:
                    mTextMessage.setText(R.string.title_settings);
                    return true;
            }
            return false;
        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mTextMessage = (TextView) findViewById(R.id.message);
        BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
        navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
    }
}
yolo
  • 31
  • 3
  • can you add a sample image?, maybe it would be an actualization of Google Services. – DarckBlezzer Jun 25 '18 at 23:48
  • Do you mean a screenshot? If thats what you mean, I added that here: https://imgur.com/a/CpVyQQK, if not I can add the images of what you are looking for, let me know what you want specifically, sorry I am new to this stuff so I don't know what you want in the sample image lol – yolo Jun 26 '18 at 00:23
  • Do you have any errors logs, about map?, try to test your app in another emulator, like genymotion or android studio if you have intel processor – DarckBlezzer Jun 26 '18 at 16:50
  • I do not have errors about the map. I also tested it using android studio and genymotion as you suggested and both have the same issue :( – yolo Jun 27 '18 at 03:13
  • Typically blank screen indicates that API key is not configured properly. Double check your API key restrictions in the developer console: https://developers.google.com/maps/documentation/android-sdk/signup#detailed-guides – xomena Jun 27 '18 at 11:47
  • Ok thanks, I'll just try generating a new one or something – yolo Jul 02 '18 at 21:05

0 Answers0