ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

ROS and Android with Kinetic and Android Studio

asked 2017-10-20 09:58:52 -0600

TristanKpka gravatar image

updated 2017-10-20 11:33:29 -0600


I'm trying to get ROS (Kinetic) and Android working together in Android Studio. I followed the tutorial

I created a new project, edited the gradle files but I get this error when I try to build the app and I cannot find anything about this.

Error:Android tasks have already been created.
This happens when calling android.applicationVariants,
android.libraryVariants or android.testVariants.
Once these methods are called, it is not possible to
continue configuring the model.

Any idea ?

Thanks in advance :)

edit retag flag offensive close merge delete


Hello! Could you please specify at what point you got that error?

jubeira gravatar image jubeira  ( 2017-10-20 11:26:45 -0600 )edit

I got that error when I build the app. I've edited my answer.

TristanKpka gravatar image TristanKpka  ( 2017-10-20 11:33:53 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2017-10-20 14:14:29 -0600

jubeira gravatar image

Instead of placing the ros-android plugin in the bottom level Gradle file, leave the bottom level as is. Just add android_10 to the dependencies and remove the espresso from AndroidTestCompile.

Your bottom level script should look like something like this:

apply plugin: ''

android {
    compileSdkVersion 26
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.project.androidrostest"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner ""
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), ''

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile ''
    compile ''
    testCompile 'junit:junit:4.12'
    compile 'org.ros.android_core:android_10:[0.3,0.4)'    // Added dependency!!!

In your top-level script, replace the buildscript as the tutorial indicates:

buildscript {
    apply from: ""

And add the following:

subprojects {
    apply plugin: 'ros-android'

    afterEvaluate { project ->
        android {
            // Exclude a few files that are duplicated across our dependencies and
            // prevent packaging Android applications.
            packagingOptions {
                exclude "META-INF/LICENSE.txt"
                exclude "META-INF/NOTICE.txt"

Note: you might need to remove the android:icon from the manifest or indicate to replace it with another one, as android_10 already provides a default.

Let me know if it worked. If it does, I will update the tutorial.

edit flag offensive delete link more


Thank you. I added your code plus tools:node="replace" in the manifest. I am compiling a project that needs dependencies.

TristanKpka gravatar image TristanKpka  ( 2017-10-23 02:59:25 -0600 )edit
jubeira gravatar image jubeira  ( 2017-10-23 15:48:10 -0600 )edit

Question Tools


Asked: 2017-10-20 09:58:52 -0600

Seen: 776 times

Last updated: Oct 20 '17