Android Studio Debug NDK/JNI Mapbox Library - android

I would like to use the Android Mapbox GL library for a project. I will need to modify the source, so I am attempting to include the mapbox-gl-native project source as a git submodule. I'm new to this, so if I'm on the wrong track using a git submodule, let me know that too.
Here's the project:
https://github.com/bessermt/TriMetRail
It all seems to work, but I can't get the debugger to step into the C++ source of the library with Android Studio. I suspect that since the project is only showing me the Java source files and not the C++, that is a clue to what I'm missing.
If anyone has an idea on how to do this, it would be much appreciated.
thx.

The library you reference uses the old gradle plugin:
classpath 'com.android.tools.build:gradle:1.5.0'
The experimental plugin is required today to debug native code in Android Studio. Updating all build scripts, with all the dependencies, for the new plugin may be a tricky task, so I would suggest that you post your request on GitHub.
I doubt this will make it into the android-v3.1.0 milestone.

I think use the experiment version of the gradle may fix the problem

Related

Integrating CMake and ndk-build external libraries into an Android Studio project

I have two existing native libraries that I would like to integrate into an Android project. One has a working Android.mk file and the other has a working CMakeList.txt file. Is there a clean way to link both to Gradle?
Using CMake's ExternalProject[1] is the only idea I have at the moment.
[1] https://cmake.org/cmake/help/v3.0/module/ExternalProject.html
The solution that I arrived at was to add an additional Gradle module to build the ndk-build project. In Gradle terms the project would become a multi-project/multi-module build and is discussed further here [1]. I was also able to express the dependency in Gradle and the project built without issue.
My initial thought of using CMake's ExternalBuild failed under Gradle, but would build fine when invoking CMake from the command line. This probably had something to do with my lack of knowledge in Gradle and CMake.
[1] https://speakerdeck.com/bmuschko/state-of-the-art-gradle-multi-module-builds
I might have what you need. There is an all c++ sample that involves no JAVA UI which is actually a big thing because now your main (entry point) is in a c++ file - you can do OOP and depend on 3rd party libraries without much hassle.
Check out my repo: https://github.com/skanti/Android-Manual-Build-Command-Line

Resolve deprecated NDK warnings in Android Studio

I have an Android app that uses OpenCV's Java wrapper for image processing. To add OpenCV to the project, I had to add the following line to gradle.properties:
android.useDeprecatedNdk=true
This had been working fine without any warnings or errors (that I know of) up until I updated my Android Studio and Gradle after a long time (I'm using Gradle 2.2.2 and Android Studio 2.2.2 now). Now when I build my app, I get the following warnings on the messages window:
Warning:Native C/C++ source code is found, but it seems that NDK
option is not configured. Note that if you have an Android.mk, it is
not used for compilation. The recommended workaround is to remove the
default jni source code directory by adding:
Warning:Deprecated NDK integration enabled by useDeprecatedNdk flag in
gradle.properties will be removed from Android Gradle plugin soon.
Even though the build is successful at this time, as the second warning informs, this is highly likely to cause some trouble in the future, so I want to resolve them as soon as possible before things go sideways.
Does anyone know how to get resolve these warnings? Or are there any other way to import OpenCV to an Android project, other than adding all the compiled code (the .so files) and setting the flag I mentioned earlier? Any help on this will be appreciated.
I would suggest to migrate over to using the native support with cmake. You could check the link which provides a step-by-step tutorial to add OpenCV using cmake via the following link.
You're code should stay the same without any changes, only necessary action is to figure out how to include them within the build process using CMakeLists.txt.
In the project pane, right click your app (in my React Native project it's the "app" catalog), and select "Link C++ project with gradle".
Now you must find the Android.mk file - it should be already generated in your_app/app/build/intermediates/ndk/debug/

How can you add external dependencies to bazel

I am a student and currently working on a project where I am trying to connect my game that which I have created with Android Studio. A neural network has also been made with Tensorflow which is going to be used for the android game.
The problem is that Android Studio uses a build tool which is called Gradle and Tensorflow uses Bazel. To solve this problem I have been trying to build my android game with Bazel but I am stuck at the part where I have to add the used external dependencies. For the game I use the following dependencies:
Appcompat
Support
Percent
Which supposedly should come with the android support repository.
I have looked at http://www.bazel.io/docs/external.html and several other sources but I still do not understand how I can add the dependensies. Could someone provide me with an example how to do it with for example appcompat and what I have to do to make it work? Or is there another way which would be easier?
EDIT: I have have been succesful in building the android example of Tensorflow but this: https://github.com/tensorflow/tensorflow/tree/master/tensorflow/examples/android
But it doesn't include dependensies which I am using.
You may want to look at the Makefile support we just added for Android:
https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/makefile
It's still very experimental (and fiddly), but should let you build a static library that you can more easily use in your gradle project.
Nevermind I resolved my issues, after removing the depensies I checked the WORKSPACE file. It seems I didn't set the package correctly, my bad.

Android NDK unable to debug native code with two gradle plugins

I'm using NDK with the experimental gradle plugin, and initially I was able to debug my native code.
Then I saw this issue https://github.com/googlesamples/android-ndk/issues/119 and this blog post http://frogermcs.github.io/json-parsing-with-flatbuffers-in-android/.
This approach would be great, because I could use the stable gradle plugin for android specific code, and the experimental gradle plugin for the native code, witch would be great to use use databinding for example.
I was able to use this structure, but I lost the ability to debug native code.
I have created a sample project that illustrate my problem.
https://github.com/4brunu/AndroidNDKDebug
In there you can find two projects.
The first one "hello-jni-one-gradle-plugin", only use the experimental gradle plugin, and I'm able to debug the native code.
The second one "hello-jni-two-gradle-plugins", I use the stable gradle plugin for android specific code, and the experimental gradle plugin for the native code, and I'm unable to debug the native code.
Am I doing something wrong?
Could you help me enable native code debug in the second project please?
Thanks
I'm using the same setup in one of my projects, with Android Studio 2.1-preview5, gradle-experimental 0.7.0-alpha5, and gradle plugin 2.1.0-alpha5, and debugging works.
The secret missing step is to add the path to your non-stripped libs to the debugger: lib/build/intermediates/binaries/release/obj/ABI

Android Contributing to Open Source Projects with the gradle dependency

So I am starting to work on some open source libraries that is out there, mainly I have found bugs with the library using my specific project. As far as I know the Gradle library dependency is cached somewhere and not accessible.
What I would like to do is be able to create a branch for the fix and test in my project. Is there efficient way of doing this or do I need to comment out my gradle dependency and do a manual import of the library and do the fix?
I think that project is available on GitHub? You have 2 options then:
Open a issue at the project and describe your problems. Maybe the author will fix them himself
Fork the Project. You can work on your own on it then and make a Pull Request later if you want to.
You can of course download the source code and modify it yourself locally too, but that's not the purpose of Open Source Projects I think :)

Categories

Resources