gpt4 book ai didi

java - 无法在模拟器中执行 map API

转载 作者:太空狗 更新时间:2023-10-29 12:45:02 26 4
gpt4 key购买 nike

无法在模拟器中执行 MAP API

MainActivity.java

public class MainActivity extends FragmentActivity {

// Google Map
private GoogleMap googleMap;

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

try {
// Loading map
initilizeMap();

} catch (Exception e) {
e.printStackTrace();
}

}

/**
* function to load map. If map is not created it will create it for you
* */
private void initilizeMap() {
if (googleMap == null) {



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


// check if map is created successfully or not
if (googleMap == null) {
Toast.makeText(getApplicationContext(),
"Sorry! unable to create maps", Toast.LENGTH_SHORT)
.show();
}
}
}

@Override
protected void onResume() {
super.onResume();
initilizeMap();
}

}

list

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

<uses-sdk
android:minSdkVersion="12"
android:targetSdkVersion="17" />

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<!-- Required to show current location -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

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

<!-- Goolge Maps API Key -->
<!-- <meta-data
android:name="com.example.googlemaps.API_KEY"
android:value="AIzaSyB_nfzBC625kv_O6GzW-O8l2oLBhqAGCIc" /> -->

<meta-data android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyB_nfzBC625kv_O6GzW-O8l2oLBhqAGCIc"/>
</application>

</manifest>

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />

</RelativeLayout>

没有错误....但日志如下所示

10-17 11:58:50.169: D/dalvikvm(592): DexOpt: couldn't find field Landroid/content/res/Configuration;.smallestScreenWidthDp
10-17 11:58:50.169: W/dalvikvm(592): VFY: unable to resolve instance field 28
10-17 11:58:50.169: D/dalvikvm(592): VFY: replacing opcode 0x52 at 0x0012
10-17 11:58:50.199: W/GooglePlayServicesUtil(592): Google Play Store is missing.
10-17 11:58:50.209: W/GooglePlayServicesUtil(592): Google Play Store is missing.
10-17 11:58:50.209: W/GooglePlayServicesUtil(592): Google Play Store is missing.
10-17 11:58:50.219: W/GooglePlayServicesUtil(592): Google Play Store is missing.
10-17 11:58:50.219: W/GooglePlayServicesUtil(592): Google Play Store is missing.
10-17 11:58:50.259: W/GooglePlayServicesUtil(592): Google Play Store is missing.
10-17 11:58:50.369: W/GooglePlayServicesUtil(592): Google Play Store is missing.
10-17 11:58:50.399: W/GooglePlayServicesUtil(592): Google Play Store is missing.
10-17 11:58:50.459: V/TLINE(592): new: android.text.TextLine@4090edb0
10-17 11:58:50.499: D/dalvikvm(592): GC_CONCURRENT freed 80K, 3% free 9051K/9287K, paused 7ms+5ms
10-17 11:58:50.759: V/TLINE(592): new: android.text.TextLine@408a52c0

我已经添加了 Google play 商店

enter image description here

我得到的模拟器如下

enter image description here


是否无法在模拟器中运行 MAP-API

如果是这样,是否有其他方法可以让我的程序在 MAP 的模拟器中执行

最佳答案

在模拟器中使用 Play Services 真的很痛苦。我从来没有机会让它发挥作用(因为我找到了替代方案)

我建议您下载并安装 Genymotion .

它使用 VirtualBox 来虚拟化超快的 android 设备和那些支持 Google Play 服务的设备。

祝你好运!

关于java - 无法在模拟器中执行 map API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19419948/

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