Blank Screen Android 2.2 Google Maps v2

2019-08-04 20:33发布

EDIT :

I transferred my 20+ projects that tries to use Google Maps for Android v2. After changing keys and stuff, now, it works. I don't know what made this work, but thank you all. I got one keystore, the key is right. I guess it magically fixed somehow. Well, thanks guys.

I'm doing searches for 2 days and I couldn't fix this problem. I did everything, yet, this application can not work.

I want my application to work on Android 2.2 and above. Like it says "if you create your app in level 8, it'll support 95% of market".

Here are my screenshots and source codes:

I'm pasting the source code which is the easiest to get. I took this from web.

Here's the output of the command

keytool -list -keystore <path>
*****************  WARNING WARNING WARNING  *****************
* The integrity of the information stored in your keystore  *
* has NOT been verified!  In order to verify its integrity, *
* you must provide your keystore password.                  *
*****************  WARNING WARNING WARNING  *****************

Keystore type: JKS Keystore provider: SUN

Your keystore contains 1 entry

androiddebugkey, 15.Mar.2013, PrivateKeyEntry,
Certificate fingerprint (SHA1): xxx

main.xml file:

<?xml version="1.0" encoding="utf-8"?>
<com.google.android.maps.MapView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mapView"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:clickable="true"
    android:apiKey="AIzaSyDim-x5Gxxx"
/>

manifest file:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.androidhive.googlemaps"
    android:versionCode="1"
    android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <!-- Add Google Map Library -->
        <uses-library android:name="com.google.android.maps" />
        <activity
            android:name=".AndroidGoogleMapsActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
    <!-- Allow to connect with internet -->
    <uses-permission android:name="android.permission.INTERNET" />
</manifest>

java file (no need to paste it all, but I guess it's best to paste it all)

http://pastebin.com/yF95Rcbd

Here are my screenshots:

http://i.imgur.com/gExHpUG.png

http://i.imgur.com/AMOXKhr.png

http://i.imgur.com/Aqon97Y.png

I'm trying to compile this app to Android 4.2.2, but I tried and want to make it work in 2.2 and above.

Here's the Android tab of the properties window just to make sure:

http://i.imgur.com/ht0CQwT.png

Here's my log

03-20 07:01:20.145: W/System.err(956):  at java.lang.Thread.run(Thread.java:856)
03-20 07:01:20.665: W/System.err(956): IOException processing: 26
03-20 07:01:20.665: W/System.err(956): java.io.IOException: Server returned: 3
03-20 07:01:20.665: W/System.err(956):  at android_maps_conflict_avoidance.com.google.googlenav.map.BaseTileRequest.readResponseData(BaseTileRequest.java:115)
03-20 07:01:20.675: W/System.err(956):  at android_maps_conflict_avoidance.com.google.googlenav.map.MapService$MapTileRequest.readResponseData(MapService.java:1473)
03-20 07:01:20.675: W/System.err(956):  at android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher.processDataRequest(DataRequestDispatcher.java:1117)
03-20 07:01:20.675: W/System.err(956):  at android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher.serviceRequests(DataRequestDispatcher.java:994)
03-20 07:01:20.675: W/System.err(956):  at android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher$DispatcherServer.run(DataRequestDispatcher.java:1702)

These lines repeat all the time.

Thank you very much. Your post appears to contain code that is not properly formatted as code" error made me delete the blank lines. Sorry for the messed up codes.

5条回答
ら.Afraid
2楼-- · 2019-08-04 20:38

http://i.imgur.com/ht0CQwT.png See the snapshot. You did not add Google Play Services library that is require for displaying Google Android Map V2. Please download and add that library and then try again.

Please also see the target. Your target is 4.2.2 and your are accessing it on 2.2. Change the target to 2.2 and use support fragment.

Thanks,

查看更多
Emotional °昔
3楼-- · 2019-08-04 20:47

You are missing permissions and meta-data for API KEY.

Read this carefully: https://developers.google.com/maps/documentation/android/start

查看更多
爷的心禁止访问
4楼-- · 2019-08-04 20:48

Working with android mapapi v2 ,the main reason is you must add play service to your app,like below :

<permission
        android:name="com.example.androidmapview.permission.MAPS_RECEIVE"
        android:protectionLevel="signature" />

    <uses-permission android:name="com.example.androidmapview.permission.MAPS_RECEIVE" />

Use fragment class in Layout:

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:map="http://schemas.android.com/apk/res-auto"
  android:id="@+id/map"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
 class="com.google.android.gms.maps.SupportMapFragment"/>

And change your manifest:

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

   <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="16" />

    <permission
        android:name="com.example.androidmapview.permission.MAPS_RECEIVE"
        android:protectionLevel="signature" />

    <uses-permission android:name="com.example.androidmapview.permission.MAPS_RECEIVE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.androidmapview.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="AIzxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"></meta-data>
    </application>

    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />
</manifest>

in activity:

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;

import com.google.android.gms.maps.SupportMapFragment;

public class MainActivity extends FragmentActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        SupportMapFragment fragment = new SupportMapFragment();
        getSupportFragmentManager().beginTransaction()
                .add(android.R.id.content, fragment).commit();
    }
}

For more info check the link which will explain you in details about api v2

查看更多
孤傲高冷的网名
5楼-- · 2019-08-04 20:54

I solved my blank screen problem with zoom in/out buttons like that.(it happens after I changed my package name)

  1. Delete the keystore file
  2. Create a new keystore file
  3. Get SHA1 fingerprint
  4. Go to API Console
  5. Create a new Android App.
  6. Paste your fingerprint
  7. Use the given API Key in your Manifest File

That worked for me

查看更多
Fickle 薄情
6楼-- · 2019-08-04 20:58

I have solved this issue,

  • Open your Google APIs Console
  • Choose API Access
  • Edit allowed Android apps from your API Key
  • Change the package name with your package name
  • Example: 00:06:A5:0E:04:A2:1E:8F:FE:6B:7F:46:23:C3:xx:xx:xx:xx:xx:xx;com.example.androidmapview
查看更多
登录 后发表回答