stu*_*bgo 9 android google-play google-maps-android-api-2 android-studio genymotion
我使用的是Ubuntu 14,Android Studio 0.8.6.我正在使用Genymotion来运行应用程序,我得到的响应是:
W/GooglePlayServicesUtil? Google Play services is missing.
Run Code Online (Sandbox Code Playgroud)
尝试在Android Studio中导入Google Play服务库,也可以在Android Studio中使用Google Play服务.从Android SDK Manager安装以下软件包:Android支持存储库,Android支持库,Google Play服务,Google Repository.
我正在尝试运行Android Studio默认活动(地图活动).这是清单文件:
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MapsActivity"
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>
<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="@string/google_maps_key" />
</application>
<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" />
Run Code Online (Sandbox Code Playgroud)
build.gradle的依赖关系:
dependencies {
compile 'com.google.android.gms:play-services:5.2.08'
compile 'com.android.support:appcompat-v7:20.0.0'
}
Run Code Online (Sandbox Code Playgroud)
默认的MapsActivity.java:
import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
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 MapsActivity extends FragmentActivity {
private GoogleMap mMap; // Might be null if Google Play services APK is not available.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
setUpMapIfNeeded();
}
@Override
protected void onResume() {
super.onResume();
setUpMapIfNeeded();
}
private void setUpMapIfNeeded() {
// Do a null check to confirm that we have not already instantiated the map.
if (mMap == null) {
// Try to obtain the map from the SupportMapFragment.
mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map))
.getMap();
// Check if we were successful in obtaining the map.
if (mMap != null) {
setUpMap();
}
}
}
private void setUpMap() {
mMap.addMarker(new MarkerOptions().position(new LatLng(0, 0)).title("Marker"));
}
}
Run Code Online (Sandbox Code Playgroud)
我错过了什么,可能是什么问题?任何帮助非常感谢.
谢谢.
有一个解决方案.不得不做两件事 - 将Play服务版本设置为更低:5.0.89.最后一个版本无法从我测试的任何(虚拟)设备下载,需要更新.
其次,要安装Google Play服务到Genymotion VM,请按照此链接下的说明:如何在Genymotion VM中安装Google Play服务(没有拖放支持)?.
干杯.
| 归档时间: |
|
| 查看次数: |
19271 次 |
| 最近记录: |