0

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 ?

matthieu
  • 1,412
  • 1
  • 11
  • 33
  • Can you clarify this - are you saying that Android Studio's gradle scripts folder is empty ? How exactly then is this getting built ? I'm not totally up on the java side of the build process, I use gradle mostly for NDK stuff - I did build and futz with the Java pointcloud sample without having to interact with gradle directly – Mark Mullin Jan 15 '15 at 01:27
  • Yeah, I think my question is: does anyone has already coded gradle.build files for that sample, that I could use. I think @ArthurToenz has some interesting elements in his answer. – matthieu Jan 15 '15 at 21:49

3 Answers3

3

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.

ArthurT
  • 358
  • 1
  • 14
  • All right, thank you very much, I don't have time to look more closely at it right now, but I will try it, and keep you updated on it. – matthieu Jan 21 '15 at 18:56
3

There is a git project which already migrates the samples to Android Studio - https://github.com/briangriffey/tango-examples-java

Bamerza
  • 1,335
  • 1
  • 18
  • 34
1

Just as a follow up here, Tango c examples has been migrated to Android Studio project, you should be able to import directly to Android Studio now.

xuguo
  • 1,816
  • 1
  • 11
  • 15