1

我正试图让谷歌地图进入模拟器。我能够在实际设备上启动代码,但模拟器是另一回事。

我正在尝试将模拟器与 Google API 18 一起使用。我的最低 SDK 是 15。

我在模拟器中得到的只是一个空白屏幕,底部写入角带有 +/- 控件。

当我的地图运行时,我在 Logcat 中收到以下消息。

09-30 12:35:27.761: ERROR/Google Maps Android API(1327): Google Maps Android API v2 only supports devices with OpenGL ES 2.0 and above 
09-30 12:35:28.441: WARN/EGL_emulation(1327): eglSurfaceAttrib not implemented 
09-30 12:36:16.741: ERROR/CheckinTask(550): Checkin failed: https://android.clients.google.com/checkin (request #0): java.net.SocketTimeoutException   
09-30 12:37:01.003: ERROR/CheckinTask(550): SSL error, attempting time correction: javax.net.ssl.SSLHandshakeException: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0x2a2d2368: Failure in SSL library, usually a protocol error
            error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol (external/openssl/ssl/s23_clnt.c:766 0x59bf16ba:0x00000000) 
09-30 12:38:01.201: ERROR/CheckinTask(550): Checkin failed: https://android.clients.google.com/checkin (request #0): java.net.SocketTimeoutException    
09-30 12:38:17.482: WARN/Uploader(545): No account for auth token provided 09-30 
12:39:10.121: ERROR/CheckinTask(550): SSL error, attempting time correction: javax.net.ssl.SSLHandshakeException: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0x2a2daaa0: Failure in SSL library, usually a protocol error
            error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol (external/openssl/ssl/s23_clnt.c:766 0x59bf16ba:0x00000000) 
09-30 12:40:10.381: ERROR/CheckinTask(550): Checkin failed: https://android.clients.google.com/checkin (request #0): java.net.SocketTimeoutException

这是我的清单。

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.Mapper"
      android:versionCode="1"
      android:versionName="1.0">
<uses-feature
        android:glEsVersion="0x00020000"
        android:required="true"/>
<uses-sdk android:minSdkVersion="15"
          android:targetSdkVersion="17"/>

<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="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<!-- The following two permissions are not required to use
     Google Maps Android API v2, but are recommended. -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>


<application android:label="@string/app_name" android:icon="@drawable/ic_launcher">
    <uses-library android:name="com.google.android.maps"/>

    <activity android:name="MyActivity" android:label="@string/app_name"  android:theme="@android:style/Theme.NoTitleBar">
        <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="MY_API_GENERATED_KEY_IS_HERE"/>

</application>
</manifest>

布局 main.xml

<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/map"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:name="com.google.android.gms.maps.MapFragment"/>

活动代码如下

package com.example.Mapper;

import android.app.Activity;
import android.app.Dialog;
import android.os.Bundle;
import android.util.Log;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;

public class MyActivity extends Activity {
    /**
     * Called when the activity is first created.
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        Log.w("........................","................................................");
        super.onCreate(savedInstanceState);
        Integer resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(MyActivity.this);
        if (resultCode == ConnectionResult.SUCCESS) {
            setContentView(R.layout.main);
        } else {
            Dialog dialog = GooglePlayServicesUtil.getErrorDialog(resultCode, MyActivity.this, 0);
            if (dialog != null) {
                //This dialog will help the user update to the latest GooglePlayServices
                dialog.show();
            }
        }


    }
}

我不明白为什么设备上没有 SSL 错误,而我使用模拟器时出现错误。请协助。

谢谢你。

4

1 回答 1

0

我已经切换到 Genymotion 模拟器,我的问题已经消失了。问题不在于我做错了什么,而在于 GOOGLE 的模拟器。

于 2013-10-02T01:20:32.533 回答