Skip to content

Commit

Permalink
升级为cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
BruceWind committed Aug 11, 2017
1 parent 840879e commit 8241f7f
Show file tree
Hide file tree
Showing 15 changed files with 91 additions and 58 deletions.
34 changes: 34 additions & 0 deletions aesjni/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
cmake_minimum_required(VERSION 3.4.1)
add_library( # Sets the name of the library.
JNIEncrypt

# Sets the library as a shared library.
SHARED

# Provides a relative path to your source file(s).
src/main/cpp/JNIEncrypt.c
src/main/cpp/checksignature.h
src/main/cpp/checksignature.c
src/main/cpp/aes.h
src/main/cpp/base64.h
src/main/cpp/aes.c
src/main/cpp/base64.c
)

# 搜索指定的预构建库并将路径存储为变量。 因为默认情况下,CMake在搜索路径中包含系统库,
# 所以您只需要指定公共NDK库的名称你想添加。 在完成构建之前,CMake验证库存在。

find_library( # Sets the name of the path variable.
log-lib

# Specifies the name of the NDK library that
# you want CMake to locate.
log )

# 指定CMake应链接到目标库的库。 您可以链接多个库,例如在此构建脚本中定义的库,预构建的第三方库或系统库。

target_link_libraries( # Specifies the target library.
JNIEncrypt

# included in the NDK.
${log-lib} )
55 changes: 27 additions & 28 deletions aesjni/build.gradle
Original file line number Diff line number Diff line change
@@ -1,40 +1,39 @@
apply plugin: 'com.android.model.library'

model {
android {
compileSdkVersion 25
buildToolsVersion "24.0.1"

defaultConfig {
minSdkVersion.apiLevel 15
targetSdkVersion.apiLevel 25
versionCode 1
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
apply plugin: 'com.android.library'

android {
compileSdkVersion 25
buildToolsVersion "25.0.3"

defaultConfig {
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
cppFlags "-frtti -fexceptions"
}
}
}



ndk {
moduleName = "JNIEncrypt"
toolchain = 'clang'
CFlags.add('-std=c99')
// 添加依赖库
ldLibs.addAll(['android', 'OpenSLES', 'log'])
// 生成不同abi体系的so库
abiFilters.addAll(['armeabi', 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'])
buildTypes {
release {
minifyEnabled false
proguardFiles.add(file("proguard-rules.pro"))
}
}

buildTypes {
release {
minifyEnabled false
proguardFiles.add(file("proguard-rules.pro"))
}
externalNativeBuild {
cmake {
path "CMakeLists.txt"
}
}
}


dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
54 changes: 27 additions & 27 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion 25
buildToolsVersion "24.0.1"
defaultConfig {
applicationId "com.androidyuan.aesjniencrypt"
minSdkVersion.apiLevel 15
targetSdkVersion.apiLevel 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles.add(file("proguard-rules.pro"))
signingConfig = $("android.signingConfigs.test")
}
debug {
signingConfig = $("android.signingConfigs.test")
}
}

apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.androidyuan.aesjniencrypt"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

android.signingConfigs {
create("test") {
storeFile "../keystore/androidyuan.keystore" //请看目录
signingConfigs {
release {
storeFile file("../keystore/androidyuan.keystore") //请看目录
storePassword "weizongwei"
keyAlias "client1"
keyPassword "weizongwei"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles.add(file("proguard-rules.pro"))
signingConfig signingConfigs.release
}
debug {
signingConfig signingConfigs.release
}
}


}


dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle-experimental:0.8.2'
classpath 'com.android.tools.build:gradle:2.3.1'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Dec 28 10:00:20 PST 2015
#Fri Aug 11 15:40:50 CST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip

0 comments on commit 8241f7f

Please sign in to comment.