[Android] How to use the prebuilt .so lib files (ndk native C++)
Related post: https://medium.com/@nhancv/android-set-up-an-environment-for-c-native-ndk18-50b146b4dad0
Create jniLibs folder place at:
app/src/main/jniLibs
Push *.so files with respective platform (arm64-v8a, armeabi-v7a, x86, x86_64) folder:
app/src/main/jniLibs/armeabi-v7a/native-lib.so
Update app/src/main/java/com/nhancv/myapplication/MainActivity.java
package com.nhancv.myapplication;import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;public class MainActivity extends AppCompatActivity {
static {
System.loadLibrary("native-lib");
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Example of a call to a native method
TextView tv = findViewById(R.id.sample_text);
tv.setText(stringFromJNI());
} /**
* A native method that is implemented by the 'native-lib' native library,
* which is packaged with this application.
*/
public native String stringFromJNI();
}