1

I'm trying to build APK of my flutter application but upon running flutter build apk --split-per-abi I'm getting below error. It looks like there is something wrong with the camera package and I don't know what sms:verifyReleaseResources is referring to. I have tried different verisons of camera package but in vain.

Did any one else encountered this issue before? I have followed this guide to build an 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.

Directory looks like this

enter image description here

And below is my key.properties

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

android/app/build.gradle file

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 file

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 directory

enter image description here

Faizan Kamal
  • 1,732
  • 3
  • 27
  • 56
  • You should not store your key.jks file under your project. It should be in a local folder. storeFile parameter should look like this: storeFile=D:\CIIT GUIDE\Keys\storeifie_new_admin_panel\key.jks – Akif Nov 16 '20 at 09:20
  • Can you share your android/app/build.gradle file? – Akif Nov 16 '20 at 09:23
  • @Akif I've updated the question and added android/app/build.gradle file – Faizan Kamal Nov 17 '20 at 07:23
  • Can you also share your android/build.gradle file? – Akif Nov 17 '20 at 07:40
  • @Akif Updated the question – Faizan Kamal Nov 17 '20 at 07:46
  • Storing `key.jks` locally and giving it's path in `storeFile` gives following error `Execution failed for task ':app:validateSigningRelease'. > Keystore file 'D:\CIIT GUIDE\Flutter\Apps\storeifie_new_admin_panel\android\app\D:CIIT GUIDEKeysstoreifie_new_admin_panelkey.jks' not found for signing config 'release'` – Faizan Kamal Nov 17 '20 at 07:47
  • key.jks is not found. – Akif Nov 17 '20 at 07:52
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/224652/discussion-between-faizan-kamal-and-akif). – Faizan Kamal Nov 17 '20 at 07:57

1 Answers1

0

I was able to solve this problem by simply removing below packages from pubspec.yaml

otp: ^2.2.3

flutter_otp: ^0.3.2

Faizan Kamal
  • 1,732
  • 3
  • 27
  • 56