apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {

    compileSdkVersion 29
    buildToolsVersion "29.0.3"


    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        consumerProguardFiles 'consumer-rules.pro'

        externalNativeBuild {
            cmake {
                version "3.10.2"
                cppFlags "-frtti -fexceptions"
            }
        }
        ndk {
            moduleName "kernel"
            abiFilters "armeabi-v7a", "x86"
            cFlags "-DANDROID_NDK"
        }

        //Gradle 构建并打包某个特定abi体系架构下的.so库
        sourceSets {
            main() {
                jniLibs.srcDirs=['src/main/jniLibs']
            }
        }
    }

    packagingOptions {
        pickFirst 'lib/armeabi-v7a/libsilk.so'
        pickFirst 'lib/arm64/libsilk.so'
        pickFirst 'lib/arm64-v8a/libsilk.so'
        pickFirst 'lib/x86/libsilk.so'
    }

    externalNativeBuild {
        cmake {
//            path "src/main/cpp/CMakeLists.txt"
        }
    }

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.core:core-ktx:1.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

    implementation 'com.google.code.gson:gson:2.8.6'
    implementation("com.squareup.okhttp3:okhttp:4.4.0")
    compileOnly 'de.robv.android.xposed:api:82'
    compileOnly 'de.robv.android.xposed:api:82:sources'
}

this.afterEvaluate {
    this.copy {
        from 'src/main/jniLibs/armeabi-v7a'
        into 'src/main/jniLibs/arm64-v8a'
    }
}

