构建 flutter 应用程序的 APK 时任务“:sms:verifyReleaseResources”执行失败

问题描述 投票:0回答:2

我正在尝试构建我的 flutter 应用程序的 APK,但在运行时

flutter build apk --split-per-abi
我收到以下错误。 看起来
camera
包有问题,我不知道
sms:verifyReleaseResources
指的是什么。我尝试过不同版本的
camera
包但没有成功。

之前有其他人遇到过这个问题吗? 我已经按照这个指南构建了一个apk https://flutter.dev/docs/deployment/android

 D:\CIIT GUIDE\Flutter\Apps\storeifie_new_admin_panel>flutter build apk --split-per-abi
    Parameter format not correct -
    Removed unused resources: Binary resource data reduced from 719KB to 693KB: Removed 3%
    Removed unused resources: Binary resource data reduced from 719KB to 693KB: Removed 3%
    Removed unused resources: Binary resource data reduced from 719KB to 693KB: Removed 3%
    Removed unused resources: Binary resource data reduced from 719KB to 693KB: Removed 3%
    Removed unused resources: Binary resource data reduced from 719KB to 693KB: Removed 3%
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':sms:verifyReleaseResources'.
    > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
       > Android resource linking failed
         C:\Users\faiza\.gradle\caches\transforms-2\files-2.1\44b1706abe044cd42dcac5be863451ed\core-1.1.0\res\values\values.xml:142:5-173:25: AAPT: error: resource android:attr/fontVariationSettings not found.
    
         C:\Users\faiza\.gradle\caches\transforms-2\files-2.1\44b1706abe044cd42dcac5be863451ed\core-1.1.0\res\values\values.xml:142:5-173:25: AAPT: error: resource android:attr/ttcIndex not found.
    
    
    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
    
    * Get more help at https://help.gradle.org
    
    BUILD FAILED in 1m 8s
    Running Gradle task 'assembleRelease'...
    Running Gradle task 'assembleRelease'... Done                      69.4s
    The built failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetfier to solve
    the incompatibility.
    Building plugin camera...
    Running Gradle task 'assembleAarRelease'...
    Running Gradle task 'assembleAarRelease'... Done                    5.3s
    
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    A problem occurred configuring root project 'camera'.
    > SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
    
    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
    
    * Get more help at https://help.gradle.org
    
    BUILD FAILED in 4s
    
    
    The plugin camera could not be built due to the issue above.

目录看起来像这样

enter image description here

下面是

my key.properties

storePassword=xxxxxx
keyPassword=xxxxxx
keyAlias=key
storeFile=key.jks

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 plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android'
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 29

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.appName"
        minSdkVersion 21
        targetSdkVersion 29
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        multiDexEnabled true
    }

   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 "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation platform('com.google.firebase:firebase-bom:26.0.0')
    implementation 'com.google.firebase:firebase-analytics'
    implementation 'androidx.multidex:multidex:2.0.1'
}

android/build.gradle
文件

buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
        google()  // Google's Maven repository
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.4'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

build
目录

enter image description here

flutter dart apk release flutter-release
2个回答
0
投票

我只需从

pubspec.yaml

中删除以下软件包即可解决此问题

otp: ^2.2.3

flutter_otp: ^0.3.2


0
投票

更新Flutter版本时出现此错误

解决方案

将下面的代码块添加到项目目录中的 android/build.gradle 文件中。

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

rootProject.buildDir = "../build"
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
    //>>>>>>>>>>>>>>>>>>> Add this  >>>>>>>>>>>>
    afterEvaluate {
        android {
            compileSdkVersion 34
        }
    }
    //>>>>>>>>>>>>> End  >>>>>>>>>>>>>
}
subprojects {
    project.evaluationDependsOn(":app")
}

tasks.register("clean", Delete) {
    delete rootProject.buildDir
}

该代码是Android项目中使用的Gradle配置脚本。子项目块允许您为项目中的所有子项目(模块)配置某些设置。 afterEvaluate 块包含将在初始配置完成后运行的代码,确保在进行任何更改之前完全读取和评估所有设置。

android 块定义了 Android 相关的配置设置,compileSdkVersion 34 行确保项目使用 Android API 34 进行编译。这对于利用 Android 上最新的 API 功能非常重要,因为较新的 API 通常提供更好的性能、安全性和新功能。特点。

实施这些更改后,您应该在整个项目中进行全面的测试,以确保一切按预期运行。此外,请注意可能影响项目中其他依赖项的潜在副作用。

© www.soinside.com 2019 - 2024. All rights reserved.