Skip to content
This repository has been archived by the owner on Nov 9, 2022. It is now read-only.

class file for org.ros.internal.message.Message not found #311

Open
SyuanLiao opened this issue Jan 9, 2020 · 2 comments
Open

class file for org.ros.internal.message.Message not found #311

SyuanLiao opened this issue Jan 9, 2020 · 2 comments

Comments

@SyuanLiao
Copy link

SyuanLiao commented Jan 9, 2020

Hi all,

I tried to do this:

@Override
public void onStart(final ConnectedNode connectedNode){
    final Publisher<std_msgs.String> pubString =
            connectedNode.newPublisher("table_talk", std_msgs.String._TYPE);

    connectedNode.executeCancellableLoop(new CancellableLoop() {
        @Override
        protected void loop() throws InterruptedException {
            std_msgs.String msg = pubString.newMessage();
            msg.setData("hello");
            pubString.publish(msg);
            Thread.sleep(1000);
        }
    });
}

then I got the error message:

error: cannot access Message
 msg.setData("Hello");
                   ^
  class file for org.ros.internal.message.Message not found

And this is my build.gradle:

buildscript {
    repositories {
        google()
        jcenter()
        maven { url 'https://github.com/rosjava/rosjava_mvn_repo/raw/master' }
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.3'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()

        maven { url 'https://github.com/rosjava/rosjava_mvn_repo/raw/master' }
        mavenCentral()

    }
}

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

another one:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "test.android"
        minSdkVersion 15
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

    implementation 'org.ros.rosjava_core:rosjava:[0.1,0.2)'
    implementation 'org.ros.android_core:android_10:[0.3,0.4)'
    implementation 'org.ros.android_core:android_15:[0.3,0.4)'
    implementation 'org.ros.rosjava_messages:std_msgs:[0.5, 0.6)'
}

May somebody help me? Thank you!!

@colin-broderick
Copy link

colin-broderick commented Jan 24, 2020

Same problem. I'm working from what looks like the same example as SyuanLiao: https://github.com/ollide/rosjava_android_template/tree/master/rosandroid-example-app/src/main/java/org/ollide/rosandroid

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.example.rosdroid"
        minSdkVersion 15
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.android.material:material:1.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

    implementation 'org.ros.android_core:android_honeycomb_mr2:0.1.2'
    implementation 'org.ros.android_core:android_gingerbread_mr1:0.1.2'
    implementation 'org.ros.rosjava_core:rosjava:0.3.6'
    implementation 'org.ros.rosjava_messages:std_msgs:0.5.11'
}

@Goochaozheng
Copy link

Solved the same problem according to this.
Adding message related dependencies manually to your build.gradle file:

implementation 'org.ros.rosjava_bootstrap:message_generation:[0.3, 0.4)'

It looks like newer version of gradle fails to resolve these second-level dependencies properly.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants