mixpanel / mixpanel-flutter

Official Flutter Tracking Library for Mixpanel Analytics
https://mixpanel.com
Apache License 2.0
66 stars 75 forks source link

Error whilst building apk #154

Closed bibaswan-bhawal closed 1 day ago

bibaswan-bhawal commented 4 weeks ago

When trying to build an apk using the flutter build apk command I am getting this error, building an appbundle works fine however.

flutter build apk

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':mixpanel_flutter:verifyReleaseResources'.
> A failure occurred while executing com.android.build.gradle.tasks.VerifyLibraryResourcesTask$Action
   > Android resource linking failed
     ERROR: ${project_root}/build/mixpanel_flutter/intermediates/merged_res/release/mergeReleaseResources/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.
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, 3.24.0-0.2.pre, on macOS 14.5 23F79 darwin-arm64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.1)
[✓] VS Code (version 1.92.1)
[✓] Connected device (3 available)
[✓] Network resources
cerberodev commented 4 weeks ago

The error you are encountering (resource android:attr/lStar not found) occurs because the lStar attribute was introduced in a newer version of Android (API 31), but your project or one of its dependencies, like mixpanel_flutter, might be using an older version of compileSdkVersion that does not support this attribute.

To resolve this issue, you need to ensure that your project is using a compileSdkVersion that is compatible with the lStar attribute.

1.  Update compileSdkVersion and buildToolsVersion:
subprojects {
    afterEvaluate { project ->
        if (project.plugins.hasPlugin("com.android.application") ||
                project.plugins.hasPlugin("com.android.library")) {
            project.android {
                compileSdkVersion 34
                buildToolsVersion "34.0.0"
            }
        }
    }
}

This ensures that all subprojects in your application use these versions of the SDK and build tools.

2.  Clean and Rebuild the Project:

After making these changes, perform a clean and rebuild of the project to apply the new configuration:

flutter clean
flutter build apk
zihejia commented 1 day ago

Fixed in v2.3.2, thanks for bringing it up!