Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
sonuPrasas010 opened this issue May 13, 2024 · 37 comments
Closed

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

sonuPrasas010 opened this issue May 13, 2024 · 37 comments
Labels

Comments

@sonuPrasas010
Copy link

  • 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

@Z6P0
Copy link

Z6P0 commented May 19, 2024

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

@christocracy
Copy link
Member

Post both your gradle files.

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

@Z6P0
Copy link

Z6P0 commented May 19, 2024

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.

@christocracy
Copy link
Member

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.

@waqaseusopht
Copy link

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
}

@christocracy
Copy link
Member

christocracy commented May 23, 2024

See my comment above: #369 (comment)

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

Copy link

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

@github-actions github-actions bot added the stale label Jun 23, 2024
Copy link

github-actions bot commented Jul 7, 2024

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

@github-actions github-actions bot closed this as completed Jul 7, 2024
@YumanYIN
Copy link

YumanYIN commented Aug 8, 2024

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"
}

@skgaurav-web
Copy link

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

@YumanYIN
Copy link

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"
}

@sahilsharma17
Copy link

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.

@YumanYIN
Copy link

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.

@Aziz-T
Copy link

Aziz-T commented Aug 14, 2024

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.

@christocracy
Copy link
Member

Post both your .gradle files.

@Aziz-T
Copy link

Aziz-T commented Aug 14, 2024

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
}
`

@christocracy
Copy link
Member

christocracy commented Aug 14, 2024

Post the entire contents of both your gradle files:

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

@YumanYIN
Copy link

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" }
    }
}

@christocracy
Copy link
Member

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

@marcusee
Copy link

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

@CodeDeveloper19
Copy link

If you are like me and have updated to the new Flutter version, You can consider this temporary solution
livekit/client-sdk-flutter#569 (comment)

@christocracy
Copy link
Member

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.

@abtpltd
Copy link

abtpltd commented Aug 15, 2024

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
Copy link

abtpltd commented Aug 15, 2024

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
}

@SatyawanHajar
Copy link

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.

@axelasa
Copy link

axelasa commented Aug 28, 2024

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 {}

@Huoran559
Copy link

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.
==============================================================================

@christocracy
Copy link
Member

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

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

@RahajulAminRaju
Copy link

RahajulAminRaju commented Sep 2, 2024

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.

@christocracy
Copy link
Member

christocracy commented Sep 2, 2024

@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
Copy link
Member

christocracy commented Sep 2, 2024

This plug-in is happy to import any version of appcompat that you wish. As the Setup Instructions remark “or higher / as desired

{
  appCompatVersion  = "1.4.2" // or higher / as desired
}

@diegocontini
Copy link

I was facing this issue, and finded a fix to my case.
Sharing just in case help someone.

In my case, the issue was the PDF package and PRINTING package.

Upgraded to this versions and fixed the issue:
pdf: ^3.11.1
printing: ^5.13.2

If you use firebase too, consider reading this PR: firebase/flutterfire#13200

@r0755466
Copy link

r0755466 commented Sep 5, 2024

Would really help me if someone can check my code or give any advise.
In advance thank you !

My current versions are:
Flutter 3.24.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 5874a72aa4 (2 weeks ago) • 2024-08-20 16:46:00 -0500
Engine • revision c9b9d5780d
Tools • Dart 3.5.1 • DevTools 2.37.2

Channel -> Stable

The problem only occurs in release mode, not debug.
I've tried updating the app/build.gradle & android/build.gradle, but the error persists.

What went wrong:

Execution failed for task :gdpr_dialog:verifyReleaseResources.

A failure occurred while executing com.android.build.gradle.tasks.VerifyLibraryResourcesTask$Action

Android resource linking failed:

ERROR:
C:\Users\nameuser\Desktop\appname\newflutter\build\gdpr_dialog\intermediates\merged_res\release\values\values.xml:196: AAPT: error: resource android:attr/lStar not found.

I upgraded my dependencies in pubspec.yaml using:

  1. flutter pub outdated
  2. flutter pub upgrade --major-versions

Tried resources:

  1. StackOverflow
  2. Background Fetch GitHub

app/build.gradle

plugins {
    id "com.android.application"
    id "kotlin-android"
    id "dev.flutter.flutter-gradle-plugin"
}

android {
     // Added by the comments 
    def buildConfig = rootProject.extensions.getByName("ext") 
    compileSdkVersion rootProject.ext.compileSdkVersion // Added checking the INSTALL-ANDROID.md
    namespace = "com.example.newflutter"
    compileSdk = 34
    ndkVersion = flutter.ndkVersion

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_1_8
    }
    

    defaultConfig {
        applicationId = "com.example.newflutter"
        minSdk = 21
        targetSdk = 34
        versionCode = flutter.versionCode
        versionName = flutter.versionName
        // Added checking the INSTALL-ANDROID.md
        targetSdkVersion rootProject.ext.targetSdkVersion
    }

    buildTypes {
        release {
            signingConfig = signingConfigs.debug
        }
    }
}

dependencies {
    implementation 'androidx.core:core-ktx:1.12.0' 
    implementation 'com.google.android.material:material:1.9.0' 
    implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
    implementation 'androidx.multidex:multidex:2.0.1'
    implementation 'androidx.work:work-runtime:2.7.0'
    implementation project(path: ':gdpr_dialog')
}

flutter {
    source = "../.."
}




android/build.gradle

buildscript {
    ext.kotlin_version = '1.8.0' 

    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.4.2'  // or 8.0.2 for Java 11+
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.15'  
    }
}

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

   
    configurations.all {
        resolutionStrategy {
            force "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
            force "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        }
    }

}

   ext {
    
    compileSdkVersion   = 34
    targetSdkVersion    = 34
    // Had an error with the compiler changed from 1.7 to 1.6.1 works now 
    appCompatVersion    = "1.6.1"
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}

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

@christocracy
Copy link
Member

Show me the result of the following command (it’s a lot of output)

$ cd android 
$ ./gradlew app:dependencies

@christocracy
Copy link
Member

Try version 1.3.6 (just released). I've removed the android dependency androidx.appcompat:appcompat from the plugin's build.gradle (it turns out it's not required).

@a-v-ebrahimi
Copy link

a-v-ebrahimi commented Sep 15, 2024

Add this to android/build.gradle

subprojects {
        afterEvaluate { project ->
            if (project.hasProperty('android')) {
                project.android { compileSdkVersion 34 }
            }
        }
}

@christocracy
Copy link
Member

christocracy commented Sep 17, 2024

In version 1.3.7, I have removed the appcompat dependency.

Add this to android/build.gradle

subprojects {
        afterEvaluate { project ->
            if (project.hasProperty('android')) {
                project.android { compileSdkVersion 34 }
            }
        }
}

This plugin does not require this if you provide the required ext vars (including ext.compileSdkVersion) in your root build.gradle, as documented in the Android Setup Instructions

Of course, other plugins may have hard-coded compileSdkVersion, requiring that override, but this plugin does not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests