rosjava android AppCompatActivity
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.
- Forked rosjava_mvn_repo, android_core and rosjava (metapackage)
Cloned my rosjava_mvn_repo to ~/rosjava_mvn_repo
git clone https://github.com/stratomda/rosjava_...
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
Installed necessary ros-indigo dependencies
sudo apt-get install ros-indigo-ros-java-build-tools
sudo apt-get install ros-indigo-warehouse-ros
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
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.
Pull in repository artifacts into Android Project using build.gradle
repositories { maven { url 'https://github.com/stratomda/rosjava_mvn_repo/raw/master' } }
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?
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, 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?
sure, you only need to keep a reference to the node, and shut it down when that happens.