rosjava / android_core

Android libraries for rosjava
145 stars 166 forks source link

Android 9 support #286

Closed jubeira closed 5 years ago

jubeira commented 5 years ago

This PR allows creating apps for Android 9 on top of android_core.

Some notes:

TODO list:

Any comments regarding this are welcome! Similar upgrades will be applied to android_apps regarding the minimum SDK version.

jubeira commented 5 years ago

/cc @eborghi10 @ernestmc

blmhemu commented 5 years ago

Hello, I am not a pro, but I have tried to fix the notifications issue on oreo. I have changed some UI components, for easy ergonomics. I can put a pull request, if you say so. Here is the link to my code : https://github.com/blmhemu-rosjava/android_core

jubeira commented 5 years ago

@blmhemu thanks for the heads up! The last time I tried the current code here I didn't have issues with the shutdown notification. I still need to polish the PR a bit and double check that everything is going well (e.g. update build tools; the new Gradle uses the required one anyways), but so far it seems to work well on newer Android devices.

After this PR is merged, we can update the notification functionality if there's a better way to do it in a follow-up PR. The only thing I'd recommend is keeping PRs as atomic as possible in that case.

jubeira commented 5 years ago

This and https://github.com/rosjava/android_apps/pull/80 are ready.

Note that https://github.com/rosjava/rosjava_bootstrap/pull/73 is necessary for this to work; otherwise the new Android Gradle plugin will not be found.

jubeira commented 5 years ago

@ernestmc to build this without merging the PR in rosjava_bootstrap, replace the buildscript block in the top level build.gradle with this:

// Replace external buildscript with this
buildscript {
    apply from: "https://github.com/jubeira/rosjava_bootstrap/raw/task/add_google_repo/buildscript.gradle"
    dependencies {
        classpath "com.android.tools.build:gradle:3.2.0"
    }
}

apply plugin: 'catkin'

// Add repositories block here
allprojects {
    group 'com.github.rosjava.android_apps'
    version = project.catkin.pkg.version
    repositories {
        google()
        jcenter()
    }
}

After merging the PR in rosjava_bootstrap it shouldn't be necessary to hack this file to build the project.

yycho0108 commented 5 years ago

@jubeira I'm currently experiencing the issues related to the NotificationCompat as you described. While waiting for the PR to be merged, would it be possible to ask you how I might be able to apply the patch to an existing ROS Android Application?

EDIT : I ended up compiling android_core from jubeira:android_9_support and linking the .AAR file. Let me know if there's a better way.

jubeira commented 5 years ago

@yycho0108 sorry for the delay, I've been out for some weeks.

I would have suggested exactly what you did. If you are a ROS / catkin user you can place this version of android_core in the same workspace as your application. By making your app depend on android_core[0.4, 0.5) it will be built on top of this and you will have the latest patches and updates.

By any chance, did you encounter any problems when using this code? I'd like to get as much feedback as possible before merging it.

yycho0108 commented 5 years ago

@jubeira It's been some time since I setup the library for the project, but I think when I tried to setup the source dependencies something about how the manifest.srcFile was specified in sourceSets in build.gradle wasn't quite compatible with Android Studio. It might work fine with Eclipse or catkin-based build configuration.

While the issue was perplexing, compiling the library and linking to it wasn't that painful anyways, so I think it's fine - I haven't had a runtime/build error coming up for the project itself.

By the way, thank you for fixing the errors and upgrading android_core to be compatible with the newer APIs -- it made development much easier, and the bug could have been a show-stopper for the project I was working on!

jubeira commented 5 years ago

Update: I updated everything related to Android and I tested building android_apps afterwards. With the last fix in #291 everything ran smoothly.

I also added a note to the tutorials about creating Android packages (and projects) here, and updated the required build tools here.

It would be great to restore a way to create Android packages from the command line directly; I'll update the issue about that.

swarmt commented 5 years ago

This is awesome! Any idea if I can get to the updated android_core_components through maven?

jubeira commented 5 years ago

@swarmt the PR is open here: https://github.com/rosjava/rosjava_mvn_repo/pull/62. Could you try targeting that branch and testing it out? It would be awesome to have it tested somehow before merging.

swarmt commented 5 years ago

I could be doing something wrong here but I can't get org.ros to resolve when targeting your branch. I have however compiled and used your android_core_components no problems on a couple of devices. Thanks for updating it!