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

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

Closed
perqin opened this issue May 22, 2020 · 14 comments · Fixed by #58018
Closed
Labels
a: existing-apps Integration with existing apps via the add-to-app flow c: crash Stack traces logged to the console c: regression It was better in the past than it is now t: gradle "flutter build" and "flutter run" on Android tool Affects the "flutter" command-line tool. See also t: labels.

Comments

@perqin
Copy link
Contributor

perqin commented May 22, 2020

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

TahaTesser commented May 22, 2020

Edit:
Misunderstood, path_provider_macos isn't separate than path_provider

@TahaTesser TahaTesser added in triage Presently being triaged by the triage team waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds labels May 22, 2020
@perqin
Copy link
Contributor Author

perqin commented May 22, 2020

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.

@no-response no-response bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label May 22, 2020
@tiagoantunes
Copy link

same issue,
#57810

@TahaTesser TahaTesser removed the in triage Presently being triaged by the triage team label May 22, 2020
@TahaTesser TahaTesser 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 May 22, 2020
@TahaTesser TahaTesser added a: existing-apps Integration with existing apps via the add-to-app flow c: crash Stack traces logged to the console t: gradle "flutter build" and "flutter run" on Android tool Affects the "flutter" command-line tool. See also t: labels. labels May 22, 2020
@TahaTesser TahaTesser added the c: regression It was better in the past than it is now label May 25, 2020
@creativecreatorormaybenot
Copy link
Contributor

creativecreatorormaybenot commented May 25, 2020

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

@cyanglaz
Copy link
Contributor

cc @blasten

@TahaTesser
Copy link
Member

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

@blasten
Copy link

blasten commented May 26, 2020

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.

@creativecreatorormaybenot
Copy link
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.

@perqin
Copy link
Contributor Author

perqin commented May 27, 2020

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

@wanjm
Copy link

wanjm commented May 27, 2020

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

@blasten
Copy link

blasten commented May 28, 2020

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

@blasten
Copy link

blasten commented May 28, 2020

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

@blasten blasten closed this as completed May 28, 2020
@jimneylee
Copy link

jimneylee commented Jun 1, 2020

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.

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: existing-apps Integration with existing apps via the add-to-app flow c: crash Stack traces logged to the console c: regression It was better in the past than it is now t: gradle "flutter build" and "flutter run" on Android tool Affects the "flutter" command-line tool. See also t: labels.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants