Dynamic library in a Visual Studio 2015 Native Android Application?


  • I am trying to create a simple Visual C++ Native Activity Application (Android) that uses a dynamic shared library (.so). It seems to be a common thing, but I still can't find any samples for this. Microsoft provides the TwoLibs sample, which is somewhat similar, but there the library is called from Java code. I need to do this in C++.

    I tried to make a native activity and adding a reference to the shared library project. 

    It compiles fine, but when I run it, the program crashes. It doesn't even matter whether I call any functions from the library.

    When I use a static library it doesn't crash.

    I have also tried to add a compiled .so library to the list of dependencies with the same success: 

    Could somebody explain me how this is supposed to be done?

    • Edited by Lanamelach Tuesday, May 31, 2016 9:59 AM
    Tuesday, May 31, 2016 9:25 AM

All replies

  • Hi Lanamelach,

    Could you please tell me what's the version of your Visual Studio?

    How about running the Visual Studio in safe mode to check whether it has the same problem?

    Also please try to restart your Virtual Machine then try it again. If still no help. I suppose there might be something wrong with the installation of the Cross Platform components. Try to re-install it and try it again.

    By the way, to validate whether the cause is in your Visual Studio. Please try to do a repair of your Visual Studio or install the latest update of Visual Studio.

    In addition, if after repairing, it has the same issue. I suggest you'd better post to this Android development in Visual Studio forum for better support.

    Thanks for your understanding.

    Best Regards,

    Lake Xiao

    Wednesday, June 1, 2016 5:43 AM
  • I'm using Visual Studio 2015 (Version 14.0.25123.00 Update 2). I've just installed all available updates, but the issue still persists. 

    How do I run VS in safe mode? And what Virtual Machine are you referring to? I'm running Visual Studio on my computer natively (Windows 8.1 x64). However, I'd like to mention that I have Hyper Visor disabled as it conflicts with VMware, which I need for work.

    Regarding the link to another forum, is it about xamarin or Visual Studio? As I don't use xamarin. Or should I? I thought VS is enough for development.

    Wednesday, June 1, 2016 7:13 AM
  • Hi Lanamelach,

    Thanks for your response.

    I just did a test in my side using VS2015 Update2. And the test result is same to you. When I use the dynamic shared library, the emulator and the Visual Studio crash. But when I use a static library it doesn't crash.

    I am not familiar with this problem. Perhaps it is not allowed to use the dynamic shared library in this place. Or this might be a known issue in VS2015 Update2.

    I suggest you could try to post a feedback report to the I Microsoft Connect feedback portal:

    Microsoft engineers will evaluate them. Also please share link here. Since my result is same to you. I will help to vote it. 

    Best Regards,

    Lake Xiao

    Thursday, June 2, 2016 1:05 AM
  • Hello again. I've reported the issue, but that guy told me it was by design and suggested creating a java app... I'm confused now, because I don't want to develop my application in java and I saw many videos about C++ cross-platform mobile development in Visual Studio. But almost any more or less serious app needs some third-party stuff, normally distributed in libraries. After all, Visual Studio doesn't seem to be a java IDE. So how was it supposed to develop android applications there, if I can't even load libs?

    Thursday, June 30, 2016 12:30 PM
  • Hi Lanamelach,

    I agree with you. Visual Studio is not a java IDE. And if you want to develo mobile developmenet. One idea I suggest you could use Xamarin which is intergrated in Visual Studio and used to develop mobile application.

    Best Regards,

    Lake xiao

    Thursday, June 30, 2016 2:15 PM
  • Can I develop C++ applications with Xamarin or is it only for C#/.NET? 

    Friday, July 1, 2016 7:12 AM
  • Hi Lanamelach,

    As far as I know, it also support to develop C++ application.


    Best Regards,

    Lake Xiao

    Monday, July 4, 2016 1:12 AM
  • As far as understand the article, they merely use a C++ dynamic library in a C# project. I'd like to develop the whole application in C++ (probably, with some tiny java wrappers if needed). How do I do that?
    Monday, July 4, 2016 5:24 AM