-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
Sample Android project, Android Gradle GitHub Action, and gradle build fixes
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: Android Gradle Build test logic | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
os: | ||
required: true | ||
type: string | ||
jdk_distro: | ||
required: true | ||
type: string | ||
jdk_version: | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
build_wolfssljni: | ||
runs-on: ${{ inputs.os }} | ||
steps: | ||
- name: Clone wolfcrypt-jni | ||
uses: actions/checkout@v4 | ||
|
||
# Clone native wolfSSL | ||
- name: Clone native wolfSSL | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: 'wolfssl/wolfssl' | ||
path: IDE/Android/app/src/main/cpp/wolfssl | ||
|
||
# Copy options.h.in to blank options.h | ||
- name: Create blank options.h | ||
run: cp IDE/Android/app/src/main/cpp/wolfssl/wolfssl/options.h.in IDE/Android/app/src/main/cpp/wolfssl/wolfssl/options.h | ||
|
||
# Setup Java | ||
- name: Setup java | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: ${{ inputs.jdk_distro }} | ||
java-version: ${{ inputs.jdk_version }} | ||
|
||
# Gradle assembleDebug | ||
- name: Gradle assembleDebug | ||
run: cd IDE/Android && ls && ./gradlew assembleDebug | ||
|
||
# Gradle assembleDebugUnitTest | ||
- name: Gradle assembleDebugUnitTest | ||
run: cd IDE/Android && ls && ./gradlew assembleDebugUnitTest | ||
|
||
# Gradle assembleDebugAndroidTest | ||
- name: Gradle assembleDebugAndroidTest | ||
run: cd IDE/Android && ls && ./gradlew assembleDebugAndroidTest | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/caches | ||
/.idea/libraries | ||
/.idea/modules.xml | ||
/.idea/workspace.xml | ||
/.idea/navEditor.xml | ||
/.idea/assetWizardSettings.xml | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# Android Studio Example Project | ||
|
||
This is an example Android Studio project file for wolfcrypt-jni / wolfJCE. | ||
This project should be used for reference only. | ||
|
||
Tool and version information used when testing this project: | ||
|
||
- Ubuntu 20.04.3 LTS | ||
- Android Studio Chipmunk 2021.2.1 | ||
- Android Gradle Plugin Version: 4.2.2 | ||
- Gradle Version: 7.1.3 | ||
- API 30: Android 11 | ||
- Emulator: Pixel 5 API 31 | ||
|
||
The following sections outline steps required to run this example on an | ||
Android device or emulator. | ||
|
||
## 1. Add Native wolfSSL Library Source Code to Project | ||
|
||
This example project is already set up to compile and build the native | ||
wolfSSL library source files, but the wolfSSL files themselves have not been | ||
included in this package. You must download or link an appropriate version | ||
of wolfSSL to this project using one of the options below. | ||
|
||
The project looks for the directory | ||
`wolfcrypt-jni/IDE/Android/app/src/main/cpp/wolfssl` for wolfSSL source code. | ||
This can added in multiple ways: | ||
|
||
- OPTION A: Download the latest wolfSSL library release from www.wolfssl.com, | ||
unzip it, rename it to `wolfssl`, and place it in the direcotry | ||
`wolfcrypt-jni/IDE/Android/app/src/main/cpp/`. | ||
|
||
``` | ||
$ unzip wolfssl-X.X.X.zip | ||
$ mv wolfssl-X.X.X wolfcrypt-jni/IDE/Android/app/src/main/cpp/wolfssl | ||
``` | ||
|
||
- OPTION B: Alternatively GitHub can be used to clone wolfSSL: | ||
|
||
``` | ||
$ cd /IDE/Android/app/src/main/cpp/ | ||
$ git clone https://github.com/wolfssl/wolfssl | ||
$ cp wolfssl/options.h.in wolfssl/options.h | ||
``` | ||
|
||
- OPTION C: A symbolic link to a wolfssl directory on the system by using: | ||
|
||
``` | ||
$ cd /IDE/Android/app/src/main/cpp/ | ||
$ ln -s /path/to/local/wolfssl ./wolfssl | ||
``` | ||
|
||
## 2. Update Java Symbolic Links (Only applies to Windows Users) | ||
|
||
The following Java source directory is a Unix/Linux symlink: | ||
|
||
``` | ||
wolfcrypt-jni/IDE/Android/app/src/main/java/com/wolfssl | ||
``` | ||
|
||
This will not work correctly on Windows, and a new Windows symbolic link needs | ||
to be created in this location. To do so: | ||
|
||
1) Open Windows Command Prompt (Right click, and "Run as Administrator") | ||
2) Navigate to `wolfcrypt-jni\IDE\Android\app\src\main\java\com` | ||
3) Delete the existing symlink file (it shows up as a file called "wolfssl") | ||
|
||
``` | ||
del wolfssl | ||
``` | ||
|
||
4) Create a new relative symbolic link with `mklink`: | ||
|
||
``` | ||
mklink /D wolfssl ..\..\..\..\..\..\..\src\java\com\wolfssl\ | ||
``` | ||
|
||
## 3. Import and Build the Example Project with Android Studio | ||
|
||
1) Open the Android Studio project by double clicking on the `Android` folder | ||
in wolfcrypt-jni/IDE/. Or, from inside Android Studio, open the `Android` | ||
project located in the wolfcrypt-jni/IDE directory. | ||
|
||
2) Build the project and run MainActivity from app -> java/com/example.wolfssl. | ||
This will ask for permissions to access the certificates in the /sdcard/ | ||
directory and then print out the server certificate information on success. | ||
|
||
## Support | ||
|
||
Please contact wolfSSL support at [email protected] with any questions or | ||
feedback. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdk 33 | ||
defaultConfig { | ||
applicationId "com.example.wolfssl" | ||
/* Min SDK should stay at 24 to detect if we try to use newer APIs | ||
* than were available in that Android SDK. We have users who are still | ||
on SDK 24 (ref ZD 18311) */ | ||
minSdkVersion 24 | ||
targetSdkVersion 33 | ||
versionCode 1 | ||
versionName "1.0" | ||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
externalNativeBuild { | ||
cmake { | ||
cppFlags "" | ||
} | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_11 | ||
targetCompatibility JavaVersion.VERSION_11 | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
externalNativeBuild { | ||
cmake { | ||
path "src/main/cpp/CMakeLists.txt" | ||
} | ||
} | ||
sourceSets { | ||
main.java.srcDirs += '../../../src/main/java' | ||
test.java.srcDirs += '../../../src/main/test' | ||
} | ||
namespace 'com.example.wolfssl' | ||
} | ||
|
||
dependencies { | ||
implementation fileTree(dir: 'libs', include: ['*.jar']) | ||
implementation 'com.android.support:appcompat-v7:28.0.0' | ||
implementation 'com.android.support.constraint:constraint-layout:2.0.4' | ||
testImplementation 'junit:junit:4.13.2' | ||
androidTestImplementation 'com.android.support.test:runner:1.0.2' | ||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |