gpt4 book ai didi

android - 谷歌地图未显示在谷歌地图 API v2 中

转载 作者:行者123 更新时间:2023-11-29 17:54:57 25 4
gpt4 key购买 nike

您好,我正在尝试使用 google 提供的代码运行 map 应用程序,但 map 未显示,昨天显示的现在我的设备上显示空白屏幕

当我运行程序时,以下是日志

LogCat

01-02 11:33:36.203: D/dalvikvm(20623): GC_CONCURRENT freed 188K, 10% free 7589K/8391K, paused 17ms+10ms, total 86ms
01-02 11:33:36.203: D/dalvikvm(20623): WAIT_FOR_CONCURRENT_GC blocked 43ms
01-02 11:33:36.789: D/dalvikvm(20623): GC_CONCURRENT freed 343K, 11% free 7817K/8775K, paused 12ms+2ms, total 68ms
01-02 11:33:36.789: D/dalvikvm(20623): WAIT_FOR_CONCURRENT_GC blocked 31ms
01-02 11:33:36.789: D/dalvikvm(20623): WAIT_FOR_CONCURRENT_GC blocked 31ms
01-02 11:33:36.789: D/dalvikvm(20623): WAIT_FOR_CONCURRENT_GC blocked 31ms
01-02 11:33:36.789: D/dalvikvm(20623): WAIT_FOR_CONCURRENT_GC blocked 32ms
01-02 11:33:36.789: D/dalvikvm(20623): WAIT_FOR_CONCURRENT_GC blocked 33ms
01-02 11:33:36.796: D/dalvikvm(20623): WAIT_FOR_CONCURRENT_GC blocked 36ms
01-02 11:33:36.937: D/AbsListView(20623): Get MotionRecognitionManager
01-02 11:33:37.007: D/dalvikvm(20623): GC_CONCURRENT freed 255K, 11% free 8050K/8967K, paused 17ms+3ms, total 59ms
01-02 11:33:37.039: E/GooglePlayServicesUtil(20623): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
01-02 11:33:37.109: D/libEGL(20623): loaded /vendor/lib/egl/libEGL_POWERVR_SGX540_120.so
01-02 11:33:37.125: D/libEGL(20623): loaded /vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_120.so
01-02 11:33:37.132: D/libEGL(20623): loaded /vendor/lib/egl/libGLESv2_POWERVR_SGX540_120.so
01-02 11:33:37.242: D/OpenGLRenderer(20623): Enabling debug mode 0
01-02 11:33:37.492: D/dalvikvm(20623): GC_FOR_ALLOC freed 267K, 11% free 8188K/9159K, paused 35ms, total 35ms
01-02 11:33:37.539: D/dalvikvm(20623): GC_CONCURRENT freed 327K, 12% free 8318K/9351K, paused 3ms+2ms, total 32ms
01-02 11:33:37.539: D/dalvikvm(20623): WAIT_FOR_CONCURRENT_GC blocked 20ms
01-02 11:33:37.570: D/dalvikvm(20623): GC_FOR_ALLOC freed 453K, 13% free 8191K/9351K, paused 21ms, total 21ms
01-02 11:33:37.679: D/dalvikvm(20623): GC_CONCURRENT freed 304K, 11% free 8335K/9351K, paused 17ms+40ms, total 105ms

它显示未安装 google play 服务。但是我安装了 play 服务并将其导入到我的 eclipse 工作区中,然后我使用

将其添加到我的项目中

project-properties-android

这是我的 list 文件

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

<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="18" />

<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<permission
android:name="com.googlemap.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<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"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="com.googlemap.permission.MAPS_RECEIVE" />




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

<activity
android:name="com.googlemap.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="My api key"/>

<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />

</application>

</manifest>

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.SupportMapFragment"/>

MainActivity.java

package com.googlemap;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;

public class MainActivity extends FragmentActivity {
GoogleMap map;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (map == null) {
map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map))
.getMap();
LatLng loc = new LatLng(8.557845, 76.880727);

map.setMyLocationEnabled(true);

map.moveCamera(CameraUpdateFactory.newLatLngZoom(loc, 13));

map.addMarker(new MarkerOptions()
.title("Google map")
.snippet(" IT city .")
.position(loc));
}
}

}

project.properties 文件

target=Google Inc.:Google APIs:17
android.library=false
android.library.reference.1=../google-play-services_lib

请帮助我。我尝试了一些解决方案,但我没有得到结果提前致谢..

最佳答案

The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.

看起来您没有正确设置 google play 服务。

按照以下链接中的步骤设置 google play 服务。

http://developer.android.com/google/play-services/setup.html

您还需要检查 google play 服务的可用性。在下面的链接中查看主题检查 Google Play 服务

http://developer.android.com/training/location/receive-location-updates.html

你的最小 sdk 是 14

<uses-sdk
android:minSdkVersion="14"

因此您需要使用MapFragment 而不是SupportMapFrament

更改为

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

替换

public class MainActivity extends FragmentActivity {

通过

public class MainActivity extends Activity {

改变

map = ((SupportMapFragment)  getSupportFragmentManager().findFragmentById(R.id.map))
.getMap();

map = ((MapFragment)  getFragmentManager().findFragmentById(R.id.map))
.getMap();

关于android - 谷歌地图未显示在谷歌地图 API v2 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20065208/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com