Dev*_*MMO 8 android gradle android-studio flutter
我已经像作者的文档一样编辑了 Flutter 源代码,但在构建 APK 文件时总是出现此错误:
\nFAILURE: Build failed with an exception.\n\n* Where:\nBuild file \'F:\\MyProject\\android\\app\\build.gradle\' line: 34\n\n* What went wrong:\nA problem occurred evaluating project \':app\'.\n> No signature of method: build_7lhgwn6g10f1dc3sk72t2tmig.android() is applicable for argument types: (build_7lhgwn6g10f1dc3sk72t2tmig$_run_closure2) values: [build_7lhgwn6g10f1dc3sk72t2tmig$_run_closure2@9578636]\n\n* Try:\n> Run with --stacktrace option to get the stack trace.\n> Run with --info or --debug option to get more log output.\n> Run with --scan to get full insights.\n\n* Get more help at https://help.gradle.org\n\nBUILD FAILED in 1s\nRunning Gradle task \'assembleRelease\'... 2.787ms\nGradle task assembleRelease failed with exit code 1\nProcess finished with exit code 1\nRun Code Online (Sandbox Code Playgroud)\n\\android\\app\\build.gradle\' 中的第 34 行以android开头。
\n这是 app\\build.gradle 文件:
\ndef localProperties = new Properties()\ndef localPropertiesFile = rootProject.file(\'local.properties\')\nif (localPropertiesFile.exists()) {\nlocalPropertiesFile.withReader(\'UTF-8\') { reader ->\nlocalProperties.load(reader)\n}\n}\n\ndef flutterRoot = localProperties.getProperty(\'flutter.sdk\')\nif (flutterRoot == null) {\nthrow new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")\n}\n\ndef flutterVersionCode = localProperties.getProperty(\'flutter.versionCode\')\nif (flutterVersionCode == null) {\nflutterVersionCode = \'1\'\n}\n\ndef flutterVersionName = localProperties.getProperty(\'flutter.versionName\')\nif (flutterVersionName == null) {\nflutterVersionName = \'1.0\'\n}\n\ndef keystoreProperties = new Properties()\ndef keystorePropertiesFile = rootProject.file(\'key.properties\')\nif (keystorePropertiesFile.exists()) {\nkeystoreProperties.load(new FileInputStream(keystorePropertiesFile))\n}\n\napply plugin: \'com.android.application\'\napply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"\napply plugin: \'kotlin-android\'\n\nandroid {\n\ncompileSdkVersion 33\n\nlintOptions {\ndisable \'InvalidPackage\'\n}\n\ndefaultConfig {\n// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).\napplicationId "my-package-name"\nminSdkVersion 21\ntargetSdkVersion 33\nversionCode flutterVersionCode.toInteger()\nversionName flutterVersionName\nmultiDexEnabled true\ntestInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"\n}\n\nsigningConfigs {\nrelease {\nkeyAlias keystoreProperties[\'keyAlias\']\nkeyPassword keystoreProperties[\'keyPassword\']\nstoreFile file(keystoreProperties[\'storeFile\'])\nstorePassword keystoreProperties[\'storePassword\']\n}\n}\n\nbuildTypes {\nrelease {\n\nsigningConfig signingConfigs.release\n\nminifyEnabled true\nuseProguard true\n\nproguardFiles getDefaultProguardFile(\'proguard-android.txt\'), \'proguard-rules.pro\'\n}\n}\n}\n\nflutter {\nsource \'../..\'\n}\n\ndependencies {\ntestImplementation \'junit:junit:4.12\'\nandroidTestImplementation \'com.android.support.test:runner:1.0.2\'\nandroidTestImplementation \'com.android.support.test.espresso:espresso-core:3.0.2\'\nimplementation \'com.google.firebase:firebase-core:17.3.0\'\nimplementation \'com.google.firebase:firebase-messaging:20.2.4\'\nimplementation \'com.android.support:multidex:1.0.3\'\nimplementation platform(\'com.google.firebase:firebase-bom:30.2.0\')\nimplementation(\'androidx.work:work-runtime\') {\nversion {\nstrictly \'2.6.0\'\n}\n}\n}\n\napply plugin: \'com.google.gms.google-services\'\nRun Code Online (Sandbox Code Playgroud)\nFlutter doctor => 未发现问题!
\n颤振版本
\nFlutter 3.1.0-9.0.pre \xe2\x80\xa2 通道开发 \xe2\x80\xa2 https://github.com/flutter/flutter.git \nFramework \xe2\x80\xa2 修订版 f28e570c8c(3 周前) \xe2\x80\xa2 2022-06-14 13:39:33 -0500\n引擎 \xe2\x80\xa2 修订版 74ee6b5afd\n工具 \xe2\x80\xa2 Dart 2.18.0(内部版本 2.18.0-165.1.beta) \xe2\x80\xa2 开发工具 2.14.0
\ngradle——版本
\n构建时间:2022-03-31 15:25:29 UTC\n修订:540473b8118064efcc264694cbcaa4b677f61041
\nKotlin:1.5.31\nGroovy:3.0.9\nAnt:2021 年 7 月 10 日编译的 Apache Ant(TM) 版本 1.10.11\nJVM:18.0.1.1 (Oracle Corporation 18.0.1.1+2-6)\n操作系统:Windows 10 10.0 amd64
\n你能帮助我吗?非常感谢!
\n请备份您的项目并使用此 Gradle
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 FileNotFoundException("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: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
compileSdkVersion 31
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "package id here"
multiDexEnabled true
minSdkVersion 21
targetSdkVersion 31
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies{
}
flutter {
source '../..'
}
Run Code Online (Sandbox Code Playgroud)
添加您的包裹 ID。然后进行扑动清洁。删除 pub spec.lock 文件。运行 flutter pub get 并重试。
| 归档时间: |
|
| 查看次数: |
14929 次 |
| 最近记录: |