Android Wear应用无法连接到Google API服务

Android Wear应用无法连接到Google API服务,第1张

概述我正在尝试在AndroidWear和Android手机之间建立连接.googleApiClient无法连接,并返回SERVICE_VERSION_UPDATE_REQUIRED状态代码.我究竟做错了什么?这是我的活动代码:@OverrideprotectedvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);

我正在尝试在Android Wear和Android手机之间建立连接.
Googleapiclient无法连接,并返回SERVICE_VERSION_UPDATE_required状态代码.
我究竟做错了什么?

这是我的活动代码:

@OverrIDeprotected voID onCreate(Bundle savedInstanceState) {    super.onCreate(savedInstanceState);    setContentVIEw(R.layout.activity_my);    int conResult = GooglePlayServicesUtil.isGooglePlayServicesAvailable(context);    if(conResult!=ConnectionResult.SUCCESS){        Log.e(LOG_TAG,"Google play services are not available on this device");    }    Googleapiclient = new Googleapiclient.Builder(this)            .addAPI(Wearable.API)            .addConnectionCallbacks(this)            .addOnConnectionFailedListener(this)            .build();    Googleapiclient.connect();}

这是我在wear文件夹中的build.gradle文件:

apply plugin: 'com.androID.application'androID {    compileSdkVersion 20    buildToolsversion "20.0.0"    defaultConfig {        applicationID "com.example"        minSdkVersion 20        targetSdkVersion 19        versionCode 1        versionname "1.0"    }    buildTypes {        release {            runProguard true            proguardfiles getDefaultProguardfile('proguard-androID.txt'), 'proguard-rules.pro'        }    }}dependencIEs {    //compile 'com.Google.androID.gms:play-services-wearable:+'    compile 'com.Google.androID.support:wearable:+'    compile 'com.androID.support:appcompat-v7:20.+'    compile 'com.Google.androID.gms:play-services:5.+'}

还有我的AndroIDManifest.xml:

<?xml version="1.0" enCoding="utf-8"?><manifest xmlns:androID="http://schemas.androID.com/apk/res/androID"    package="com.example" ><uses-feature androID:name="androID.harDWare.type.watch" /><uses-permission androID:name="androID.permission.BODY_SENSORS" /><uses-permission androID:name="com.Google.androID.provIDers.gsf.permission.READ_GSERVICES" /><uses-permission androID:name="androID.permission.INTERNET"/><uses-permission androID:name="androID.permission.WAKE_LOCK"/><application    androID:allowBackup="true"    androID:icon="@drawable/ic_launcher"    androID:label="@string/app_name"    androID:theme="@androID:style/theme.DeviceDefault" >    <activity        androID:name=".MyActivity"        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.gms.version"        androID:value="@integer/Google_play_services_version" /></application></manifest>

解决方法:

AndroID Wear要求您在手机上安装Google Play服务版本> = 5.0.89

您可以在此处检查您的版本并更新Play服务APK:
https://play.google.com/store/apps/details?id=com.google.android.gms&hl=en

也有用:

important: Because it is hard to anticipate the state of each device,
you must always check for a compatible Google Play services APK before
you access Google Play services features. For many apps, the best time
to check is during the onResume() method of the main activity.

检查Play服务是否可用的代码(在您的手机上):

// ########################################################################// Check if Google Play Services is installed. If not show error dialog.int result = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);if( ConnectionResult.SUCCESS == result ){    mGoogleapiclient.connect();    loadingTextVIEw.setText("Connecting to Wear...");}else {    // Show appropriate dialog    Dialog d = GooglePlayServicesUtil.getErrorDialog(result, this, 0);    d.show();}

此处有更多详细信息:

https://developer.android.com/google/play-services/setup.html#ensure

总结

以上是内存溢出为你收集整理的Android Wear应用无法连接到Google API服务全部内容,希望文章能够帮你解决Android Wear应用无法连接到Google API服务所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1095273.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存