Ask Your Question
1

rosjava android AppCompatActivity

asked 2016-02-23 14:32:39 -0600

updated 2016-02-25 18:04:44 -0600

All, I have been messing around with rosjava and android and have successfully built a Android application that communicates with ROS using rosjava (I will be posting it on my blog soon www.stratom.com/blog). I created a main activity that extended RosActivity and everything worked great!

Now I am thinking about making more complex android application and will need my activity to extend AppCompatActivity and ROSActivity, I understand I cannot extend multiple classes and will need to build my own class that implements the functionality of ROSActivity but extends AppCompatActivity.

Has anyone done anything similar to this and have any documentation/references I can look at?

I assume I will need to forked the android_core and other dependencies but do not know how to include my local android_core repository into the Android Studio project build.gradle file.

Hopefully when I get this all sorted out I can post a tutorial so that others with the same intentions can implement with minimal head scratching.

I appreciate any help.

  1. Forked rosjava_mvn_repo, android_core and rosjava (metapackage)
  2. Cloned my rosjava_mvn_repo to ~/rosjava_mvn_repo

    git clone https://github.com/stratomda/rosjava_...

  3. Exported my local maven repo variables

    export ROS_MAVEN_REPOSITORY=file://home/username/rosjava_mvn_repo

    export ROS_MAVEN_DEPLOYMENT_REPOSITORY=/home/username/rosjava_mvn_repo

  4. Installed necessary ros-indigo dependencies

    sudo apt-get install ros-indigo-ros-java-build-tools

    sudo apt-get install ros-indigo-warehouse-ros

  5. Build android_core library source with modified code

    mkdir -p ~/android

    wstool init -j4 ~/android/src https://raw.githubusercontent.com/str...

    cd ~/android

    catkin_make

  6. Staged and commited/pushed artifact changes to forked maven repo

    cd ~/rosjava_mvn_repo

    ./update_maven_repo

Note: When i perform Step 6, the update script does not list any android_core .aar files as upgraded or new which makes me believe my updates in the android_10 library did not get built.

  1. Pull in repository artifacts into Android Project using build.gradle

    repositories { maven { url 'https://github.com/stratomda/rosjava_mvn_repo/raw/master' } }

  2. Add android_core dependencies to build.gradle

compile('org.ros.android_core:android_10:0.2.0') { exclude group: 'junit' exclude group: 'xml-apis' }

The project syncs/builds fine but my changes are not included in android_10 external libraries.

Any ideas? Why would the changes not be included in the build when using catkin_make?

[Edit] If I bump the version number in the android_core/package.xml file and run catkin_make the new version aar file is added to the maven repository and everything works. Is there a way I do not have to bump the version number every time I add something in order for it to work?

edit retag flag offensive close merge delete

Comments

1

You could create a default Activity1 (extends RosActivity) and start your Activity2 (extends AppCompatActivity and contains the UI) automatically after the NodeMainExecutor has initialized, using startActivity(...) Have you seen this question?

mmore gravatar imagemmore ( 2016-02-26 00:32:20 -0600 )edit

mmore, If I do what you suggested how can I unsubscribe/shutdown the Activity2 node when the back button is pressed? I would prefer that Activity2 is shutdown when the activity is not present to reduce network traffic. I tried to pass Activity2 a NodeMainExecutor copy and call shutdown(this). Ideas?

dambrosio gravatar imagedambrosio ( 2016-03-03 15:35:04 -0600 )edit

sure, you only need to keep a reference to the node, and shut it down when that happens.

al gravatar imageal ( 2017-02-16 09:39:32 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-01-30 07:47:18 -0600

jubeira gravatar image

Just for further reference and in case anyone needs it, AppCompatRosActivity was added to android_10.

So if anyone needs an AppCompat activity, extend https://github.com/rosjava/android_co... instead of the regular RosActivity.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2016-02-23 14:32:39 -0600

Seen: 444 times

Last updated: Jan 30 '18