当前位置: 首页 > 知识库问答 >
问题:

颤振当我试着运行这个“flutter build appbundle”时,我得到了这个错误

白和泽
2023-03-14

我正在尝试使用flutter构建一个应用程序。当我尝试运行此推荐“flutter build appbundle”时,我收到以下错误:

失败:构建失败,但有例外。

>

  • 其中:构建文件'F:\azabaza_app\myapp\android\app\build.gradle'行:28

    错误:评估项目“app”时出现问题。

    无法为FlutterExtension类型的扩展“flutter”获取未知属性“compileSdkVersion”。

    >

    获取更多帮助https://help.gradle.org

    在828ms内运行Gradle任务“bundleRelease”时生成失败
    1536ms梯度任务bundleRelease失败,退出代码为1

    我的android/app/build.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 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"
    def keystoreProperties = new Properties()
    def keystorePropertiesFile = rootProject.file('key.properties')
    if (keystorePropertiesFile.exists()) {
        keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
    }
    android {
        compileSdkVersion flutter.compileSdkVersion
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }
        defaultConfig {
            applicationId "io.flutter.examples.flutter_view"
            minSdkVersion flutter.minSdkVersion
            targetSdkVersion flutter.targetSdkVersion
            versionCode flutterVersionCode.toInteger()
            versionName flutterVersionName
        }
       signingConfigs {
           release {
               keyAlias keystoreProperties['keyAlias']
               keyPassword keystoreProperties['keyPassword']
               storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
               storePassword keystoreProperties['storePassword']
           }
       }
       buildTypes {
           release {
               signingConfig signingConfigs.release
           }
       }
    
    }
    flutter {
        source '../..'
    }
    dependencies {
        implementation 'androidx.appcompat:appcompat:1.1.0'
        implementation 'com.google.android.material:material:1.0.0'
    }
    
  • 共有2个答案

    伯鸿达
    2023-03-14

    您当前正在将android编译版本设置为不存在的变量。编译SDK版本。编译版本通常是硬编码的数字,例如:compileSdkVersion 30

    甘西岭
    2023-03-14

    从你的android/app/build。gradle文件中,您需要更改构建中的3个变量。将文件渐变为整数:compileSdkVersion,现在设置为flutter。compileSdkVersion,minSdkVersion现在设置为flutter。MinSDK版本和目标SDK版本现在设置为颤振。targetSdkVersion。它们需要被最新的稳定版本所取代。

    android {
    
        compileSdkVersion 31
    
        compileOptions {
           ...
        }
    
       ... ...
    
        defaultConfig {
            ...
            minSdkVersion 28
            targetSdkVersion 30
           ...
        }
    }
    

    编译SdkVersion

    进行更改后,运行flutter clean以删除上一个版本。然后再次重建flutter build appbundle-v或flutter build appbundle以反映您的新更改。

     类似资料:
    • AMQ6235E:缺少目录“H:”。 我无法找到解决这个问题的方法,它正在连接队列,它显示了这个错误。我不能公开我运行的代码,但我可以解释节点脚本将做什么,首先尝试连接队列管理器,然后尝试通道名,主机名,端口名,这里问题是当它需要建立连接而不是得到上面的错误

    • 启动sandbox并运行json api后,意味着我会出现以下错误:

    • 下面是我的代码: java.lang.runtimeException:无法启动活动ComponentInfo{com.example.auditoriamedica/com.example.auditoriamedica.views.principal}:java.lang.IllegalStateException:findViewById(r.id.nav_view)在Android.app

    • 当我试图运行这个骨架代码时,我一直收到这个错误。我试图在Eclipse中使用OpenGL。我不知道是什么导致了这个问题。我如何解决这个问题?我也已经将jar文件添加到用户库中。 代码: 这是我一直在犯的错误。 错误:错误1 错误2 Plhd-19/>(JComponent. java: 4839)在java.桌面/java. awt.容器. addNotify(容器. java: 2804)在ja

    • java.lang.IllegalStateException:未能加载ApplicationContext 原因:org . spring framework . beans . factory . unsatisfieddependencyexception:创建在URL[jar:file:/C:/Users/MDI vya/. m2/repository/io/spring fox/spri

    • 错误:任务“app:transformClassesWithDexForDebug”的执行失败 com.android.build.api.transform。TransformException:com.android.ide.common.process。ProcessException:org.gradle.process.internal。ExecException:处理C:\Progra