0

I'm using Android Studio to build an Android app. I'm using Kotlin, and I'm using C++ code, i.e. native C++ that I interface with using JNI. I'm able to do this in the MainActivity, because Android Studio offers this build in their setup. However, I can't figure out a way to call native C++ functions from a second empty activity that I created. Does anyone know how to set up a second activity to access native C++ code?

Thanks for any help!

xash
  • 3,702
  • 10
  • 22
John Alway
  • 65
  • 10
  • Just make sure that you follow [the required naming convention](https://stackoverflow.com/questions/32470463/what-is-the-naming-convention-for-java-native-interface-method-and-module-name/32473938#32473938), and that the library has been loaded by the time you attempt to call the native functions. – Michael Oct 03 '21 at 06:59
  • Please show code and error messages after you add a `native` method to your second activity. – Botje Oct 04 '21 at 12:10
  • @Michael Thanks for your response. For the record, I ended up using a lateinit var to MainActivity in a companion object in the MainActivity, and I referenced it in the second activity. That worked to access my native c++ functions. – John Alway Oct 06 '21 at 00:12
  • @Botje -- I ended up getting it working as described to Michael. – John Alway Oct 06 '21 at 00:13

0 Answers0