Topic: Integrate TLS into the Native Android App
Hello,
How do I import WolfSSL Library into the Android App? I downloaded the WolfSSL Android Client and went through the instructions provided in the "Readme.md" file :
An Android SSL Client using the wolfSSL JNI library
## Prerequisits for successful installation
In order to build the wolfSSL Android client you need to:
* Have `Java JDK 7` or later installed
* Install the `Android NDK` [link](https://developer.android.com/tools/sdk/ndk/index.html)
* Install the `Android SDK` [link](http://developer.android.com/sdk/index.html)
* Install [JUnit-4.11](http://junit.org/) or later. Add `JUNIT_HOME` to your classpath
After installing the Android SDK, run the `SDK Tools` app packaged with it and install Android 4.3 or higher. After you have those installed, you will need to build and install CyaSSL to your system.
### Build and Install CyaSSL
CyaSSL should be located at the root of JNI-Client.
1. To install CyaSSL in Terminal, use the following configure command and hit enter:
```
./configure --enable-dtls --enable-opensslextra --enable-crl --enable-ocsp --enable-crl-monitor --enable-savesession --enable-savecert --enable-atomicuser --enable-ecc --enable-aesgcm --enable-camellia --enable-pkcallbacks
```
2. Type `make`, hit enter.
3. Type `sudo make install`, hit enter. CyaSSL should now be installed.
Once you have compiled and installed CyaSSL, navigate to the `wolfssl-jni` folder located at the root of JNI-Client.
Before we can build the JNI library, we need to make sure your `java.sh` file is setup correctly. Open your `java.sh` file and make sure the `javaIncludes=` path is correctly pointing to your java includes folder. For example, you may need to change it from `java-7-openjdk-amd64` to `oracle-java-8` if you are using oracles Java 8.
1. type `./java.sh` and hit enter, this compiles the native JNI sources into a shared library
2. type `ant` and hit enter, this compiles the java sources and runs tests to make sure it's working correctly
3. You should now have a `wolfssl.jar` file in the `libs` folder. Copy the `wolfssl.jar` file to `JNI-Client/libs` folder.
#### Troubleshooting
When running `ant`, if you get compile errors referring to JUnit you may need to edit the `build.xml` and change
```xml
<include name="junit4.jar"/>
```
to
```xml
<include name="junit-4.11.jar"/>
```
or to whatever the latest version of JUnit is that you installed.
## Building the Android Client
1. In terminal, navigate to the root of JNI-Client
2. type `android list targets` and get the id # of the latest Android version you have installed.
3. type `android update project -t <id#> -p .` without the < > brackets, hit enter. This will create the project properties file.
4. type `ndk-build` hit enter. This will compile the native c files used in the JNI.
The project should now be built and ready to install to an Android device, or emulator.
## Installing the Android Client
To install to your Android device or emulator, make sure your device or emulator has `Android HoneyComb` or later installed then do the following.
1. a) If you are using an emulator, start the emulator and wait until it is fully loaded before continuing.
1. b) If you are using a physical device, make sure you have the Google USB drivers installed and then plug your device in via usb cable.
2. type `ant debug` then hit enter.
3. type `ant debug install` then hit enter, the Android Client should now be installed on your device/emulator as `SSL Client`
## Coding Style
wolfSSL has a strict coding standard that we like to follow. If you plan on submitting a pull request and are using the Eclipse IDE, please import our coding standard.
1. Open the `Windows -> Preferences`
2. Under `Java -> Code Style -> Formatter` click on `Import...`
3. Browse to the `wolfssl-eclipse-format.xml` file at the root of the repository.
4. Save the settings and use `ctrl-shift-f` to format any added source.
In addition to using the Eclipse formatter, please use `ctrl-shift-o` to organize the import statements and remove unneeded ones.
I have Android SDK, NDK, Java 1.8 installed into my laptop. I even mentioned the JVM path to be included in the java.sh file - "/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/include".
When I run this command "./java.sh", I get an error like this:
clang: error: no such file or directory: './native/com_wolfssl_WolfSSL.o'
clang: error: no such file or directory: './native/com_wolfssl_WolfSSLSession.o'
clang: error: no such file or directory: './native/com_wolfssl_WolfSSLContext.o'
clang: error: no such file or directory: './native/com_wolfssl_wolfcrypt_RSA.o'
clang: error: no such file or directory: './native/com_wolfssl_wolfcrypt_ECC.o'
I'm using MacBook Air M2. Can anyone help me to import WolfSSL into the Android App?