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 from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { compileSdkVersion 29 //解决Android或者Flutter 打包 Execution failed for task ':app:compileFlutterBuildRelease'.的问题 // lintOptions { // checkReleaseBuilds false // abortOnError false // disable 'InvalidPackage' // } defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.flutter.hyzp_ybqx01_cuiping" minSdkVersion 21 targetSdkVersion 29 versionCode flutterVersionCode.toInteger() versionName flutterVersionName } buildTypes { release { // TODO: Add your own signing config for the release build. // Signing with the debug keys for now, so `flutter run --release` works. signingConfig signingConfigs.debug //关闭代码混淆,解决 Flutter 打包后真机运行闪退。 //flutter build apk --release --target-platform android-arm64 //真机运行正常 minifyEnabled false //删除无用代码,只用该行编译报错 //Removing unused resources requires unused code shrinking to be turned on. See http://d.android.com/r/tools/shrink-resources.html for more information. shrinkResources false //删除无用资源,只用该行编译通过,但真机运行闪退 } } //解决Flutter应用打包release版本apk后,打不开闪退。经测试无效 // packagingOptions { // pickFirst 'lib/x86_64/libapp.so' // pickFirst 'lib/armeabi-v7a/libapp.so' // pickFirst 'lib/arm64-v8a/libapp.so' // } } flutter { source '../..' }