in

Android activity crashes as it tries to add a native (C++) library (Visual Studio)


First I’ll clarify my environment: Windows 10, Visual Studio 2017.

That being said, I’m trying to build an Android app that includes a library in the same solution:

I have a red arrow pointing something suspicious about the reference of AndroidLib added to my AndroidApp.

My C++ code in AndroidLib is minimal:

#include "AndroidLib.h"

#include <iostream>

AndroidLib::AndroidLib()
{
}

AndroidLib::~AndroidLib()
{
}

void Java_com_AndroidApp_AndroidLib_nativeHelloWorld()
{
    std::cout << "Oh hi!" << std::endl;
}

My code located in AndroidApp.java is as follow:

package com.AndroidApp;

import android.app.Activity;
import android.widget.TextView;
import android.os.Bundle;

public class AndroidApp extends Activity
{
    //static {
        //System.loadLibrary("AndroidLib");
    //}
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);

        /* Create a TextView and set its text to "Hello world" */
        TextView  tv = new TextView(this);
        tv.setText("Hello World!");
        setContentView(tv);

        nativeHelloWorld();
    }

    public native void nativeHelloWorld();
}

Also very simple.

This is how both projects were created (red is AndroidLib, yellow is AndroidApp):

enter image description here

And, last but not least, this is how the projects properties look like:

enter image description here
enter image description here

This is the output during the application crash:

Stopped due to shared library event (no libraries added or removed)
Stopped due to shared library event:
  Inferior loaded /data/app/com.AndroidApp-zF3CfzRuPZ6vmQ_RuevS7A==/oat/arm/base.odex
Loaded '/data/app/com.AndroidApp-zF3CfzRuPZ6vmQ_RuevS7A==/oat/arm/base.odex'. Cannot find or open the symbol file.

(I’m debugging using a Samsung Galaxy S7 Edge).



Source: https://stackoverflow.com/questions/70609392/android-activity-crashes-as-it-tries-to-add-a-native-c-library-visual-studi

RoW Rules Silent on Deployment of Small Cells in India: COAI DG, SP Kochhar

Project for Student Management System and use of CURD Operation