-1

I've been working for a long long... time attempting to build the most basic project on Android with Mapbox that I can, but so far no luck.

There 2 restrictions on how I build it.

1) Build from source

2) App must be debuggable into C++/C source

I have used the following instructions:

https://github.com/mapbox/mapbox-gl-native/blob/master/INSTALL.md and other web pages linked from here.

These pages don't explain how to create a test app, they only tell you how to build the library. I've already followed those and have built the library. I created an app using:

https://www.mapbox.com/help/first-steps-android-sdk/

but it crashes when I run it inside a C++ library function.

It seems reasonable to believe that the developers of Mapbox must be doing this, but I have no idea how. I can't even build a working example using the Mapbox library source, let alone debug it.

I have found the following document that claims to help in debugging a C/C++ Android app, but either it's not clear or there's not enough information to accomplish debugging a source library using this method.

http://tools.android.com/tech-docs/new-build-system/gradle-experimental

A sample project that does this would be quite helpful. Even one that builds a working (doesn't crash) simple example from source without debugging would move me in the right direction. I'll still need to debug it, but at least I would know how to build a working example from source.

I have asked Mapbox for assistance. They typically respond by asking me questions back like, "Do you need to really build the source?" After I answer a few of their questions, they say they'll get back to me. After a few weeks of not hearing back, I ask if they have an answer to my question and they have no memory of the conversation and loop starts over. They seem too busy to follow though on answering my question.

Any assistance on this simple yet elusive task would be much appreciated.

Thank you.

Mitch

UPDATE:

I can get the project to build now, but still no luck getting it to run or debug. I found a page that looked like it might help:

https://github.com/mapbox/mapbox-gl-native/blob/master/platform/android/DISTRIBUTE.md

These instructions don't work and report jni.h file not found. I attempted to correct this by

BUILDTYPE=Debug make apackage -I$JAVA_HOME/include

However, this creates the similar error:

../../include/mbgl/gl/gl.hpp:30:14: fatal error: 'GLES2/gl2.h' file not found

Should I be building from inside Android Studio to get debugging to work or using the command line?

UPDATE:

Also get the error by invoking:

BUILDTYPE=Debug make android-lib-x86-64

but don't get it with:

BUILDTYPE=Debug make android-lib-x86

Also, when I run under Android Studio, the following line crashes:

static {
    System.loadLibrary("mapbox-gl");
}

Inside:

mapbox-gl-native/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java

Does this imply the instructions from Mapbox is missing the step to put the library into the apk?

Mitch
  • 1,716
  • 3
  • 25
  • 41

1 Answers1

2

The docs for building Mapbox GL Native on Linux were just updated:

https://github.com/mapbox/mapbox-gl-native/blob/master/platform/android/CONTRIBUTING_LINUX.md

You should be able to build the test app and install on a phone/emulator following the instructions.

Tested on a fresh install of Ubuntu 16.04 LTS.

tmpsantos
  • 68
  • 2
  • I'm not sure what you mean by "the test app". Maybe you mean "https://github.com/mapbox/mapbox-gl-native/tree/master/platform/android/MapboxGLAndroidSDKTestApp"? This does not look like a test app to me, but rather unit tests. I am looking for an app and not unit tests. If it is an app, can I debug into the C/C++ code in the library with it? – Mitch May 09 '16 at 18:02
  • If you follow the instructions you will get an app installed on your phone where you can add markers, change style, etc. And yes, you can debug the C/C++ core code and also the Java code. – tmpsantos May 10 '16 at 00:07
  • This built, but I can't debug it. I tried loading it as a module in Android Studio, but when it syncs, I get the message: Unable to find method 'com.android.build.gradle.internal.LibraryCache.unload()Ljava/lang/Object;'. Is there a trick to loading the project for debugging? – Mitch May 13 '16 at 03:44
  • Gave up and tried to use make apackage as described in https://github.com/mapbox/mapbox-gl-native/blob/master/platform/android/DISTRIBUTE.md but I get the message In file included from ../../src/mbgl/sprite/sprite_atlas.hpp:5: ../../include/mbgl/gl/gl.hpp:30:14: fatal error: 'GLES2/gl2.h' file not found if using -I$JAVA_HOME/include and jni.h not found when I don't. Does anyone know how I can run the debugger with this code. – Mitch May 15 '16 at 17:57
  • I got the build to run inside Android Studio, but it won't run. Everything immediately crashes. Looks like the error is anything that uses MapView, but not sure. I suspect the application doesn't have a mapbox library it needs to run. I'll keep attempting to build it inside Android Studio. This was suggested by a friend that has more experience with Android development, but he doesn't know mapbox. If you are still there tmpsantos, can you comment on how to debug? I know you work for Mapbox and so I suspect you must know how. Are you still there or should I write you directly? – Mitch May 16 '16 at 01:55
  • Hey tmpsantos. Are you there? – Mitch May 17 '16 at 16:28
  • Anyone... Anyone... You're not even pick up email. – Mitch May 18 '16 at 15:33
  • The testapp setup described on the instructions works for me for changing things on the Java bindings, working on the engine core and fixing crashes by looking at the backtrace on the Android logs. Unfortunately, on Linux, building and running the testapp is as far as I can help you ATM. If by debugging you mean attaching GDB, I haven't done it. We have instructions but they are likely to be outdated: https://github.com/mapbox/mapbox-gl-native/wiki/Android-debugging-with-remote-GDB – tmpsantos May 23 '16 at 16:21
  • From what I can tell, GDB isn't what should be used with Android Studio. It seems to be lldb, but I don't know much about that. I looked at the GDB document you mention. After reading it, I don't think it helps. Thank you for letting me know you are not able to debug the code either. If I can figure out how to do that, I will write up the procedure I used. At least knowing Mapbox isn't debugging let's me know I'm on my own. – Mitch May 30 '16 at 06:01
  • Okay, I'm back attempting to debug. I had a discussion with a Google Engineer and they suggested I dump the build created by Mapbox as it is unworkable for debugging purposes. They tried and failed. They recommended reworking the build system for CMake. If there's been any progress on allowing Mapbox to be debugged, let me know. – Mitch Sep 18 '16 at 20:01
  • Rebuilt the code, still not able to debug just like the Google Engineer said. So as stated above "And yes, you can debug the C/C++ core code and also the Java code." is not true. – Mitch Sep 18 '16 at 23:21
  • @Mitch the current state of the Android tools aren't that great when it comes to doing native debugging on Android. On a day to day basis I use other targets to do my debugging of the native code. We have been promised a lot by Google in latest Google I/O but those tools haven't landed yet or do not work properly (yet). If you have any questions don't hesitate to contact us through https://www.mapbox.com/contact/. – Tobrun Sep 20 '16 at 05:33
  • Hi @Tobrun, I have one simple thing I've been attempting to do for a number of years (literally years) on my rare free time. I simply want to create a map using my own custom projection (it is not Mercator or similar). I saw Mapbox was open source and thought I could modify it to allow me access to the projection formula, but I couldn't understand some of the code. I am open to anything that gets me there. If you have a suggestion, I'd very much appreciate it. If it is any incentive, once this simple task is done, one could leverage the code to be used in many more use cases. – Mitch Oct 02 '16 at 19:37