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

Posted

技术标签:

【中文标题】构建flutter应用程序的APK时任务\':sms:verifyReleaseResources\'执行失败【英文标题】:Execution failed for task ':sms:verifyReleaseResources' while building APK of flutter application构建flutter应用程序的APK时任务':sms:verifyReleaseResources'执行失败 【发布时间】:2020-11-16 07:16:29 【问题描述】:

我正在尝试构建我的颤振应用程序的 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.

目录是这样的

下面是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目录

【问题讨论】:

您不应将 key.jks 文件存储在您的项目下。它应该在本地文件夹中。 storeFile 参数应如下所示:storeFile=D:\CIIT GUIDE\Keys\storeifie_new_admin_panel\key.jks 你能分享你的 android/app/build.gradle 文件吗? @Akif 我已经更新了问题并添加了 android/app/build.gradle 文件 你也可以分享你的 android/build.gradle 文件吗? @Akif 更新了问题 【参考方案1】:

我可以通过简单地从 pubspec.yaml 中删除以下包来解决这个问题

otp: ^2.2.3

flutter_otp: ^0.3.2

【讨论】:

以上是关于构建flutter应用程序的APK时任务':sms:verifyReleaseResources'执行失败的主要内容,如果未能解决你的问题,请参考以下文章

Flutter构建apk错误:任务':app:compileFlutterBuildRelease'执行失败

从 Flutter 项目构建 APK 时出错

Flutter 构建 apk 失败

Flutter如何构建APK

如何在 Flutter 中构建 apk 创建旧版本应用程序

Flutter 应用程序在构建 release-APK 时工作,但在通过 Google Play 商店提供时不工作