Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Get Core GL C++ Into Android Project #1753

Closed

Description

@bleege

In order to support C++ / NDK debugging in Android Studio and streamline CI builds and artifact publication we need to refactor the current make android process to integrate the Core GL C++ project files into the Gradle managed Android project. The current process compiles the Core GL into .so files based on ABI and places them into jniLibs for the Gradle build process to then use as a separate step, while the new process will copy the uncompiled C++ files into jni and make (the Gradle driven) Android NDK responsible for compiling them and linking them via JNI to the Android code along with building the SDK as whole in one step. This process will essentially mirror what is done for iOS and Xcode with make iproj where Xcode is responsible for all the compilation and linking.

Unknowns

  • Will custom Android.mk files be needed or will the built in NDK controls in Gradle be enough.
  • Will current GL Makefile process work or will refactoring to use something like Bazel be needed?

Resources

@mapbox/mobile @mapbox/gl

Activity

  1. added
    Android
    on Jun 18, 2015
  2. added this to the milestone on Jun 18, 2015
  3. bleege commented on Jun 18, 2015

    @bleege
    ContributorAuthor

    What Before and After should look like:

    20150618-current-jnilibs-to-new-jni

  4. mb12 commented on Jun 18, 2015

    @mb12

    This would be really awesome when it is available. Is this already working in your local repo?
    In this year's Google IO, they announced that Jetbrains NDK plugin will be available for free for Android development.

    https://www.youtube.com/watch?v=f7ihSQ44WO0

  5. ljbade commented on Jun 19, 2015

    @ljbade
    Contributor

    Yeah I look forward to having everything in Studio too. At one point in time (June last year) I did actually have everything built with a custom Android.mk file but a lot has changed since.

    Let me know if you need help with this @bleege. First I would try getting NDK to compile all the C++ files. If we can get that to work then the hardest bit will be getting everything linked nicely.

  6. bleege commented on Jun 22, 2015

    @bleege
    ContributorAuthor

    @ljbade Yeah, it'd be fantastic to get your 👀 on this.

    First I would try getting NDK to compile all the C++ files.

    Agreed. It's a little unclear to me how all the C++ and related dependencies would be compiled via NDK. I assume that Mason has to stay in the mix somewhere? Can you sketch out how you think this would work on a branch?

  7. ljbade commented on Jun 22, 2015

    @ljbade
    Contributor

    Hmm yeah we going to need mason. Can't think off the top of my head the best way to do this.

    Perhaps we are going to need to create a series of custom Gradle tasks that somehow add dependencies and etc automatically from mason command calls into the NDK settings in the Gradle state.

  8. ljbade commented on Jun 23, 2015

    @ljbade
    Contributor

    This is my thinking so far:

    • gradle has custom task that copies C++ files to jni dir, perhaps by calling a gyp command that does this from the gyp files (it may be better to symlink though so you can edit the files in Android Studio?)
    • gradle has another custom task that runs the mason setup - this will install the deps, copy the libs to the jniLibs dir and also insert the required compiler and linker flags into the NDK compile config
    • gradle then uses normal NDK process to compile jni dir and link with jniLibs
  9. ljbade commented on Jun 23, 2015

    @ljbade
    Contributor

    @kkaefer How hard would it be to get gyp to copy or symlink the C++ files in the Android target instead of compiling them?

    Is it also possible to capture the compile and linker flags set in gyp? Berhaps echoing them to stdout then gradle can grab them

  10. kkaefer commented on Jun 23, 2015

    @kkaefer
    Member

    Can we get around copying the files into the jni dir by specifying the paths in a (generated) Android.mk file?

  11. bleege commented on Jun 23, 2015

    @bleege
    ContributorAuthor

    @kkaefer Yep. We can point the NDK at what ever path we want to. The only potential issue is if the debugger will work like this, but that's more of an unknown as Google hasn't even released it in Android Studio yet. In other words, lets worry about that later.

    My big blocker is just knowing what all needs to be compiled on the C++ side. If I can get pointed at the all the C++ needed I can then get the Gradle / NDK side wired up to start compiling things.

  12. bleege commented on Jun 23, 2015

    @bleege
    ContributorAuthor
  13. bleege commented on Jun 23, 2015

    @bleege
    ContributorAuthor

    According to this bug report Android generator is being removed from GYP.

  14. 81 remaining items

  15. tomlocks commented on Feb 3, 2016

    @tomlocks
    Contributor

    Bumping...

    Would It be possible to get at least working Android.mk and Application.mk files with all flags and dependecies needed to build?

    @ljbade You mentioned before that you successfully created Android.mk with all dependecies for older SDK version. Can you share it with us?

  16. bleege commented on Feb 3, 2016

    @bleege
    ContributorAuthor

    @tomlocks We welcome PRs on enabling this functionality. The difficulty has always been trying to integrate the common C++ code that doesn't live directly in the Android project filesystem as it's reused by iOS, OSX, Qt, and others.

  17. modified the milestone: android-v4.1.0 on Mar 18, 2016
  18. bleege commented on Mar 24, 2016

    @bleege
    ContributorAuthor

    How can I import mapbox-gl-native Android sdk project to Android Studio like you?

    @zhangzhuowh The oiginal work on this was focused on copying the C++ source code into the Android Studio jni folder but it was never finalized. This is still the current status of this work if you'd like to pick this effort up. Pull Requests are always welcomed.

  19. jfirebaugh commented on Feb 8, 2017

    @jfirebaugh
    Contributor

    ⇢ #5855

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Androidrefactor

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions