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

Android 9 support #286

Merged
merged 11 commits into from
Dec 26, 2018
Merged

Android 9 support #286

merged 11 commits into from
Dec 26, 2018

Conversation

jubeira
Copy link

@jubeira jubeira commented Sep 7, 2018

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

Some notes:

  • Keeping it backwards compatible is starting to be really annoying. The notification system changed a lot, and NotificationCompat was deleted from the support library v27. When upgrading the API target, Android Studio suggests upgrading the support library as well.
  • The Notification class without compatibility libraries is available since API 16. Since devices up to API 15 nowadays represent less than 1% of the total devices around, I strongly suggest raising the minimum API level and stop using deprecated compatibility stuff. API 16 is still really old nowadays, and it's far more useful to be able to develop applications for current devices. Furthermore, starting on November 1, 2018, applications with target SDK < 26 won't be allowed to be released / updated to the Play Store.
  • As this breaks compatibility and the code in this repository still uses the API numbers, I will merge android_10 and android_15 into one Gradle project (android_core), and bump the package version to 0.4.0.

TODO list:

  • clean up the code in the notification, and ensure that the apps close properly whenever the user clicks on it.
  • upgrade Gradle wrapper version and Android plugin to latest ones.
  • upgrade tutorials. With build tools > 25, the android command is no longer available, so the command line cannot be used anymore to create new projects. The best approach would be to start on top of an existing application in Android Studio.

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

@jubeira
Copy link
Author

jubeira commented Sep 7, 2018

/cc @eborghi10 @ernestmc

@blmhemu
Copy link

blmhemu commented Sep 23, 2018

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
Copy link
Author

jubeira commented Sep 24, 2018

@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
Copy link
Author

jubeira commented Oct 4, 2018

This and rosjava/android_apps#80 are ready.

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

@jubeira
Copy link
Author

jubeira commented Oct 4, 2018

@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
Copy link

yycho0108 commented Oct 14, 2018

@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
Copy link
Author

jubeira commented Oct 30, 2018

@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
Copy link

@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 jubeira merged commit c5c2aff into rosjava:kinetic Dec 26, 2018
@jubeira jubeira deleted the android_9_support branch December 26, 2018 15:35
@jubeira
Copy link
Author

jubeira commented Dec 26, 2018

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
Copy link

swarmt commented Dec 29, 2018

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

@jubeira
Copy link
Author

jubeira commented Dec 31, 2018

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

@swarmt
Copy link

swarmt commented Jan 1, 2019

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!

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

Successfully merging this pull request may close these issues.

5 participants