Skip to content

Android resource linking failed: resource android:attr/lStar not found

The "error: resource android:attr/lStar not found" is a common Android build error that typically occurs when there's a mismatch between your project's compile SDK version and the dependencies you're using. This error prevents your app from building successfully and can be frustrating to resolve.

Root cause

The lStar attribute was introduced in Android SDK version 31 (Android 12). When your project or its dependencies reference this attribute but are compiled against an older SDK version, the build system cannot find the resource, resulting in the linking failure.

Primary solutions

Update compileSdkVersion and targetSdkVersion

The most straightforward solution is to update your project's SDK versions:

gradle
// In android/app/build.gradle
android {
    compileSdkVersion 34
    targetSdkVersion 34
    
    defaultConfig {
        minSdkVersion 21
        // ... other configurations
    }
    // ... other configurations
}

WARNING

Before updating targetSdkVersion, ensure your app is compatible with the new Android version requirements, particularly permissions and behavior changes.

Force SDK versions for all subprojects (Flutter specific)

For Flutter projects, some plugins might have outdated SDK configurations. Add this to your android/build.gradle file:

gradle
// In android/build.gradle
subprojects {
    afterEvaluate { project ->
        if (project.plugins.hasPlugin("com.android.application") ||
                project.plugins.hasPlugin("com.android.library")) {
            project.android {
                compileSdkVersion 34
                buildToolsVersion "34.0.0"
            }
        }
    }
}

Kotlin DSL version

If you're using build.gradle.kts, use this approach:

kotlin
subprojects {
    afterEvaluate {
        if (plugins.hasPlugin("com.android.application") || plugins.hasPlugin("com.android.library")) {
            extensions.findByType<com.android.build.gradle.BaseExtension>()?.apply {
                compileSdkVersion(34)
                buildToolsVersion("34.0.0")
            }
        }
    }
    project.evaluationDependsOn(":app")
}

Advanced solution with version checking

For better control and debugging, use this approach that only updates plugins with outdated SDK versions:

gradle
subprojects {
    afterEvaluate { project ->
        if (project.extensions.findByName("android") != null) {
            Integer pluginCompileSdk = project.android.compileSdk
            if (pluginCompileSdk != null && pluginCompileSdk < 31) {
                project.logger.error(
                        "Warning: Overriding compileSdk version in Flutter plugin: "
                                + project.name
                                + " from "
                                + pluginCompileSdk
                                + " to 31 (to work around https://issuetracker.google.com/issues/199180389)."
                                + "\nIf there is not a new version of " + project.name + ", consider filing an issue against "
                                + project.name
                                + " to increase their compileSdk to the latest (otherwise try updating to the latest version)."
                )
                project.android {
                    compileSdk 31
                }
            }
        }
    }
    
    project.buildDir = "${rootProject.buildDir}/${project.name}"
    project.evaluationDependsOn(":app")
}

This approach:

  • Only updates plugins that need changes
  • Provides clear warnings about which plugins are affected
  • Minimizes the SDK version bump to resolve the issue

Alternative approaches

Force specific dependency versions

If updating SDK versions isn't feasible, you can force specific dependency versions:

gradle
// In android/app/build.gradle
configurations.all {
    resolutionStrategy {
        force 'androidx.core:core:1.6.0'
        force 'androidx.core:core-ktx:1.6.0'
        force 'androidx.appcompat:appcompat:1.3.0'
    }
}

Update problematic dependencies

Some dependencies might be incompatible or outdated:

  1. Identify the problematic package causing the error (check build logs)
  2. Update to the latest version of the package
  3. If no update is available, consider switching to an alternative package
  4. For severely outdated packages, manually edit the cached version (not recommended)

React Native specific solutions

For React Native projects, ensure you're using a compatible version:

gradle
// In android/build.gradle
buildscript {
    ext {
        buildToolsVersion = "31.0.0"
        minSdkVersion = 21
        compileSdkVersion = 31
        targetSdkVersion = 31
        androidXCore = "1.6.0"
    }
}

Also ensure your AndroidManifest.xml includes the required exported attribute:

xml
<activity
    android:name=".MainActivity"
    android:exported="true">
    <!-- ... other attributes -->
</activity>

Prevention and best practices

  1. Regularly update dependencies: Keep your project and its dependencies updated to avoid compatibility issues
  2. Use consistent SDK versions: Ensure all modules and plugins use the same SDK versions
  3. Check plugin compatibility: Before adding new plugins, verify they support your target SDK version
  4. Monitor Android releases: Stay informed about new Android versions and their requirements

When to use which solution

ScenarioRecommended Solution
Starting a new projectUse latest SDK versions (34+)
Existing project with minimal dependenciesUpdate SDK versions to 31+
Project with many pluginsUse the subprojects approach
Cannot update SDK versionsForce specific dependency versions
Single problematic pluginUpdate or replace the specific plugin

INFO

The lStar attribute is related to material design icons and was introduced in Android 12. Keeping your project updated with current Android standards is the best long-term solution.

Troubleshooting

If you continue to experience issues:

  1. Clean your project: ./gradlew clean
  2. Invalidate caches and restart Android Studio
  3. Check for any remaining outdated dependencies
  4. Ensure all plugins are compatible with your SDK version

By following these solutions, you should be able to resolve the "resource android:attr/lStar not found" error and successfully build your Android application.