Android Studio 上的 Tango 示例应用,Gradle

Tango sample apps on Android Studio, with Gradle

有谁知道在 Android Studio 中导入 Java Tango 示例 (https://github.com/googlesamples/tango-examples-java) 并使用 Gradle 正确配置构建的方法? 我已经能够通过 "Import Project..." 在 Android Studio 中导入它们,编译它们并将它们安装在 Tango 平板电脑上,但没有使用 Gradle。 有什么想法吗?

我认为您要求的是让 Gradle 为您工作的正确设置。

为此,如果导入没有为您完成,您需要在您的应用程序目录中创建一个 build.gradle 文件。 build.gradle 应如下所示:

apply plugin: 'com.android.project'

android {
    compileSdkVersion 16
    buildToolsVersion "19.1.0"

    defaultConfig {
        minSdkVersion 17
        targetSdkVersion 21
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile files('libs/MyJar.jar')
}

SdkVersion、buildToolsVersion、minSdkVersion、targetSdkVersion对应对应的值。 在 "dependencies" 块中,您可以使用 :

列出所有 jar 依赖项

compile files('libs/thejar.jar')compile fileTree(dir: 'libs', include: ['*.jar']) 如果您有多个罐子。

其次,如果它不是自动创建的,您将需要两个文件 settings.gradlebuild.gradle 作为项目的顶层。

settings.gradle 应包含:

include ':app'

假设您的应用程序名称是 'app'。

build.gradle应该包含:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.0.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

一旦你在你的项目中有了这些,你可以使用 Build>Rebuild Project 为你 Gradle 构建项目。

作为后续,Tango c 示例已迁移到 Android Studio 项目,您现在应该可以直接导入到 Android Studio。

有一个 git 项目已经将示例迁移到 Android Studio - https://github.com/briangriffey/tango-examples-java