Android Studio可穿戴进口“不工作”

时间:2015-04-02 16:43:05

标签: java android gradle

长话短说我决定玩新的Google可穿戴设备,所以我打开了android studio并点击了示例项目中的导入。 (请注意,我选择导入的项目并尝试了很多项目并不重要)

我打开项目并且一切都错了,因为Android工作室无法找到可穿戴设备......但它可以将它构建到手表上就好了。所以基本上如果我输入

mApiClient = new GoogleApiClient.Builder(this);

GoogleApiClient变为红色,因为它"无法找到对象"

import com.google.android.gms.common.ConnectionResult; <-- cannot find symbol common
import com.google.android.gms.common.api.GoogleApiClient; <-- cannot find symbol common
import com.google.android.gms.common.api.ResultCallback; <-- cannot find symbol common
import com.google.android.gms.wearable.MessageApi; <-- cannot find symbol MessageApi
import com.google.android.gms.wearable.MessageEvent; <-- cannot find MessageEvent
import com.google.android.gms.wearable.Node; <-- Cannot find Node
import com.google.android.gms.wearable.NodeApi; <-- Cannot find NodeApi
import com.google.android.gms.wearable.Wearable; <-- Cannot find Wearable

现在请注意......所有这些构建......它只是让编辑器无用,因为它没有给我任何代码帮助,并且总是告诉我项目中有100个错误。它比记事本更糟糕!

我尝试过的事情:

  • 卸载并重新安装Android Studio(现在3次)

  • 卸载并重新安装所有Android SDK及其他内容 工具

  • 点击按钮将项目与Gradle同步(1000次)

  • 检查所有Gradle文件以获取正确的包(同样,这些是 示例代码,它确实构建...所以它必须得到 正确的东西...)

  • 通过在其上安装Hackintosh然后刻录来威胁我的电脑 它。 (现在至少6次)

我试过环顾四周但到目前为止还没找到任何修复它的东西。任何帮助将不胜感激。

由于

编辑:

(延迟应用程序可穿戴样本代码!)

gradle文件:

模块申请:

buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:1.0.0'
    }
}

apply plugin: 'com.android.application'

repositories {
    jcenter()
}

dependencies {
    compile "com.android.support:support-v4:21.0.2"
    compile "com.android.support:support-v13:21.0.2"
    compile "com.android.support:cardview-v7:21.0.2"
    compile 'com.google.android.gms:play-services-wearable:6.5.+'
    compile 'com.android.support:support-v13:21.0.+'
    wearApp project(':Wearable')
}

// The sample build uses multiple directories to
// keep boilerplate and common code separate from
// the main sample code.
List<String> dirs = [
    'main',     // main sample code; look here for the interesting stuff.
    'common',   // components that are reused by multiple samples
    'template'] // boilerplate code that is generated by the sample template process

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        minSdkVersion 18
        targetSdkVersion 21
    }

    sourceSets {
        main {
            dirs.each { dir ->
                java.srcDirs "src/${dir}/java"
                res.srcDirs "src/${dir}/res"
            }
        }
        androidTest.setRoot('tests')
        androidTest.java.srcDirs = ['tests/src']

    }

}

模块:可穿戴

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:1.0.0'
    }
}

apply plugin: 'com.android.application'



dependencies {


    compile 'com.google.android.gms:play-services-wearable:6.5.+'
    compile 'com.android.support:support-v13:21.0.+'
    compile 'com.google.android.support:wearable:1.1.+'
}

// The sample build uses multiple directories to
// keep boilerplate and common code separate from
// the main sample code.
List<String> dirs = [
    'main',     // main sample code; look here for the interesting stuff.
    'common',   // components that are reused by multiple samples
    'template'] // boilerplate code that is generated by the sample template process

android {
    compileSdkVersion 21

    buildToolsVersion "21.1.2"

    defaultConfig {
        versionCode 1
        versionName "1.0"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt')
        }
    }
    sourceSets {
        main {
            dirs.each { dir ->
                java.srcDirs "src/${dir}/java"
                res.srcDirs "src/${dir}/res"
            }
        }
        androidTest.setRoot('tests')
        androidTest.java.srcDirs = ['tests/src']

    }
}

希望这有帮助!希望我能错过一些愚蠢的东西。在我的Mac上,我能够导入示例代码并运行它(在我的窗口上我可以运行它...只是编辑会很糟糕。)

1 个答案:

答案 0 :(得分:1)

听起来它可能只是一个问题,你的设置文件不知何故被破坏了。我会尝试将android studio重置为默认状态。

请参阅此问题了解步骤 - How to reset Android Studio