1

I can compile and run in debug mode, no problem.

But when I want to compile to release or profile mode I get:

Execution failed for task ':cached_video_player:verifyReleaseResources'.

The reported issue is: AAPT: error: resource android:attr/lStar not found.

Doing an build app bundle works though which I can't get it:

stephanedeluca@Angelantonio2019-2:~/development/shokaze/shokaze/functions$ flutter build appbundle
Changing current working directory to: /Users/stephanedeluca/development/shokaze/shokaze

Font asset "CupertinoIcons.ttf" was tree-shaken, reducing it from 283452 to 912 bytes (99.7% reduction). Tree-shaking can be disabled by providing the --no-tree-shake-icons flag when building your app.
Font asset "MaterialIcons-Regular.otf" was tree-shaken, reducing it from 1645184 to 16824 bytes (99.0% reduction). Tree-shaking can be disabled by providing the --no-tree-shake-icons flag when building your app.
Running Gradle task 'bundleRelease'...                            180,1s
✓ Built build/app/outputs/bundle/release/app-release.aab (68.3MB).

Anyone knows how to fix this?

Following are my attempts so far.

I've upgraded cached_video_player to 2.0.4 from 2.0.3 before but get the same issue.

cached_video_player: ^2.0.4 #^2.0.3

I also upgraded (android/build.gradle) my `kotlin_version to 1.9 (I was 1.8.22 before):

buildscript {
    ext.kotlin_version = '1.9.0' //'1.8.22'//'1.6.10'
    repositories {

Fnally, I also tried adding this line as suggested in the Resource linking fails on lStar SO answers:

    implementation "androidx.core:core-ktx:1.6.0"

But it did not fix the issue.

Here is the whole gradle trace is as follows:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':cached_video_player:verifyReleaseResources'.
> A failure occurred while executing com.android.build.gradle.tasks.VerifyLibraryResourcesTask$Action
   > Android resource linking failed
     ERROR:/Users/stephanedeluca/.gradle/caches/transforms-3/fb7be7b58c0779ade2219e6b1355257d/transformed/core-1.7.0/res/values/values.xml:105:5-114:25: AAPT: error: resource android:attr/lStar 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 34s
Exception: Gradle task assembleRelease failed with exit code 1
#0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
#1      AndroidGradleBuilder.buildGradleApp (package:flutter_tools/src/android/gradle.dart:456:9)
<asynchronous suspension>
#2      AndroidGradleBuilder.buildApk (package:flutter_tools/src/android/gradle.dart:208:5)
<asynchronous suspension>
#3      AndroidDevice.startApp (package:flutter_tools/src/android/android_device.dart:578:7)
<asynchronous suspension>
#4      FlutterDevice.runCold (package:flutter_tools/src/resident_runner.dart:524:33)
<asynchronous suspension>
#5      ColdRunner.run (package:flutter_tools/src/run_cold.dart:57:28)
<asynchronous suspension>
#6      AppDomain.launch.<anonymous closure> (package:flutter_tools/src/commands/daemon.dart:648:9)
<asynchronous suspension>
#7      AppDomain.launch (package:flutter_tools/src/commands/daemon.dart:646:5)
<asynchronous suspension>
#8      RunCommand.runCommand (package:flutter_tools/src/commands/run.dart:638:15)
<asynchronous suspension>
#9      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1336:27)
<asynchronous suspension>
#10     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#11     CommandRunner.runCommand
command_runner.dart:212
<asynchronous suspension>
#12     FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:296:9)
<asynchronous suspension>
#13     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#14     FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:244:5)
<asynchronous suspension>
#15     run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:91:9)
<asynchronous suspension>
#16     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#17     main (package:flutter_tools/executable.dart:91:3)
<asynchronous suspension>

And my android/app/build.gradle is as follows:

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'
// START: FlutterFire Configuration
apply plugin: 'com.google.gms.google-services'
// END: FlutterFire Configuration
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 33
    //flutter.compileSdkVersion
    ndkVersion flutter.ndkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

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

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.shokaze.shokaze"
        // You can update the following values to match your application needs.
        // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
        minSdkVersion 24
        //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 "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

    // Sdl on Sunday July 23th 2023 see https://stackoverflow.com/questions/69021225/resource-linking-fails-on-lstar/69029908#69029908
    //implementation "androidx.core:core-ktx:1.6.0"

    def billing_version = "5.1.0" // for today, it's the latest
    implementation "com.android.billingclient:billing:$billing_version"
}
Stéphane de Luca
  • 12,745
  • 9
  • 57
  • 95

1 Answers1

1

Seems like a gradle version issue from the package itself, try adding the below for the dependency in your pubspec.yaml:

 cached_video_player:
    git:
      url: https://github.com/vikram25897/flutter_cached_video_player
      ref: feature/gradle_version_bump
Yash Garg
  • 477
  • 5
  • 11
  • Wow, awesome, pb fixed! Could you tell me why the debug version was OK and why the `flutter build app bundle`was successful a well? – Stéphane de Luca Jul 23 '23 at 21:46
  • 1
    Release APK builds have R8 which tries to shrink resources to decrease app size, the configuration in the package caused some issue with it and hence it was missing up on release. – Yash Garg Jul 24 '23 at 02:51