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

Problems to set build.gradle files in my demo that built based on official example android_tutorial_pubsub?

asked 2017-04-11 05:35:36 -0500

Zorcs gravatar image

Hello, guys. I'm new to ros, and recently I have trouble to following the official example android_tutorial_pubsub to built my demo. I have been spent a lots of time to set my ros environment in my computer, and it seems good. However, when I'm trying to run the demo there's come the error:

 Information:Gradle tasks [:app:assembleDebug]
Error:trouble processing "javax/xml/parsers/DocumentBuilder.class":
Error:Ill-advised or mistaken usage of a core class (java.* or javax.*)
Error:when not building a core library.
Error:This is often due to inadvertently including a core library file
Error:in your application's project, when using an IDE (such as
Error:Eclipse). If you are sure you're not intentionally defining a
Error:core class, then this is the most likely explanation of what's
Error:going on.
Error:However, you might actually be trying to define a class in a core
Error:namespace, the source of which you may have taken, for example,
Error:from a non-Android virtual machine project. This will most
Error:assuredly not work. At a minimum, it jeopardizes the
Error:compatibility of your app with future versions of the platform.
Error:It is also often of questionable legality.
Error:If you really intend to build a core library -- which is only
Error:appropriate as part of creating a full virtual machine
Error:distribution, as opposed to compiling an application -- then use
Error:the "--core-library" option to suppress this error message.
Error:If you go ahead and use "--core-library" but are in fact
Error:building an application, then be forewarned that your application
Error:will still fail to build or run, at some point. Please be
Error:prepared for angry customers who find, for example, that your
Error:application ceases to function once they upgrade their operating
Error:system. You will be to blame for this problem.
Error:If you are legitimately using some code that happens to be in a
Error:core package, then the easiest safe alternative you have is to
Error:repackage that code. That is, move the classes in question into
Error:your own package namespace. This means that they will never be in
Error:conflict with core system classes. JarJar is a tool that may help
Error:you in this endeavor. If you find that you cannot do this, then
Error:that is an indication that the path you are on will ultimately
Error:lead to pain, suffering, grief, and lamentation.

Error:1 error; aborting
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: Unable to pre-dex '/home/toor/.gradle/caches/modules-2/files-2.1/xml-apis/xml-apis/1.0.b2/3136ca936f64c9d68529f048c2618bd356bf85c9/xml-apis-1.0.b2.jar' to '/home/toor/AndroidStudioProjects/RosTest/app/build/intermediates/transforms/dex/debug/folders/1000/10/xml-apis-1.0.b2_dcead7c64ba2045a1ed89659ff2a64684198f1b0'
Information:BUILD FAILED
Information:Total time: 13.683 secs
Information:34 errors
Information:0 warnings
Information:See complete output in console

After checked the error messages, I know ... (more)

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-04-13 05:44:53 -0500

Zorcs gravatar image

After a lots of check in many ways, finally I think it's maybe the bad network caused the problem. And at last, I had made a configuration for the build.gradle files, and seems good. Anyway, my demo finally works. Here is the settings of the files:

buildscript {
    apply from: "https://github.com/rosjava/android_core/raw/kinetic/buildscript.gradle"
}

allprojects {
    repositories {
        jcenter()
    }
}

subprojects {
    apply plugin: 'ros-android'

    afterEvaluate { project ->
        android {
            packagingOptions {
                exclude 'META-INF/LICENSE.txt'
                exclude 'META-INF/NOTICE.txt'
            }
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

in app directory:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"

    defaultConfig {
        applicationId "com.ros.rosAndroidTest"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

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

    configurations.all {
        resolutionStrategy.force 'com.google.code.findbugs:jsr305:3.0.1'
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])

    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

    compile 'com.android.support.constraint:constraint-layout:1.0.2'

    //ros dependencies
    compile 'org.ros.rosjava_core:rosjava_tutorial_pubsub:[0.2,0.3)'
    compile('org.ros.android_core:android_10:[0.3, 0.4)') {
        exclude group: 'junit'
        exclude group: 'xml-apis'
    }

    testCompile 'junit:junit:4.12'
}

Hope this could be a good suggestion for beginners like me!

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-04-11 05:35:36 -0500

Seen: 765 times

Last updated: Apr 13 '17