Android Studio Android工作室与Google Play:Google Play服务缺失

qhhrdooz  于 2022-12-27  发布在  Android
关注(0)|答案(4)|浏览(166)

我正在使用Ubuntu 14,Android Studio 0. 8. 6。我正在使用Genymotion运行应用程序,我得到的React是:

W/GooglePlayServicesUtil﹕ Google Play services is missing.

尝试了Import Google Play Services library in Android Studio的解决方案,也从Android Studio with Google Play Services.安装了以下软件包从Android SDK管理器:Android支持存储库,Android支持库,Google Play服务,Google存储库。
我正在尝试运行Android Studio默认Activity(MapActivity)。以下是清单文件:

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

来自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"));
    }
}

我错过了什么,有什么问题吗?任何帮助都非常感谢。
谢谢你。

kr98yfug

kr98yfug1#

得到了一个解决方案。必须做两件事-将播放服务版本设置为较低:5.0.89.最后一个版本无法从我测试的任何(虚拟)设备下载,需要更新。
其次,要将Google Play服务安装到Genymotion VM,请按照此链接下的说明操作:How to install Google Play Services in a Genymotion VM (with no drag and drop support)? .
干杯。

ua4mk5z4

ua4mk5z42#

另一个解决方案是将模拟器的目标更改为API

要在使用Google Play服务SDK时测试您的应用,您必须将Android模拟器与运行基于Android 4.2.2或更高版本的Google API平台的AVD配合使用。Source

vh0rcniy

vh0rcniy3#

Ojonugwa的解决方案很好,但另外还有一个问题,即最新版本的Google Play服务在模拟器上不可用。然而,运行API版本21或19的模拟器上提供了相应版本的Google Play服务。
当前的解决方案是创建一个API版本为21或19的新AVD,并针对Google API(而不是Andriod x.x.x)。如果您使用API版本为21或19的Google API AVD,它应该按预期工作。
https://github.com/googlesamples/google-services/issues/32

vktxenjb

vktxenjb4#

对于Linux用户,我解决了这3个步骤:
1.转到“主页/“your_username”/.android/avd/[您的虚拟设备文件夹]”,并通过双击使用文本编辑器打开“config.ini”
2)将“PlayStore.enabled=假”更改为“PlayStore.enabled=真”
3-更改“系统映像/安卓30/google_apis/x86/”

“image.sysdir.1 =系统图像/安卓30/谷歌应用程序接口播放商店/x86/”

相关问题