0

I am trying to exchange files between watch and handheld by using the channel API.

But when I tried to open the channel by calling the following code, the ChannelAPI can not be resolved . Its not part of the "wearable" class I am using.

I guess there probably was caused by the wrong Android version. Does anyone know which version should I specify in my config files or how to fix it?

Thanks a lot.

My wear bundle file looks like this:

apply plugin: 'com.android.application'


android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "mywearapp"
        minSdkVersion 20
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    dexOptions {
        javaMaxHeapSize "4096m"
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.google.android.support:wearable:1.1.0'
    compile 'com.google.android.gms:play-services-wearable:7.8.0'
    compile project(':shared')
}



 Wearable.ChannelApi.openChannel(
                mGoogleApiClient, node.getId(), "/mypath").setResultCallback(
                new ResultCallback<ChannelApi.OpenChannelResult>() {
                    @Override
                    public void onResult(ChannelApi.OpenChannelResult openChannelResult) {
                        if (openChannelResult.getStatus().isSuccess()) {
                            mChannel = openChannelResult.getChannel();
                            mChannel.getOutputStream(mGoogleApiClient).setResultCallback(

                                    new ResultCallback<Channel.GetOutputStreamResult>() {
                                        @Override
                                        public void onResult(Channel.GetOutputStreamResult getOutputStreamResult) {
                                            if (getOutputStreamResult.getStatus().isSuccess()) {
                                                mOutputStream = getOutputStreamResult.getOutputStream();
                                            } else {
                                                // handle failure, and close channel
                                            }
                                        }
                                    });
                        }
                    }
                });
Foreverniu
  • 349
  • 1
  • 3
  • 18
  • 1
    which version of the playservices are you using? Do you have a compile time or runtime error ? – Blackbelt Sep 10 '15 at 14:27
  • @Blackbelt Thanks for your response. I am using com.google.android.gms:play-services:6.5.87 – Foreverniu Sep 10 '15 at 14:28
  • 1
    that's pretty old. Change it with `compile 'com.google.android.gms:play-services-wearable:7.8.0'`, sync gradle and run it again – Blackbelt Sep 10 '15 at 14:29
  • @Blackbelt I tried change it in the bundle to 7.8.0 and sync it. The problem still exists. It can not resolve the channelAPI as well as the "wearable". I have added my bundle file to the orignial post. Thank you – Foreverniu Sep 10 '15 at 14:37
  • 1
    it looks good. Did you try to restart AS (restart and invalidate cache) ? – Blackbelt Sep 10 '15 at 14:55
  • @Blackbelt I did restarted AS. but it did not work. How to invalidate cache for AS? What made it even worse was that after I played with different sdk versiosn in the bundle files, now even "import com.google.android.gms.wearable.Wearable;" can not be resolved. Even after I have changed the bundle file to where it was. – Foreverniu Sep 10 '15 at 15:12
  • 1
    there is an option under File called Invalidate caches / restart – Blackbelt Sep 10 '15 at 15:13
  • @Blackbelt My problem was solved by actually rebuild the whole project after changing to the right sdk version. Most of the weird errors earlier was probably caused by that. Thanks so much for your help! – Foreverniu Sep 10 '15 at 15:23

0 Answers0