Google Play上的Android Studio缺失 [英] Android Studio with Google Play: Google Play services is missing

查看:251
本文介绍了Google Play上的Android Studio缺失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Ubuntu 14,Android Studio 0.8.6。我使用Genymotion来运行该应用程序,我得到的响应是:

  W / GooglePlayServicesUtil:Google Play服务丢失。 

尝试了解决方案,也可以从带Google Play服务的Android Studio 。从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>

< 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>

<使用权限android:name =android.permission.INTERNET/>
< uses-permission android:name =android.permission.ACCESS_NETWORK_STATE/>
< uses-permission android:name =android.permission.WRITE_EXTERNAL_STORAGE/>
<使用权限android:name =com.google.android.providers.gsf.permission.READ_GSERVICES/>

来自build.gradle的依赖关系:

 依赖项{
compile'c​​om.google.android.gms:play-services:5.2.08'
compile'c​​om.android.support:appcompat-v7:20.0 .0'
}

默认的MapsActivity.java:

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

导入com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
导入com.google.android.gms.maps.model.MarkerOptions;

公共类MapsActivity扩展FragmentActivity {

私有GoogleMap mMap; //如果Google Play服务APK不可用,则可能为空。

@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(){
//做一个空检查来确认我们还没有实例化地图。
if(mMap == null){
//尝试从SupportMapFragment获取映射。
mMap =((SupportMapFragment)getSupportFragmentManager()。findFragmentById(R.id.map))
.getMap();
//检查我们是否成功获取地图。
if(mMap!= null){
setUpMap();




private void setUpMap(){
mMap.addMarker(new MarkerOptions()。position(new LatLng(0,0 ))标题( 标记));
}
}

我错过了什么,可能是什么问题?任何帮助大加赞赏。



谢谢。

解决方案

解。必须做两件事 - 将Play服务版本设置为较低:5.0.89。最后的版本不能从我测试的任何(虚拟)设备下载,需要更新。

其次,要将Google Play服务安装到Genymotion VM,请按照以下链接中的说明操作:如何在Genymotion虚拟机中安装Google Play服务(不支持拖放操作) ?



干杯。


I am using Ubuntu 14, Android Studio 0.8.6. I am using Genymotion for running the app, the response I get, is:

W/GooglePlayServicesUtil﹕ Google Play services is missing.

Tried the solution of Import Google Play Services library in Android Studio, also from Android Studio with Google Play Services. Installed the following packages from Android SDK Manager: Android Support Repository, Android Support Library, Google Play services, Google Repository.

I'm trying to run an Android Studio default activity (Map activity). Here is the manifest file:

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

Dependencies from build.gradle:

dependencies {
    compile 'com.google.android.gms:play-services:5.2.08'
    compile 'com.android.support:appcompat-v7:20.0.0'
}

The default 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"));
    }
}

What am I missing, what can be the problem? Any help much appreciated.

Thank you.

解决方案

Got a solution. Had to do two things - set the Play Services version to lower: 5.0.89. The last version wasn't available for downloading from any (virtual) device I tested, required update.

Secondly, to install Google Play Services to Genymotion VM, followed instructions under this link: How to install Google Play Services in a Genymotion VM (with no drag and drop support)?.

Cheers.

这篇关于Google Play上的Android Studio缺失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆