but now my problem is how to import existing .so and .h files in android studio
Usually, you should put your .so
files inside jniLibs
which is usually located at app/src/main/jniLibs
, and put c/c++ source code inside app/src/main/cpp
. See below directory structure.
.
├── CMakeLists.txt // Your cmake configuration files.
├── app.iml
├── build
├── build.gradle
├── libs
├── proguard-rules.pro
└── src
├── androidTest
│ └── java
├── main
│ ├── AndroidManifest.xml
│ ├── cpp // Directory to put your jni native source code.
│ │ └── native-lib.cpp
│ ├── java
│ ├── jniLibs // Directory to put your jni libs, i.e. the .so files.
│ └── res
└── test
└── java
See: https://stackoverflow.com/a/52048933/8034839