Skip to content

Cannot build apk from new project after upgrade #153668

Closed

Description

@jefflongo

Steps to reproduce

  1. Upgraded Android Studio to 2024.1.1, upgraded SDK/tools
  2. Upgraded Flutter to 3.24.0
  3. Created a new Flutter project with flutter create -t app test
  4. Attempt to build apk: flutter build apk

Actual results

Fails to apply the flutter gradle plugin (see logs). I'm able to get it to build by manually upgrading the Gradle and Kotlin version, then changing gradle distribution URL. I'm not sure why I have to do all of these things in the first place though for an empty project.

Logs

Logs
$ flutter build apk

FAILURE: Build failed with an exception.

* Where:
Build file '<redacted>/test/android/app/build.gradle' line: 5

* What went wrong:
An exception occurred applying plugin request [id: 'dev.flutter.flutter-gradle-plugin']
> Failed to apply plugin 'dev.flutter.flutter-gradle-plugin'.
   > Could not get unknown property 'usesUnsupportedDependencyVersions' for project ':app' of type org.gradle.api.Project.

* 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 539ms
Running Gradle task 'assembleRelease'...                           978ms
Gradle task assembleRelease failed with exit code 1

Flutter Doctor output

Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.24.0, on Ubuntu 22.04.4 LTS 6.8.0-40-generic, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
[✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✓] Linux toolchain - develop for Linux desktop
[✓] Android Studio (version 2024.1)
[✓] VS Code (version 1.92.2)
[✓] Connected device (1 available)
[✓] Network resources

! Doctor found issues in 1 category.

Activity

  1. mqhamdam commented on Aug 19, 2024

    @mqhamdam

    Can not reproduce your issue.
    did u try to delete android folder and run

    flutter clean
    flutter pub get
    flutter create .
    
  2. AbdeMohlbi commented on Aug 19, 2024

    @AbdeMohlbi
    Member

    Steps to reproduce

    1. Upgraded Android Studio to 2024.1.1, upgraded SDK/tools
    2. Upgraded Flutter to 3.24.0
    3. Created a new Flutter project with flutter create -t app test
    4. Attempt to build apk: flutter build apk

    Actual results

    Fails to apply the flutter gradle plugin (see logs). I'm able to get it to build by manually upgrading the Gradle and Kotlin version, then changing gradle distribution URL. I'm not sure why I have to do all of these things in the first place though for an empty project.

    Logs

    Logs
    $ flutter build apk
    
    FAILURE: Build failed with an exception.
    
    * Where:
    Build file '<redacted>/test/android/app/build.gradle' line: 5
    
    * What went wrong:
    An exception occurred applying plugin request [id: 'dev.flutter.flutter-gradle-plugin']
    > Failed to apply plugin 'dev.flutter.flutter-gradle-plugin'.
       > Could not get unknown property 'usesUnsupportedDependencyVersions' for project ':app' of type org.gradle.api.Project.
    
    * 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 539ms
    Running Gradle task 'assembleRelease'...                           978ms
    Gradle task assembleRelease failed with exit code 1
    

    Flutter Doctor output

    Doctor output
    Doctor summary (to see all details, run flutter doctor -v):
    [✓] Flutter (Channel stable, 3.24.0, on Ubuntu 22.04.4 LTS 6.8.0-40-generic, locale en_US.UTF-8)
    [✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    [✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
        ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
    [✓] Linux toolchain - develop for Linux desktop
    [✓] Android Studio (version 2024.1)
    [✓] VS Code (version 1.92.2)
    [✓] Connected device (1 available)
    [✓] Network resources
    
    ! Doctor found issues in 1 category.
    

    It would be easier if u provided ur gradle files

  3. danagbemava-nc commented on Aug 19, 2024

    @danagbemava-nc
    Member

    Hi @jefflongo, please provide the full output of flutter build apk -v. The output may be huge so kindly put it into a .log/.txt file and attach it here. Please also provide your android/build.gradle & android/app/build.gradle files.

    If you can also provide your gradle-wrapper.properties, that would help

    Thank you

  4. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Aug 19, 2024
  5. jefflongo commented on Aug 19, 2024

    @jefflongo
    Author

    Can not reproduce your issue. did u try to delete android folder and run

    flutter clean
    flutter pub get
    flutter create .
    

    Tried this, did not solve the problem.

    It would be easier if u provided ur gradle files

    Hi @jefflongo, please provide the full output of flutter build apk -v. The output may be huge so kindly put it into a .log/.txt file and attach it here. Please also provide your android/build.gradle & android/app/build.gradle files.

    If you can also provide your gradle-wrapper.properties, that would help

    Thank you

    I can do this, only reason I didn't is because I have not modified anything after creating the project. My expectation is that I should be able to build with whatever Flutter generates by default.

    Here is some more information to debug with:
    Log of flutter build apk: log.txt

    ~/Downloads/test $ flutter --version
    Flutter 3.24.0 • channel stable • https://github.com/flutter/flutter.git
    Framework • revision 80c2e84975 (3 weeks ago) • 2024-07-30 23:06:49 +0700
    Engine • revision b8800d88be
    Tools • Dart 3.5.0 • DevTools 2.37.2
    
    ~/Downloads/test $ ./android/gradlew --version
    
    ------------------------------------------------------------
    Gradle 7.6.3
    ------------------------------------------------------------
    
    Build time:   2023-10-04 15:59:47 UTC
    Revision:     1694251d59e0d4752d547e1fd5b5020b798a7e71
    
    Kotlin:       1.7.10
    Groovy:       3.0.13
    Ant:          Apache Ant(TM) version 1.10.11 compiled on July 10 2021
    JVM:          17.0.11 (JetBrains s.r.o. 17.0.11+0-17.0.11b1207.24-11852314)
    OS:           Linux 6.8.0-40-generic amd64
    

    build.gradle:

    allprojects {
        repositories {
            google()
            mavenCentral()
        }
    }
    
    rootProject.buildDir = "../build"
    subprojects {
        project.buildDir = "${rootProject.buildDir}/${project.name}"
    }
    subprojects {
        project.evaluationDependsOn(":app")
    }
    
    tasks.register("clean", Delete) {
        delete rootProject.buildDir
    }
    

    app/build.gradle

    plugins {
        id "com.android.application"
        id "kotlin-android"
        // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
        id "dev.flutter.flutter-gradle-plugin"
    }
    
    android {
        namespace = "com.example.test"
        compileSdk = flutter.compileSdkVersion
        ndkVersion = flutter.ndkVersion
    
        compileOptions {
            sourceCompatibility = JavaVersion.VERSION_1_8
            targetCompatibility = JavaVersion.VERSION_1_8
        }
    
        kotlinOptions {
            jvmTarget = JavaVersion.VERSION_1_8
        }
    
        defaultConfig {
            // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
            applicationId = "com.example.test"
            // You can update the following values to match your application needs.
            // For more information, see: https://flutter.dev/to/review-gradle-config.
            minSdk = flutter.minSdkVersion
            targetSdk = flutter.targetSdkVersion
            versionCode = flutter.versionCode
            versionName = flutter.versionName
        }
    
        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 = "../.."
    }
    

    gradle-wrapper.properties:

    distributionBase=GRADLE_USER_HOME
    distributionPath=wrapper/dists
    zipStoreBase=GRADLE_USER_HOME
    zipStorePath=wrapper/dists
    distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-all.zip
    
  6. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Aug 19, 2024
  7. xakoy commented on Aug 21, 2024

    @xakoy

    same question.

  8. xakoy commented on Aug 21, 2024

    @xakoy

    I try do that remove gradle cache. rebuild, tip kotlin gradle plugin version:

    [!] Your project requires a newer version of the Kotlin Gradle plugin.
    Find the latest version on https://kotlinlang.org/docs/releases.html#release-details, then update the
    version number of the plugin with id "org.jetbrains.kotlin.android" in the plugins block of
    /Users/work/HLW/Mobile/dangan_demo/flutter_application_1/android/settings.gradle.

    Alternatively (if your project was created before Flutter 3.19), update
    /Users/work/HLW/Mobile/dangan_demo/flutter_application_1/android/build.gradle
    ext.kotlin_version = ''

    update version laster 2.0.10 in settings.gradle

    id "org.jetbrains.kotlin.android" version "2.0.10" apply false

    rebuild. It' successed. but has warning:

    e: /Users/luolong/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/2.0.10/9120f9dd349d5c67fa6710c4049c3128ef6b51db/kotlin-stdlib-2.0.10.jar!/META-INF/kotlin-stdlib-jdk7.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.6.0.

  9. jefflongo commented on Aug 21, 2024

    @jefflongo
    Author

    @xakoy You can get it to compile without warnings by upgrading both the Kotlin version and Gradle version in app/build.gradle, and changing the distribution URL to point to the new Gradle version in gradle-wrapper.properties. But on the topic of this issue, I don't see why we should have to make such modifications for a new generated project.

  10. danagbemava-nc commented on Aug 21, 2024

    @danagbemava-nc
    Member

    Hi @jefflongo, I just tried building an apk after creating a new app with the latest stable version and it works as expected.

    Upgraded Android Studio to 2024.1.1, upgraded SDK/tools

    What version did you upgrade to? I'm currently using android studio 2024.1.1 Patch 2 with Android build tools 35

  11. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Aug 21, 2024
  12. ckumaradev commented on Aug 21, 2024

    @ckumaradev

    Hi,

    I have the same issue with when I am doing release build, let me brief my findings

    Flutter version: 3.24.0

    In this version when I tried to do a release build through VS code or android studio terminal by running “flutter run — release ” , then I am getting this error at the verifyLibResorce task and it says also 44 plugins not complile with 34 sdk.

    My project min sdk is 24 and max is 34.

    But when I do debug build or when I open android folder in android studio and then try to generate signed bundle then it builds successfully 😳😳

    But if I clean the build folder and then try to rebuild the project then again show this error

    But if I change build varient to release and then try to re build then it is working

    seems to my problem with this flutter run — release terminal command only

    To check this then I have downloaded the Flutter 3.22.0 sdk version and did same steps and it worked without any problems even I can build using flutter run —release command also

    So I think this is the issue with this sdk version

    Thanks

  13. jefflongo commented on Aug 21, 2024

    @jefflongo
    Author

    Hi @jefflongo, I just tried building an apk after creating a new app with the latest stable version and it works as expected.

    Upgraded Android Studio to 2024.1.1, upgraded SDK/tools

    What version did you upgrade to? I'm currently using android studio 2024.1.1 Patch 2 with Android build tools 35

    I'm using 2024.1.1 Patch 2. Build tools version is unspecified in the build.gradle (default should be defined by specification of targetSdk) but if I manually set it to 35.0.0 it changes nothing.

  14. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Aug 21, 2024
  15. 28 remaining items

  16. JiyadAhammad commented on Aug 31, 2024

    @JiyadAhammad

    Any solution for this

    facing same issue
    can't take release build in 3.24.1

    [ ] FAILURE: Build failed with an exception.
    [ ] * What went wrong:
    [ ] Execution failed for task ':contacts_service:verifyReleaseResources'.
    [ ] > A failure occurred while executing com.android.build.gradle.tasks.VerifyLibraryResourcesTask$Action
    [ ] > Android resource linking failed
    [ ]
    ERROR:/Users/oonzoo1/Desktop/OONZOO/ginni/build/contacts_service/intermediates/merged_res/release/values/values.x
    ml:194: AAPT: error: resource android:attr/lStar not found.

  17. khjde1207 commented on Aug 31, 2024

    @khjde1207

    Any solution for this

    facing same issue can't take release build in 3.24.1

    [ ] FAILURE: Build failed with an exception. [ ] * What went wrong: [ ] Execution failed for task ':contacts_service:verifyReleaseResources'. [ ] > A failure occurred while executing com.android.build.gradle.tasks.VerifyLibraryResourcesTask$Action [ ] > Android resource linking failed [ ] ERROR:/Users/oonzoo1/Desktop/OONZOO/ginni/build/contacts_service/intermediates/merged_res/release/values/values.x ml:194: AAPT: error: resource android:attr/lStar not found.

    android/build.gradle

    // add 
    subprojects {  
        afterEvaluate { project ->
            if (project.plugins.hasPlugin("com.android.application") ||
                    project.plugins.hasPlugin("com.android.library")) {
                project.android {
                    compileSdkVersion 34
                    buildToolsVersion "34.0.0"
                }
            }
        }
    }
    
    
    subprojects {
        project.buildDir = "${rootProject.buildDir}/${project.name}"
    }
    subprojects {
        project.evaluationDependsOn(':app')
    }
    
    
  18. Richard-Van-Intania commented on Sep 1, 2024

    @Richard-Van-Intania

    this work for me
    just init firebase again and do nothing in ios android folder

  19. jefflongo commented on Sep 4, 2024

    @jefflongo
    Author

    Closing this issue now that Flutter 3.24.2 has landed and resolves this issue.

  20. added
    r: fixedIssue is closed as already fixed in a newer version
    on Sep 5, 2024
  21. vishnuagbly commented on Sep 11, 2024

    @vishnuagbly

    I am still having the above issue in 3.24.2.
    I resolved it by adding:

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

    in android/build.gradle

  22. gmackall commented on Sep 11, 2024

    @gmackall
    Member

    I am still having the above issue in 3.24.2. I resolved it by adding:

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

    in android/build.gradle

    Can you provide logs? Are you sure you are referring to this issue and not #153281 (comment)?

  23. vishnuagbly commented on Sep 12, 2024

    @vishnuagbly
  24. ckumaradev commented on Sep 12, 2024

    @ckumaradev

    Hi,

    We are still facing this issue in 3.24.2 stable release also and I have tried by adding subprojects config mentioned above but still issue is there

    Even I have added android.suppressUnsupportedCompileSdk=33,34 but issue still same

    we need immediate solution for this because this is the only thing preventing us to update Flutter to this version

    Thanks

  25. gmackall commented on Sep 12, 2024

    @gmackall
    Member

    Hi,

    We are still facing this issue in 3.24.2 stable release also and I have tried by adding subprojects config mentioned above but still issue is there

    Even I have added android.suppressUnsupportedCompileSdk=33,34 but issue still same

    we need immediate solution for this because this is the only thing preventing us to update Flutter to this version

    Thanks

    Are you specifically encountering the error:

     > Could not get unknown property 'usesUnsupportedDependencyVersions' for project ':app' of type org.gradle.api.Project.
    

    on 3.24.2? If so, can you provide additional logs, including the output of flutter doctor -v?

    A minimal reproduction would also be appreciated, if possible.

  26. zzmps0901 commented on Sep 26, 2024

    @zzmps0901

    Any solution for this
    facing same issue can't take release build in 3.24.1
    [ ] FAILURE: Build failed with an exception. [ ] * What went wrong: [ ] Execution failed for task ':contacts_service:verifyReleaseResources'. [ ] > A failure occurred while executing com.android.build.gradle.tasks.VerifyLibraryResourcesTask$Action [ ] > Android resource linking failed [ ] ERROR:/Users/oonzoo1/Desktop/OONZOO/ginni/build/contacts_service/intermediates/merged_res/release/values/values.x ml:194: AAPT: error: resource android:attr/lStar not found.

    android/build.gradle

    // add 
    subprojects {  
        afterEvaluate { project ->
            if (project.plugins.hasPlugin("com.android.application") ||
                    project.plugins.hasPlugin("com.android.library")) {
                project.android {
                    compileSdkVersion 34
                    buildToolsVersion "34.0.0"
                }
            }
        }
    }
    
    
    subprojects {
        project.buildDir = "${rootProject.buildDir}/${project.name}"
    }
    subprojects {
        project.evaluationDependsOn(':app')
    }
    

    Same issue here. I recently updated to Flutter SDK 3.24.3 and got this error run flutter build apk:

    ERROR: /build/amap_flutter_location/intermediates/merged_res/release/values/values.xml:194: AAPT: error: resource android:attr/lStar not found

    It seems like the amap_flutter_location plugin hasn't been updated for a long time. However, I found this solution that worked for me. Thanks.

  27. github-actions commented on Oct 10, 2024

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  28. locked as resolved and limited conversation to collaborators on Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

a: buildBuilding flutter applications with the toolc: crashStack traces logged to the consoleplatform-androidAndroid applications specificallyr: fixedIssue is closed as already fixed in a newer versiont: gradle"flutter build" and "flutter run" on Androidteam-androidOwned by Android platform teamtoolAffects the "flutter" command-line tool. See also t: labels.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions