在Android Studio中使用谷歌地图-Mapfragment为空

在Android Studio中使用谷歌地图-Mapfragment为空,android,google-maps,Android,Google Maps,我最近更新了Android的新版本。自从更新以来,我在地图显示方面一直存在问题。我只是多次重新生成API密钥,但都没有用 这是我的清单: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.morticia.android.pop"> <uses-sdk android

我最近更新了Android的新版本。自从更新以来,我在地图显示方面一直存在问题。我只是多次重新生成API密钥,但都没有用

这是我的清单:

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

<uses-sdk
    android:minSdkVersion="14"
    android:targetSdkVersion="18" />
<!--
     The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
     Google Maps Android API v2, but you must specify either coarse or fine
     location permissions for the 'MyLocation' functionality.
-->
<uses-feature
    android:glEsVersion="0x00020000"
    android:required="true" />
<uses-feature android:name="android.hardware.location.gps" />

<permission
    android:name="com.VertexVerveInc.GPSLocator.permission.MAPS_RECEIVE"
    android:protectionLevel="signature" />

<!-- <permission -->
<!-- android:name="com.google.map.permission.MAPS_RECEIVE" -->
<!-- android:protectionLevel="signature" > -->
<!-- </permission> -->

<uses-permission android:name="com.VertexVerveInc.GPSLocator.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCE" />
<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" />

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

<!-- To auto-complete the email text field in the login form with the user's emails -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />

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

<application
    android:allowBackup="true"
    android:hardwareAccelerated="false"
    android:icon="@mipmap/usericonldpi"
    android:label="@string/app_name"
    android:largeHeap="true"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">

    <!--
         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
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />
    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="AIzaSyB94l1WasdFKus_ymBzhqHz1e3WVY5AUig" />

    <activity
        android:name=".MainActivity"
        android:label="@string/title_activity_maps">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

    <activity
        android:name=".MapsActivity"
        android:exported="true" />

    </activity>
</application>
apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
    applicationId "com.morticia.android.pop"
    minSdkVersion 19
    targetSdkVersion 25
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

ext{
    supportLibVersion = '25.3.0'
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.0'
compile 'com.google.android.gms:play-services:10.2.1'
compile 'com.google.maps.android:android-maps-utils:0.4.+'
compile 'com.google.firebase:firebase-core:10.2.1'
compile 'com.google.firebase:firebase-database:10.2.1'
compile 'com.android.support:design:25.3.0'
compile 'com.google.firebase:firebase-auth:10.2.1'
compile 'com.android.support:support-v4:25.3.0'
compile 'com.android.support:support-v13:25.3.0'
testCompile 'junit:junit:4.12'
compile 'com.android.support:cardview-v7:26.0.0-alpha1'
compile 'com.android.support:recyclerview-v7:26.0.0-alpha1'
compile 'com.sothree.slidinguppanel:library:3.3.1'


}
apply plugin: 'com.google.gms.google-services'

configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
    def requested = details.requested
    if (requested.group == 'com.android.support') {
        if (!requested.name.startsWith("multidex")) {
            details.useVersion '25.3.0'
        }
    }
}
}
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback,
    GoogleApiClient.ConnectionCallbacks,
    GoogleApiClient.OnConnectionFailedListener, LocationListener, OnClickListener{
public static final int MY_PERMISSIONS_REQUEST_LOCATION = 99;
//    CircleSize circSize;

LocationRequest mLocationRequest;
Location mLastLocation;
Marker mCurrLocationMarker;
private FirebaseAuth firebaseAuth;
private FirebaseUser user;

private GoogleMap mMap;
private GoogleApiClient mGoogleApiClient;
private PopCityCollection cities;
CityReferrenceDAO cityRef;

private static final String TAG = "MapsActivity";


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_maps);
    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.map_activity);
    mapFragment.getMapAsync(this);
    firebaseAuth = FirebaseAuth.getInstance();

    if(firebaseAuth.getCurrentUser() == null){
        finish();
        startActivity(new Intent(this, LoginActivity.class));
    }
    SlidingUpPanelLayout spl = (SlidingUpPanelLayout) findViewById(R.id.sliding_layout);

    ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
    FriendsActivity friends = new FriendsActivity();
    viewPager.setAdapter(new FriendFragmentPagerAdapter(getSupportFragmentManager(), friends));
    TabLayout tabLayout = (TabLayout) findViewById(R.id.sliding_tabs);
    tabLayout.setupWithViewPager(viewPager);

    //check for pops method needs to be added (include pop just made)



}
<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="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"
    tools:context=".MapsActivity">


    <com.sothree.slidinguppanel.SlidingUpPanelLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        xmlns:sothree="http://schemas.android.com/apk/res-auto"
        android:id="@+id/sliding_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"

        android:gravity="bottom"
        sothree:umanoPanelHeight="50dp"
        sothree:paddingEnd="16dp"
        sothree:umanoShadowHeight="4dp"
        sothree:umanoParallaxOffset="100dp"
        sothree:umanoDragView="@+id/dragView"
        sothree:umanoOverlay="true"
        sothree:umanoScrollableView="@+id/list">

        <fragment xmlns:map="http://schemas.android.com/apk/res/android"
            android:name="com.google.android.gms.maps.SupportMapFragment"
            map:id="@+id/map_activity"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            tools:context="com.morticia.android.pop.MapsActivity" />

        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:app="http://schemas.android.com/apk/lib/com.morticia.android.pop"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <android.support.design.widget.TabLayout
                android:id="@+id/sliding_tabs"
                android:layout_width="match_parent"
                style="@style/MyCustomTabLayout"
                android:background="@color/colorSalmon"
                android:layout_height="wrap_content"
                app:tabMode="fixed" />

            <android.support.v4.view.ViewPager
                android:id="@+id/viewpager"
                android:layout_width="match_parent"
                android:layout_height="0px"
                android:layout_weight="1"
                android:background="@android:color/white"/>
        </LinearLayout>


    </com.sothree.slidinguppanel.SlidingUpPanelLayout>

</RelativeLayout>
以下是创建()的活动:

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

<uses-sdk
    android:minSdkVersion="14"
    android:targetSdkVersion="18" />
<!--
     The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
     Google Maps Android API v2, but you must specify either coarse or fine
     location permissions for the 'MyLocation' functionality.
-->
<uses-feature
    android:glEsVersion="0x00020000"
    android:required="true" />
<uses-feature android:name="android.hardware.location.gps" />

<permission
    android:name="com.VertexVerveInc.GPSLocator.permission.MAPS_RECEIVE"
    android:protectionLevel="signature" />

<!-- <permission -->
<!-- android:name="com.google.map.permission.MAPS_RECEIVE" -->
<!-- android:protectionLevel="signature" > -->
<!-- </permission> -->

<uses-permission android:name="com.VertexVerveInc.GPSLocator.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCE" />
<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" />

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

<!-- To auto-complete the email text field in the login form with the user's emails -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />

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

<application
    android:allowBackup="true"
    android:hardwareAccelerated="false"
    android:icon="@mipmap/usericonldpi"
    android:label="@string/app_name"
    android:largeHeap="true"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">

    <!--
         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
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />
    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="AIzaSyB94l1WasdFKus_ymBzhqHz1e3WVY5AUig" />

    <activity
        android:name=".MainActivity"
        android:label="@string/title_activity_maps">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

    <activity
        android:name=".MapsActivity"
        android:exported="true" />

    </activity>
</application>
apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
    applicationId "com.morticia.android.pop"
    minSdkVersion 19
    targetSdkVersion 25
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

ext{
    supportLibVersion = '25.3.0'
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.0'
compile 'com.google.android.gms:play-services:10.2.1'
compile 'com.google.maps.android:android-maps-utils:0.4.+'
compile 'com.google.firebase:firebase-core:10.2.1'
compile 'com.google.firebase:firebase-database:10.2.1'
compile 'com.android.support:design:25.3.0'
compile 'com.google.firebase:firebase-auth:10.2.1'
compile 'com.android.support:support-v4:25.3.0'
compile 'com.android.support:support-v13:25.3.0'
testCompile 'junit:junit:4.12'
compile 'com.android.support:cardview-v7:26.0.0-alpha1'
compile 'com.android.support:recyclerview-v7:26.0.0-alpha1'
compile 'com.sothree.slidinguppanel:library:3.3.1'


}
apply plugin: 'com.google.gms.google-services'

configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
    def requested = details.requested
    if (requested.group == 'com.android.support') {
        if (!requested.name.startsWith("multidex")) {
            details.useVersion '25.3.0'
        }
    }
}
}
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback,
    GoogleApiClient.ConnectionCallbacks,
    GoogleApiClient.OnConnectionFailedListener, LocationListener, OnClickListener{
public static final int MY_PERMISSIONS_REQUEST_LOCATION = 99;
//    CircleSize circSize;

LocationRequest mLocationRequest;
Location mLastLocation;
Marker mCurrLocationMarker;
private FirebaseAuth firebaseAuth;
private FirebaseUser user;

private GoogleMap mMap;
private GoogleApiClient mGoogleApiClient;
private PopCityCollection cities;
CityReferrenceDAO cityRef;

private static final String TAG = "MapsActivity";


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_maps);
    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.map_activity);
    mapFragment.getMapAsync(this);
    firebaseAuth = FirebaseAuth.getInstance();

    if(firebaseAuth.getCurrentUser() == null){
        finish();
        startActivity(new Intent(this, LoginActivity.class));
    }
    SlidingUpPanelLayout spl = (SlidingUpPanelLayout) findViewById(R.id.sliding_layout);

    ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
    FriendsActivity friends = new FriendsActivity();
    viewPager.setAdapter(new FriendFragmentPagerAdapter(getSupportFragmentManager(), friends));
    TabLayout tabLayout = (TabLayout) findViewById(R.id.sliding_tabs);
    tabLayout.setupWithViewPager(viewPager);

    //check for pops method needs to be added (include pop just made)



}
<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="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"
    tools:context=".MapsActivity">


    <com.sothree.slidinguppanel.SlidingUpPanelLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        xmlns:sothree="http://schemas.android.com/apk/res-auto"
        android:id="@+id/sliding_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"

        android:gravity="bottom"
        sothree:umanoPanelHeight="50dp"
        sothree:paddingEnd="16dp"
        sothree:umanoShadowHeight="4dp"
        sothree:umanoParallaxOffset="100dp"
        sothree:umanoDragView="@+id/dragView"
        sothree:umanoOverlay="true"
        sothree:umanoScrollableView="@+id/list">

        <fragment xmlns:map="http://schemas.android.com/apk/res/android"
            android:name="com.google.android.gms.maps.SupportMapFragment"
            map:id="@+id/map_activity"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            tools:context="com.morticia.android.pop.MapsActivity" />

        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:app="http://schemas.android.com/apk/lib/com.morticia.android.pop"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <android.support.design.widget.TabLayout
                android:id="@+id/sliding_tabs"
                android:layout_width="match_parent"
                style="@style/MyCustomTabLayout"
                android:background="@color/colorSalmon"
                android:layout_height="wrap_content"
                app:tabMode="fixed" />

            <android.support.v4.view.ViewPager
                android:id="@+id/viewpager"
                android:layout_width="match_parent"
                android:layout_height="0px"
                android:layout_weight="1"
                android:background="@android:color/white"/>
        </LinearLayout>


    </com.sothree.slidinguppanel.SlidingUpPanelLayout>

</RelativeLayout>
编辑:这是我的xml文件:

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

<uses-sdk
    android:minSdkVersion="14"
    android:targetSdkVersion="18" />
<!--
     The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
     Google Maps Android API v2, but you must specify either coarse or fine
     location permissions for the 'MyLocation' functionality.
-->
<uses-feature
    android:glEsVersion="0x00020000"
    android:required="true" />
<uses-feature android:name="android.hardware.location.gps" />

<permission
    android:name="com.VertexVerveInc.GPSLocator.permission.MAPS_RECEIVE"
    android:protectionLevel="signature" />

<!-- <permission -->
<!-- android:name="com.google.map.permission.MAPS_RECEIVE" -->
<!-- android:protectionLevel="signature" > -->
<!-- </permission> -->

<uses-permission android:name="com.VertexVerveInc.GPSLocator.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCE" />
<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" />

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

<!-- To auto-complete the email text field in the login form with the user's emails -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />

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

<application
    android:allowBackup="true"
    android:hardwareAccelerated="false"
    android:icon="@mipmap/usericonldpi"
    android:label="@string/app_name"
    android:largeHeap="true"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">

    <!--
         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
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />
    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="AIzaSyB94l1WasdFKus_ymBzhqHz1e3WVY5AUig" />

    <activity
        android:name=".MainActivity"
        android:label="@string/title_activity_maps">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

    <activity
        android:name=".MapsActivity"
        android:exported="true" />

    </activity>
</application>
apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
    applicationId "com.morticia.android.pop"
    minSdkVersion 19
    targetSdkVersion 25
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

ext{
    supportLibVersion = '25.3.0'
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.0'
compile 'com.google.android.gms:play-services:10.2.1'
compile 'com.google.maps.android:android-maps-utils:0.4.+'
compile 'com.google.firebase:firebase-core:10.2.1'
compile 'com.google.firebase:firebase-database:10.2.1'
compile 'com.android.support:design:25.3.0'
compile 'com.google.firebase:firebase-auth:10.2.1'
compile 'com.android.support:support-v4:25.3.0'
compile 'com.android.support:support-v13:25.3.0'
testCompile 'junit:junit:4.12'
compile 'com.android.support:cardview-v7:26.0.0-alpha1'
compile 'com.android.support:recyclerview-v7:26.0.0-alpha1'
compile 'com.sothree.slidinguppanel:library:3.3.1'


}
apply plugin: 'com.google.gms.google-services'

configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
    def requested = details.requested
    if (requested.group == 'com.android.support') {
        if (!requested.name.startsWith("multidex")) {
            details.useVersion '25.3.0'
        }
    }
}
}
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback,
    GoogleApiClient.ConnectionCallbacks,
    GoogleApiClient.OnConnectionFailedListener, LocationListener, OnClickListener{
public static final int MY_PERMISSIONS_REQUEST_LOCATION = 99;
//    CircleSize circSize;

LocationRequest mLocationRequest;
Location mLastLocation;
Marker mCurrLocationMarker;
private FirebaseAuth firebaseAuth;
private FirebaseUser user;

private GoogleMap mMap;
private GoogleApiClient mGoogleApiClient;
private PopCityCollection cities;
CityReferrenceDAO cityRef;

private static final String TAG = "MapsActivity";


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_maps);
    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.map_activity);
    mapFragment.getMapAsync(this);
    firebaseAuth = FirebaseAuth.getInstance();

    if(firebaseAuth.getCurrentUser() == null){
        finish();
        startActivity(new Intent(this, LoginActivity.class));
    }
    SlidingUpPanelLayout spl = (SlidingUpPanelLayout) findViewById(R.id.sliding_layout);

    ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
    FriendsActivity friends = new FriendsActivity();
    viewPager.setAdapter(new FriendFragmentPagerAdapter(getSupportFragmentManager(), friends));
    TabLayout tabLayout = (TabLayout) findViewById(R.id.sliding_tabs);
    tabLayout.setupWithViewPager(viewPager);

    //check for pops method needs to be added (include pop just made)



}
<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="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"
    tools:context=".MapsActivity">


    <com.sothree.slidinguppanel.SlidingUpPanelLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        xmlns:sothree="http://schemas.android.com/apk/res-auto"
        android:id="@+id/sliding_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"

        android:gravity="bottom"
        sothree:umanoPanelHeight="50dp"
        sothree:paddingEnd="16dp"
        sothree:umanoShadowHeight="4dp"
        sothree:umanoParallaxOffset="100dp"
        sothree:umanoDragView="@+id/dragView"
        sothree:umanoOverlay="true"
        sothree:umanoScrollableView="@+id/list">

        <fragment xmlns:map="http://schemas.android.com/apk/res/android"
            android:name="com.google.android.gms.maps.SupportMapFragment"
            map:id="@+id/map_activity"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            tools:context="com.morticia.android.pop.MapsActivity" />

        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:app="http://schemas.android.com/apk/lib/com.morticia.android.pop"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <android.support.design.widget.TabLayout
                android:id="@+id/sliding_tabs"
                android:layout_width="match_parent"
                style="@style/MyCustomTabLayout"
                android:background="@color/colorSalmon"
                android:layout_height="wrap_content"
                app:tabMode="fixed" />

            <android.support.v4.view.ViewPager
                android:id="@+id/viewpager"
                android:layout_width="match_parent"
                android:layout_height="0px"
                android:layout_weight="1"
                android:background="@android:color/white"/>
        </LinearLayout>


    </com.sothree.slidinguppanel.SlidingUpPanelLayout>

</RelativeLayout>


如有任何见解,将不胜感激!谢谢。

已解决

这个问题并不是因为一张空白的地图,但相机只是被放大到海洋中。我的风格JSON的水的颜色是不同于正常。该问题是在更新Android后引起的,默认情况下未启用位置。解决方案是根据设备的设置手动启用设备上的位置,以便相机可以根据位置以编程方式进行调整

谢谢


-TJBlack31

尝试更新您的google play服务,我曾经遇到过同样的问题,所以我更新了手机的google play服务,它可以将您的XML代码发布到地图上fragment@AdeelTurk谢谢你的回复。在SDK管理器中,它似乎是最新的。问题依然存在。不客气@TJBlack31我刚刚分享了我的experience@TJBlack31如果您的应用程序支持API级别11或更高,则应使用MapFragment代替SupportMapFragment并相应更改XML