123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- apply plugin: 'com.android.application'
- // NOTE!!! 重要!!! aar需要kotlin支持,不引入会导致小程序打不开.
- apply plugin: 'kotlin-android'
- apply plugin: 'kotlin-android-extensions'
- if (rootProject.ext.miniAppConfig.usePluginSdk && rootProject.ext.miniAppConfig.usePluginSdk.tpush && rootProject.ext.miniAppConfig.usePluginSdk.tpush != '') {
- apply plugin: 'com.tencent.android.tpns'
- }
- 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 "edufound_key"
- keyPassword "edufound321"
- storeFile file("C:/Users/candy/Desktop/efunbox/edufound.keystore")
- storePassword "edufound123"
- v1SigningEnabled true
- v2SigningEnabled true
- }
- release {
- keyAlias "edufound_key"
- keyPassword "edufound321"
- storeFile file("C:/Users/candy/Desktop/efunbox/edufound.keystore")
- storePassword "edufound123"
- v1SigningEnabled true
- v2SigningEnabled true
- }
- }
- defaultConfig {
- multiDexEnabled true
- versionName miniAppConfig.version
- versionCode miniAppConfig.versionCode
- minSdkVersion rootProject.ext.minSdkVersion
- targetSdkVersion rootProject.ext.targetSdkVersion
- if (rootProject.ext.miniAppConfig.map && rootProject.ext.miniAppConfig.map.qmapAPIKey) {
- manifestPlaceholders["qmapAPIKey"] = rootProject.ext.miniAppConfig.map.qmapAPIKey
- }
- }
- buildTypes {
- debug {
- debuggable true
- signingConfig signingConfigs.debug
- minifyEnabled false
- shrinkResources false
- }
- release {
- debuggable false
- signingConfig signingConfigs.release
- minifyEnabled 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
- }
- repositories {
- flatDir {
- dirs 'libs'
- }
- }
- sourceSets {
- main {
- jniLibs.srcDirs = ["libs"]
- }
- }
- }
- // def wxa_sdk_version = rootProject.ext.miniAppConfig.sdkVersion
- def wxa_sdk_version = rootProject.ext.saaaSDKVersionDepend
- 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 {
- implementation project(path: ':plugin')
- def miniAppConfig = rootProject.ext.miniAppConfig
- implementation("com.tencent.luggage:wxa-standalone-open-runtime-SaaA-plugin-sdk:${wxa_sdk_version}")
- //以下是测试通过微信打包出来的aar能否正常使用
- // implementation(name: 'wxf1a06dafa3350688-1.0.47', ext: 'aar')
- // implementation('io.github.jeremyliao:live-event-bus-x:1.8.0')
- // implementation('io.github.FailedToRead:intermodal-release:1.0.1')
- // implementation('io.github.FailedToRead:oaid_sdk_1.0.25:1.0.1')
- }
|