Skip to content

[flutter module] Flutter_tools/gradle/aar_init_script.gradle' line: 15 - AAR build fail #57795

Closed

Description

@perqin

Steps to Reproduce

  1. Create an add-to-app module: flutter create -t module --org com.example path_provider_issue
  2. Add dependency path_provider: ^1.5.1 to pubspec.yaml and run flutter pub get
  3. Run flutter build aar

If opening pubspec.lock I found that:

  path_provider_macos:
    dependency: transitive
    description:
      name: path_provider_macos
      url: "https://pub.flutter-io.cn"
    source: hosted
    version: "0.0.4+3"

and if I force path_provider_macos to 0.0.4+2 in pubspec.yaml, the build passes.

path_provider_macos 0.0.4+3 removes the android module, but Flutter tries to evaluate android/build.gradle inside it.

Logs

➜  path_provider_issue $ ls -a
.                               .dart_tool                      .gitignore                      .metadata                       lib                             pubspec.lock
..                              .flutter-plugins                .idea                           .packages                       path_provider_issue.iml         pubspec.yaml
.android                        .flutter-plugins-dependencies   .ios                            README.md                       path_provider_issue_android.iml test
➜  path_provider_issue $ flutter pub get
Running "flutter pub get" in path_provider_issue...                 0.3s
➜  path_provider_issue $ flutter build aar
Running Gradle task 'assembleAarDebug'...
Running Gradle task 'assembleAarDebug'... Done                      3.3s


FAILURE: Build failed with an exception.

* Where:
Initialization script '/Users/perqinxie/App/flutter-latest-stable/packages/flutter_tools/gradle/aar_init_script.gradle' line: 15

* What went wrong:
Android property 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

BUILD FAILED in 2s


Gradle task assembleAarDebug failed with exit code 0.

Running flutter doctor -v:

➜  path_provider_issue $ flutter doctor -v
[✓] Flutter (Channel stable, v1.17.1, on Mac OS X 10.15.4 19E287, locale ja-CN)
    • Flutter version 1.17.1 at /Users/perqinxie/App/flutter-latest-stable
    • Framework revision f7a6a7906b (9 days ago), 2020-05-12 18:39:00 -0700
    • Engine revision 6bc433c6b6
    • Dart version 2.8.2


[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    • Android SDK at /Users/perqinxie/Library/Android/sdk
    • Platform android-29, build-tools 29.0.3
    • ANDROID_HOME = /Users/perqinxie/Library/Android/sdk
    • ANDROID_SDK_ROOT = /Users/perqinxie/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.5)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.5, Build version 11E608c
    • CocoaPods version 1.8.4

[✓] Android Studio
    • Android Studio at /Applications/Android Studio 4.1 Preview.app/Contents
    • Flutter plugin version 45.1.2
    • Dart plugin version 193.6911.31
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] Android Studio (version 3.6)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 45.1.1
    • Dart plugin version 192.8052
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)

[!] IntelliJ IDEA Ultimate Edition (version 2020.1.1)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
    • For information about installing plugins, see
      https://flutter.dev/intellij-setup/#installing-the-plugins

[✓] VS Code (version 1.45.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.10.2

[✓] Proxy Configuration
    • HTTP_PROXY is set
    • NO_PROXY is *.oa.com,*.tencent.com,127.0.0.1,localhost
    • NO_PROXY contains 127.0.0.1
    • NO_PROXY contains localhost

[✓] Connected device (1 available)
    • BLN AL10 • JJRDU16A26004316 • android-arm64 • Android 8.0.0 (API 26)

! Doctor found issues in 1 category.

Activity

  1. TahaTesser commented on May 22, 2020

    @TahaTesser
    Contributor

    Edit:
    Misunderstood, path_provider_macos isn't separate than path_provider

  2. added
    in triagePresently being triaged by the triage team
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on May 22, 2020
  3. perqin commented on May 22, 2020

    @perqin
    ContributorAuthor

    Thanks for the solution.

    By the way, what if I am working on a project targeting both macOS and Android? I believe this is a bug of Flutter build tool, because the generated Gradle script loads plugin from deprecated .flutter-plugins file.

  4. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on May 22, 2020
  5. tiagoantunes commented on May 22, 2020

    @tiagoantunes

    same issue,
    #57810

  6. removed
    in triagePresently being triaged by the triage team
    on May 22, 2020
  7. changed the title [-]path_provider_macos 0.0.4+3 breaks Android build[/-] [+][flutter module] Flutter_tools/gradle/aar_init_script.gradle' line: 15 - AAR build fail[/+] on May 22, 2020
  8. added
    a: existing-appsIntegration with existing apps via the add-to-app flow
    c: crashStack traces logged to the console
    t: gradle"flutter build" and "flutter run" on Android
    toolAffects the "flutter" command-line tool. See also t: labels.
    c: regressionIt was better in the past than it is now
    on May 22, 2020
  9. creativecreatorormaybenot commented on May 25, 2020

    @creativecreatorormaybenot
    Contributor

    @TahaTesser This is not fixed by just using path_provider because it depends on path_provider_macos. Basically, most flutter/plugins currently break Flutter module builds on Android.

    #46304 only fixed APK and AAB builds but not AAR builds.

    Here is a list of the offending commits by @cg021:

  10. cyanglaz commented on May 25, 2020

    @cyanglaz
  11. TahaTesser commented on May 26, 2020

    @TahaTesser
    Contributor

    @creativecreatorormaybenot
    Thanks for explanation, i have found the mentioned issue later than this

  12. blasten commented on May 26, 2020

    @blasten

    If you are on the latest stable, this issue can be solved by just running flutter clean and then flutter build aar.

    Flutter clean will delete the .android directory, and then flutter build aar will regenerate a new .android directory that includes an updated version of include_flutter.groovy.

  13. creativecreatorormaybenot commented on May 27, 2020

    @creativecreatorormaybenot
    Contributor

    @blasten That did not seem to work for us. Our CD showed this issue and it was using both the latest stable version and a clean project afaic.

  14. perqin commented on May 27, 2020

    @perqin
    ContributorAuthor

    @blasten I'm using Flutter 1.17.1 and flutter clean doesn't work.

  15. wanjm commented on May 27, 2020

    @wanjm

    I didn't depend on path_provider, and come across such error, and flutter doesn't work;

  16. blasten commented on May 28, 2020

    @blasten

    This issue also affects apps because 54dba4c isn't on 1.17.1 (stable).

  17. blasten commented on May 28, 2020

    @blasten

    This is now fixed on stable. Run flutter upgrade while on the stable channel.

  18. jimneylee commented on Jun 1, 2020

    @jimneylee

    just show my found answer for others: https://stackoverflow.com/questions/59942331/android-property-not-found-error-while-building-flutter-aar

    Go to this File "/Users/username/sdk/flutter/packages/flutter_tools/gradle/aar_init_script.gradle"
    
    And in if (!project.hasProperty("android")) {
        throw new GradleException(project.toString())
            throw new GradleException("Android property not found.")
        }
    
    add the project.toString line to the file and run
    
    build flutter aar -v 
    Now you will get the conflicting plugin name Ex : url_launcher_mac_os
    
    Now go to .pubcache and delete that folder and run the
    
    build flutter aar -v 
    If you dont get conflicting plugins then your build will be successful.
    
  19. github-actions commented on Aug 20, 2021

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

  20. locked as resolved and limited conversation to collaborators on Aug 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: existing-appsIntegration with existing apps via the add-to-app flowc: crashStack traces logged to the consolec: regressionIt was better in the past than it is nowt: gradle"flutter build" and "flutter run" on AndroidtoolAffects 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