简体   繁体   中英

Tango sample apps on Android Studio, with Gradle

Does anyone know a way to import the Java Tango samples ( https://github.com/googlesamples/tango-examples-java ) in Android Studio, and configuring correctly the build with Gradle ? I've been able to import them in Android Studio, via "Import Project...", compile them and install them on the Tango tablet, but without using Gradle. Any ideas ?

I think what you are asking for is the correct setup to let Gradle work for you.

For this you need to create a build.gradle file in your app's directory if the import did not do it for you. The build.gradle should look like this:

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')
}

With the corresponding values for SdkVersion, buildToolsVersion, minSdkVersion and targetSdkVersion. In the "dependencies" block you can list all your jar-dependencies with :

compile files('libs/thejar.jar') or compile fileTree(dir: 'libs', include: ['*.jar']) if you have multiple jars.

Secondly , if it was not automatically created, you would need two files settings.gradle and build.gradle a the top-level of your project.

settings.gradle should contain:

include ':app'

assuming your app name is 'app'.

and build.gradle should contain:

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()
    }
}

Once you have this all in your project, you can use Build>Rebuild Project to make Gradle build the project for you.

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

就像这里的后续操作一样,Tango c示例已迁移到Android Studio项目,您现在应该可以直接导入Android Studio。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM