import java.text.SimpleDateFormat def localProperties = new Properties() def localPropertiesFile = rootProject.file('local.properties') if (localPropertiesFile.exists()) { localPropertiesFile.withReader('UTF-8') { reader -> localProperties.load(reader) } } def flutterRoot = localProperties.getProperty('flutter.sdk') if (flutterRoot == null) { throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") } def flutterVersionCode = localProperties.getProperty('flutter.versionCode') if (flutterVersionCode == null) { flutterVersionCode = '1' } def flutterVersionName = localProperties.getProperty('flutter.versionName') if (flutterVersionName == null) { flutterVersionName = '1.0' } apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { compileSdkVersion 30 // ndkVersion "21.3.6528147" sourceSets { main.java.srcDirs += 'src/main/kotlin' } applicationVariants.all { variant -> variant.outputs.all { def versionName = defaultConfig.versionName def date = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) if (variant.buildType.name == 'release') { outputFileName = "ctjt_flutter_${variant.buildType.name}_${versionName}_${date}.apk" } else if (variant.buildType.name == 'debug') { outputFileName = "ctjt_flutter_${versionName}_${date}.apk" } } } signingConfigs { debug { storeFile file('android_key.keystore') storePassword 'abcd1234' keyAlias 'ctjt_flutter' keyPassword 'abcd1234' } release { storeFile file('android_key.keystore') storePassword 'abcd1234' keyAlias 'ctjt_flutter' keyPassword 'abcd1234' } } lintOptions { disable 'InvalidPackage' //如打包出现Failed to transform libs.jar to match attributes //checkReleaseBuilds false } defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.example.ctjt_flutter" minSdkVersion 19 targetSdkVersion 30 versionCode flutterVersionCode.toInteger() versionName flutterVersionName multiDexEnabled true // Bugly相关配置 // ndk { // //设置支持的SO库架构 // abiFilters 'armeabi-v7a'//, 'arm64-v8a', 'x86', 'x86_64' // } } buildTypes { debug { signingConfig signingConfigs.debug } release { // Signing with the debug keys for now, so `flutter run --release` works. //signingConfig signingConfigs.debug signingConfig signingConfigs.release minifyEnabled false // 资源压缩设置 shrinkResources false // 删除无用资源 useProguard true // 代码压缩设置 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' // 读取代码压缩配置文件 } } } flutter { source '../..' } dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" // 引入support支持库的multidex库 implementation 'com.android.support:multidex:1.0.3' }