Skip to content

nltd101/cmake_cpp_android

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Here’s a rewritten and polished version of your README to make it more professional, clearer, and easier to follow:


πŸ“± Android Native C++ Integration Example

This project demonstrates how to build an Android application that integrates with C++ native code using the Java Native Interface (JNI). It’s ideal for performance-critical operations or reusing existing native libraries in Android apps.


✨ Features

  • Android app built with Java
  • Native functionality implemented in C++
  • Communication between Java and C++ via JNI
  • Built using Android Studio with CMake

πŸ› οΈ Technologies

  • Java – Android framework and UI
  • C++ – Native logic implementation
  • JNI – Bridge between Java and C++
  • Android Studio – Project IDE
  • CMake – Native build system

πŸš€ Getting Started

1. Add Native Library Files

Place your native files in the following directory:

android-project/app/src/main/cpp/testadd/

Include:

  • .so library file
  • Corresponding header (.h) file

2. Configure CMake

Update your CMakeLists.txt located at:

android-project/app/src/main/cpp/CMakeLists.txt

Ensure it properly includes and links your .so library and headers.

3. Call Native Code

Use native-lib.cpp to call your JNI-exposed functions. File location:

android-project/app/src/main/cpp/native-lib.cpp

You can define your native methods here and link them with your Java classes.


πŸ“‚ Project Structure

android-project/
β”œβ”€β”€ app/
β”‚   └── src/
β”‚       └── main/
β”‚           └── cpp/
β”‚               β”œβ”€β”€ testadd/          # Place native .so and .h files here
β”‚               β”œβ”€β”€ native-lib.cpp    # Implement JNI functions here
β”‚               └── CMakeLists.txt    # CMake configuration

πŸ“˜ Notes

  • Make sure your .so file matches the target architecture (e.g., armeabi-v7a, arm64-v8a, etc.).
  • Rebuild the project after modifying native code or CMake configuration.

Let me know if you'd like to include a code sample or a usage example as well.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published