123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 |
- apply plugin: 'com.android.application'
- // NOTE!!! 重要!!! aar需要kotlin支持,不引入会导致小程序打不开.
- apply plugin: 'kotlin-android'
- apply plugin: 'kotlin-android-extensions'
- android {
- useLibrary 'org.apache.http.legacy'
- compileSdkVersion rootProject.ext.compileSdkVersion
- buildToolsVersion rootProject.ext.buildToolsVersion
- def miniAppConfig = rootProject.ext.miniAppConfig
- defaultConfig {
- buildConfigField "String", "SDK_KEY", "\"$miniAppConfig.sdkKey\""
- buildConfigField "String", "SDK_KEY_SECRET", "\"$miniAppConfig.sdkKeySecret\""
- buildConfigField "Boolean", "SPLASHSCREEN", "$miniAppConfig.splashscreen"
- buildConfigField "String", "ENABLE_VCONSOLE", "\"$miniAppConfig.enableVConsole\""
- buildConfigField "Boolean", "PRIVACY_POPUP", "$miniAppConfig.privacyPopup"
- buildConfigField "Boolean", "APP_MENU_ENABLE", "$miniAppConfig.appMenuEnable"
- buildConfigField "String", "SCHEME", "\"$miniAppConfig.scheme\""
- manifestPlaceholders = [
- MINIAPP_SCHEME : miniAppConfig.scheme,
- ]
- }
- signingConfigs {
- debug {
- keyAlias 'androiddebugkey'
- keyPassword 'android'
- storeFile rootProject.file('compile/debug.keystore')
- storePassword 'android'
- }
- // 使用该 test.jks 生成的 应用签名 md5 为 d8d9a7134de382c19ff2a42a287ec627
- release {
- keyAlias 'test'
- keyPassword '12345678'
- storeFile file('./sign/test2.jks')
- storePassword '12345678'
- }
- }
- defaultConfig {
- multiDexEnabled true
- versionName miniAppConfig.version
- versionCode miniAppConfig.versionCode
- minSdkVersion rootProject.ext.minSdkVersion
- targetSdkVersion rootProject.ext.targetSdkVersion
- }
- buildTypes {
- debug {
- debuggable true
- signingConfig signingConfigs.debug
- minifyEnabled false
- shrinkResources false
- }
- release {
- debuggable false
- signingConfig signingConfigs.release
- minifyEnabled true
- shrinkResources true
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
- }
- }
- packagingOptions {
- exclude 'META-INF/DEPENDENCIES'
- exclude 'META-INF/NOTICE'
- exclude 'META-INF/LICENSE'
- exclude 'META-INF/LICENSE.txt'
- exclude 'META-INF/NOTICE.txt'
- }
- flavorDimensions 'abi'
- productFlavors {
- arm {
- dimension 'abi'
- ndk {
- abiFilters "arm64-v8a", "armeabi-v7a"
- }
- }
- arm32 {
- dimension 'abi'
- ndk {
- abiFilter "armeabi-v7a"
- }
- }
- arm64 {
- dimension 'abi'
- ndk {
- abiFilter "arm64-v8a"
- }
- }
- }
- lintOptions {
- checkReleaseBuilds false
- abortOnError false
- }
- compileOptions {
- sourceCompatibility = 1.8
- targetCompatibility = 1.8
- }
- }
- // def wxa_sdk_version = rootProject.ext.miniAppConfig.sdkVersion
- def wxa_sdk_version = rootProject.ext.saaaSDKVersionDepend
- def miniAppPluginConfig = rootProject.ext.miniAppPluginConfig
- def libsDir = file("./libs")
- if (!file("$libsDir/com/tencent/luggage/wxa-standalone-open-runtime-SaaA-plugin-sdk/${wxa_sdk_version}").exists()) {
- libsDir.mkdir()
- apply plugin: 'de.undercouch.download'
-
- def zipFileName = "wxa-standalone-open-runtime-SaaA-sdk-all-${wxa_sdk_version}.zip"
- download.run {
- src "https://dldir1.qq.com/WechatWebDev/donut/android/pluginsdk/${zipFileName}"
- dest libsDir
- }
- def zipFilePath = "$libsDir/$zipFileName"
- copy {
- def subDir = 'localAar'
- from {
- zipTree(zipFilePath).matching { include "$subDir/**" }
- }
- into libsDir
- eachFile { fcp ->
- fcp.path = fcp.path.replaceFirst("^$subDir", '')
- }
- includeEmptyDirs false
- }
- file(zipFilePath).delete()
- }
- task updateResource {
- doFirst {
- println "[I] start connect with devtools"
- def url = miniAppPluginConfig.devtoolsResourceUrl
- def shouldInterrupt = false
- try {
- println "[I] url: $url"
- def response = new URL(url).getText()
- println("[I] response: $response")
- if (response.contains("success")) {
- // 请求成功
- println("[I] update Android resource done")
- } else {
- shouldInterrupt = true
- }
- } catch (Exception e) {
- println("[W] connecting with devtools fail.." + e.getMessage())
- }
- if (shouldInterrupt) {
- throw new GradleException("update Android resource fail")
- }
- }
- }
- preBuild.dependsOn updateResource
- dependencies {
- if (miniAppPluginConfig.debugWithAar) {
- def sdkName = miniAppPluginConfig.pluginId
- def sdkVersion = miniAppPluginConfig.pluginVersion
- implementation("com.donut.plugin:${sdkName}:${sdkVersion}")
- println("[I] Use Aar")
- } else {
- implementation project(path: ':plugin')
- println("[I] Use Source Code")
- }
- def miniAppConfig = rootProject.ext.miniAppConfig
- implementation("com.tencent.luggage:wxa-standalone-open-runtime-SaaA-plugin-sdk:${wxa_sdk_version}")
-
- }
|