flutter_background_fetch icon indicating copy to clipboard operation
flutter_background_fetch copied to clipboard

[BUG] AAPT: error: resource android:attr/lStar not found.

Open sonuPrasas010 opened this issue 1 year ago • 7 comments

  • What went wrong: Execution failed for task ':background_fetch:verifyReleaseResources'.

A failure occurred while executing com.android.build.gradle.tasks.VerifyLibraryResourcesTask$Action Android resource linking failed ERROR:/home/sonu/projects/flutter/H-ATTENDANCE/build/background_fetch/intermediates/merged_res/release/values/values.xml:2520: AAPT: error: resource android:attr/lStar not found. This above is full bug report

sonuPrasas010 avatar May 13 '24 10:05 sonuPrasas010

Same here. It stopped working since latest Flutter upgrade. Works in debug mode but not in release.

Z6P0 avatar May 19 '24 07:05 Z6P0

Post both your gradle files.

nobody is specifying what version of the plug-in they’re using.

christocracy avatar May 19 '24 08:05 christocracy

build.gradle:

allprojects {
    repositories {
        google()
        jcenter()
        maven { url "${project(':background_fetch').projectDir}/libs" }
    }
}

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

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

Using latest plugin version and latest Flutter version.

Z6P0 avatar May 19 '24 16:05 Z6P0

First-of-all, the maven repo jcenter() has been deprecated since 2021.

second, you’ve not fully implemented the Android setup instructions linked in the readme (the ext vars).

I suggest you generate a fresh hello-world app and compare the changes in the default build.gradle with those in your own app.

you’ve failed to properly upgrade your app with the latest requirement of the latest flutter SDK. That’s why you have problems.

christocracy avatar May 19 '24 16:05 christocracy

I am getting same issue [BUG] AAPT: error: resource android:attr/lStar not found. This my bulid.gradle file

allprojects { repositories { google() mavenCentral() maven { url "${project(':background_fetch').projectDir}/libs" } } }

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

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

waqaseusopht avatar May 23 '24 10:05 waqaseusopht

See my comment above: https://github.com/transistorsoft/flutter_background_fetch/issues/369#issuecomment-2119292134

you did not fully implement the Setup Instructions (ext vars). Go back and review the Setup Instructions. Yes, they are important.

christocracy avatar May 23 '24 12:05 christocracy

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Jun 23 '24 01:06 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar Jul 07 '24 01:07 github-actions[bot]

I just have added below ext code in android/build.gradle after allprojects{}, and use them in android/app/build.gradle as the presentation of the help doc Android Setup, it has solved the problem on my side.

allprojects {
 ...
} 

ext {
    compileSdkVersion   = 34
    targetSdkVersion    = 34
    appCompatVersion    = "1.7.0"
}

YumanYIN avatar Aug 08 '24 13:08 YumanYIN

I am using Flutter 3.24.0 • channel stable , while building resale apk i am getting ... .gradle\caches\transforms-3\f58020c91a078450a7656e43f041db18\transformed\core-1.13.1\res\values\values.xml:113:5-122:25: AAPT: error: resource android:attr/lStar not found. Can anyone help me in this

skgaurav-web avatar Aug 12 '24 10:08 skgaurav-web

I am using Flutter 3.24.0 • channel stable , while building resale apk i am getting ... .gradle\caches\transforms-3\f58020c91a078450a7656e43f041db18\transformed\core-1.13.1\res\values\values.xml:113:5-122:25: AAPT: error: resource android:attr/lStar not found. Can anyone help me in this

Try to add below ext code in android/build.gradle under allprojects{}, and use them in android/app/build.gradle as the presentation of the help doc Android Setup

allprojects {
 ...
} 

ext {
    compileSdkVersion   = 34
    targetSdkVersion    = 34
    appCompatVersion    = "1.7.0"
}

YumanYIN avatar Aug 12 '24 12:08 YumanYIN

I have tried this but the problem is same, can not build the release apk. I guess it is some issue with the new release and dependencies.

sahilsharma17 avatar Aug 14 '24 06:08 sahilsharma17

I have tried this but the problem is same, can not build the release apk. I guess it is some issue with the new release and dependencies.

I'm also using Flutter 3.24.0, but I can build the release APK. You can try to do the below code in the android/app/build.gradle :

android {
    def buildConfig = rootProject.extensions.getByName("ext")
    
    compileSdk buildConfig.compileSdkVersion 

    defaultConfig {
       ...
       targetSdkVersion buildConfig.targetSdkVersion
       ...
    }
    ...
}

If the problem is still there, you need to post your android/build.gradle and android/app/build.gradle to help you analyse the reason.

YumanYIN avatar Aug 14 '24 08:08 YumanYIN

This problem is related to the compileSdkVersion and targetSdkVersion of the plugins. This problem occurs because the compileSdkVersion and targetSdkVersion of some plugins are outdated. Either go to the source files of the plugin in your project and make the compileSdkVersion and targetSdkVersion versions the same as your project (version 34 compatible), or add the code block below to the build.gradle file in your project directory.

subprojects { afterEvaluate { android { compileSdkVersion 34 } } }

This code is a Gradle configuration script used in Android projects. The subprojects block allows you to configure certain settings for all subprojects (modules) in the project. The android block inside defines Android-related configuration settings, and the compileSdkVersion 34 line allows projects to be compiled with Android API 34.

Aziz-T avatar Aug 14 '24 08:08 Aziz-T

Post both your .gradle files.

christocracy avatar Aug 14 '24 08:08 christocracy

app/build.gradle

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

rootProject.buildDir = "../build"

subprojects { afterEvaluate { android { compileSdkVersion 34 } } }

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

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

Aziz-T avatar Aug 14 '24 10:08 Aziz-T

Post the entire contents of both your gradle files:

  1. Android/build.gradle
  2. Android/app.build.gradle

christocracy avatar Aug 14 '24 12:08 christocracy

app/build.gradle

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

rootProject.buildDir = "../build"

subprojects { afterEvaluate { android { compileSdkVersion 34 } } }

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

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

You have not added maven { url "${project(':background_fetch').projectDir}/libs" } in allprojects , follow this doc: Android Setup

allprojects {
    repositories {
        google()
        mavenCentral()
        // [required] background_fetch
        maven { url "${project(':background_fetch').projectDir}/libs" }
    }
}

YumanYIN avatar Aug 14 '24 13:08 YumanYIN

@Aziz-T i suggest you consult with the required Android Setup Instructions, linked in the readme and carefully follow ALL the instructions.

christocracy avatar Aug 14 '24 13:08 christocracy

I upgraded cupertino_icons to the latest version and it works now hope this helps someone.

marcusee avatar Aug 14 '24 18:08 marcusee

If you are like me and have updated to the new Flutter version, You can consider this temporary solution https://github.com/livekit/client-sdk-flutter/issues/569#issuecomment-2275686786

CodeDeveloper19 avatar Aug 15 '24 00:08 CodeDeveloper19

My plug-ins never hard-code sdk versions, they read them from ext vars in your build.gradle. All plugin authors should do this but most don’t.

we learned to do this years ago in the React Native world.

christocracy avatar Aug 15 '24 00:08 christocracy

nsformed\core-1.13.1\res\values\values.xml:113:5-122:25: AAPT: error: resource android:attr/lStar not found. Can anyone help me in this

bhai tera huaa kya, m b pareshaan hu

abtpltd avatar Aug 15 '24 05:08 abtpltd

I am using Flutter 3.24.0 • channel stable , while building resale apk i am getting ... .gradle\caches\transforms-3\f58020c91a078450a7656e43f041db18\transformed\core-1.13.1\res\values\values.xml:113:5-122:25: AAPT: error: resource android:attr/lStar not found. Can anyone help me in this

rootProject.buildDir = "../build" ******************** ADD GIVEN LINE AND TRY BABY******************** subprojects { afterEvaluate { project -> if (project.plugins.hasPlugin("com.android.application") || project.plugins.hasPlugin("com.android.library")) { project.android { compileSdkVersion 34 buildToolsVersion "34.0.0" } } } } ******************** BUS YHI TAK PASTE KRNA BETAA************* subprojects { project.buildDir = "${rootProject.buildDir}/${project.name}" } subprojects { project.evaluationDependsOn(":app") }

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

abtpltd avatar Aug 15 '24 06:08 abtpltd

This problem is related to the compileSdkVersion and targetSdkVersion of the plugins. This problem occurs because the compileSdkVersion and targetSdkVersion of some plugins are outdated. Either go to the source files of the plugin in your project and make the compileSdkVersion and targetSdkVersion versions the same as your project (version 34 compatible), or add the code block below to the build.gradle file in your project directory.

subprojects { afterEvaluate { android { compileSdkVersion 34 } } }

This code is a Gradle configuration script used in Android projects. The subprojects block allows you to configure certain settings for all subprojects (modules) in the project. The android block inside defines Android-related configuration settings, and the compileSdkVersion 34 line allows projects to be compiled with Android API 34.

ext { compileSdkVersion = 34 targetSdkVersion = 34 appCompatVersion = "1.7.0" }

subprojects { afterEvaluate { android { compileSdkVersion 34 } } }

it working for me for release build in latest flutter 3.24 version.

SatyawanHajar avatar Aug 16 '24 20:08 SatyawanHajar

I am facing the same problem, below is m app level build.gradle; I am using flutter 3.24.1 stable channel plugins { id "com.android.application" id "kotlin-android" id "dev.flutter.flutter-gradle-plugin" }

def localProperties = new Properties() def localPropertiesFile = rootProject.file('local.properties') if (localPropertiesFile.exists()) { localPropertiesFile.withReader('UTF-8') { reader -> localProperties.load(reader) } }

def flutterVersionCode = localProperties.getProperty('flutter.versionCode') if (flutterVersionCode == null) { flutterVersionCode = '1' }

def flutterVersionName = localProperties.getProperty('flutter.versionName') if (flutterVersionName == null) { flutterVersionName = '1.0' }

android { namespace "com.panda.panda_rider" compileSdkVersion 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.panda.panda_rider"
    // You can update the following values to match your application needs.
    // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
    minSdkVersion 34
    targetSdkVersion 34
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
}

buildTypes {
    release {
        // TODO: Add your own signing config for the release build.
        // Signing with the debug keys for now, so `flutter run --release` works.
        signingConfig signingConfigs.debug
    }
}

}

flutter { source '../..' }

dependencies {}

axelasa avatar Aug 28 '24 20:08 axelasa

Same issues +++++++++++++++++++++++++++ % flutter --version Flutter 3.24.1 • channel stable • https://github.com/flutter/flutter.git Framework • revision 5874a72aa4 (10 天前) • 2024-08-20 16:46:00 -0500 Engine • revision c9b9d5780d Tools • Dart 3.5.1 • DevTools 2.37.2

+++++++++++++++++++++++++++ FAILURE: Build completed with 2 failures.

1: Task failed with an exception.

  • What went wrong: Execution failed for task ':flutter_wallpaper_manager:verifyReleaseResources'.

A failure occurred while executing com.android.build.gradle.tasks.VerifyLibraryResourcesTask$Action Android resource linking failed ERROR:/Users/zhouruibin/Documents/renew_spirit/apps/renew/build/flutter_wallpaper_manager/intermediates/merged_res/release/values/values.xml:194: 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. ==============================================================================

2: Task failed with an exception.

  • What went wrong: Execution failed for task ':image_gallery_saver:verifyReleaseResources'.

A failure occurred while executing com.android.build.gradle.tasks.VerifyLibraryResourcesTask$Action Android resource linking failed ERROR:/Users/zhouruibin/Documents/renew_spirit/apps/renew/build/image_gallery_saver/intermediates/merged_res/release/values/values.xml:194: 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 ++++++++++++++++++++++++++++++++

Huoran559 avatar Aug 30 '24 12:08 Huoran559

Search "AAPT: error: resource android:attr/lStar not found.":

https://stackoverflow.com/questions/69033022/message-error-resource-androidattr-lstar-not-found

christocracy avatar Aug 30 '24 13:08 christocracy

background_fetch

100% working solution:

the problem is with background_fetch package that you used in pubspec.yaml. comment or remove this package then make the build. it will must work.

note: the to find the problem: when you get the error check the direction first.ERROR:/home/sonu/projects/flutter/H-ATTENDANCE/build/background_fetch/intermediates/merged_res/release/values/values.xml:2520: AAPT: error

so here: search immediate folder after build folder. here immediate folder is 'background_fetch'. so, the problem is in backgroudn fetch package. there may have file missing when the package is downloaded. this is why the error(resource android:attr/lStar not found) came.

RahajulAminRaju avatar Sep 02 '24 20:09 RahajulAminRaju

@RahajulAminRaju

100% working solution:

No!. This error is typically associated with the Android dependency androidx.appcompat.appcompat

check your appCompatVersion.

https://github.com/transistorsoft/flutter_background_fetch/blob/master/help/INSTALL-ANDROID.md#open_file_folder-androidbuildgradle

people having problems with this likely have multiple plugins importing different versions of this dependency.

Consult https://maven.google.com appcompat.

to see a dependency tree of your app, execute:

$ ./gradlew app:dependencies

christocracy avatar Sep 02 '24 21:09 christocracy