Open
Description
Steps to Reproduce
- Create project in a different drive from Flutter SDK
- Add
shared_preferences
andurl_launcher
topubspec.yaml
and runflutter pub get
- Open the
android
folder with Android Studio or IDEA - Gradle sync fails (error logs below)
I checked stackoverflow and https://stackoverflow.com/a/71734846/13978447 this is the workaround that works for me too.
The build fails only if the project is in a different drive from the drive in which the sdk is in.
My project is in D: and both (Android and Flutter) SDKs are in C:.
I copied the project to C: and the build succeeds.
Although this fixes the issue I do not want to store the project in C: drive (and I shouldn't have to).
I also noticed that using an old version of the plugin shared_preferences: 2.0.6
instead of the latest 2.0.15
fixes the issue for this plugin atleast.
Flutter Doctor
[√] Flutter (Channel stable, 3.0.1, on Microsoft Windows [Version 10.0.19043.1706], locale en-IN)
• Flutter version 3.0.1 at C:\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision fb57da5f94 (2 weeks ago), 2022-05-19 15:50:29 -0700
• Engine revision caaafc5604
• Dart version 2.17.1
• DevTools version 2.12.2
[√] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
• Android SDK at C:\Users\VARUN\AppData\Local\Android\Sdk
• Platform android-Tiramisu, build-tools 32.0.0
• ANDROID_HOME = C:\Users\VARUN\AppData\Local\Android\Sdk
• ANDROID_SDK_ROOT = C:\Users\VARUN\AppData\Local\Android\Sdk
• Java binary at: C:\Users\VARUN\.jdks\corretto-11.0.15\bin\java
• Java version OpenJDK Runtime Environment Corretto-11.0.15.9.1 (build 11.0.15+9-LTS)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
[√] Visual Studio - develop for Windows (Visual Studio Build Tools 2019 16.9.3)
• Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools
• Visual Studio Build Tools 2019 version 16.9.31129.286
• Windows 10 SDK version 10.0.18362.0
[!] Android Studio (not installed)
• Android Studio not found; download from https://developer.android.com/studio/index.html
(or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions).
[√] IntelliJ IDEA Ultimate Edition (version 2022.1)
• IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA 2022.1
• Flutter plugin version 68.1.4
• Dart plugin version 221.5787.37
[√] VS Code, 64-bit edition (version 1.67.2)
• VS Code at C:\Program Files\Microsoft VS Code
• Flutter extension can be installed from:
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[√] Connected device (3 available)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19043.1706]
• Chrome (web) • chrome • web-javascript • Google Chrome 102.0.5005.63
• Edge (web) • edge • web-javascript • Microsoft Edge 101.0.1210.39
[√] HTTP Host Availability
• All required HTTP hosts are available
! Doctor found issues in 1 category.
Metadata
Metadata
Assignees
Labels
Issues that are less important to the Flutter projectSupport for writing, building, and running plugin packagesAffects or could affect many people, though not necessarily a specific customer.Found to occur in 3.0Found to occur in 3.1The issue has been confirmed reproducible and is ready to work onAndroid applications specifically"flutter build" and "flutter run" on AndroidOwned by Android platform teamAffects the "flutter" command-line tool. See also t: labels.Triaged by Android platform team
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
huycozy commentedon Jun 6, 2022
Hi @VarunS2002,
I can not reproduce this issue on the latest
stable
andmaster
channels.The project I created on drive
D:
run well with Flutter SDK located on driveC:
Sample code
The default new created project with adding two dependencies:
Logs
flutter doctor -v
As I can see from your
flutter doctor -v
:It seems you're not using
Android Studio
. What's your current IDEA? Or can you try installing Android Studio and retry?VarunS2002 commentedon Jun 6, 2022
@huycozy
Oh no don't get me wrong.
flutter run
andflutter build apk
both work fine.Which indicates that the gradle tasks
assembleDebug
andassembleRelease
both work.Only the gradle sync process fails in IDEA when I open the
android
folder as a project resulting in me unable to use the native Android features in IDEA.One thing to note is that I am using Android Gradle Build Plugin
7.0.4
instead of the Flutter default7.1.2
because IDEA 2022.1.2 doesn't support it apparently.I will install and setup Android Studio to test the same but I will need a few days time so please don't close the issue by then,
VarunS2002 commentedon Jun 6, 2022
I tried it with the latest Android Studio Chipmunk 2021.2.1 Patch 1 but the issue persists.
With Android Gradle Plugin 7.0.4:
With Android Gradle Plugin 7.1.2:
VarunS2002 commentedon Jun 6, 2022
I created a new empty project to reproduce the issue which I'm attaching here:
test.zip
New Flutter Doctor output
huycozy commentedon Jun 7, 2022
@VarunS2002
Opened your
test.zip
and see the version is different than you reported.It's using
7.1.2
:Anyway, I got the same error when creating new project and adding dependencies as above mentioned.
Logs
The temporary workaround is to use lower gradle
4.1.3
:FYI, there is a completed work here #87649 in order to support for Android Gradle Plugin 7.0.0, but it's not supported for first party packages/plugins yet. Follow up on #88666 for further updates.
I'm closing the current one as a duplicate.
If you disagree, please write in the comments and I will reopen it.
VarunS2002 commentedon Jun 7, 2022
The version was different because I created a new project in the latest Android Studio to test this issue (to check whether IDEA or AGB 7.0.4 was the problem). My main project still has AGP 7.04 and throws the same error.
Either way you're able to reproduce the error so it doesn't matter.
VarunS2002 commentedon Jun 7, 2022
Also I'm curious why this happens only on a different drive and works fine on the drive that has the sdk?
huycozy commentedon Jun 7, 2022
You're right, it worked well on the same drive even with default Gradle
7.1.2
. It means that we don't need to update anything from new project when creating the project in the same drive with Flutter SDK.Reopen this issue for further investigation from the team due to this issue's occurring in a special case, it is unlikely that #88666 will be aware/fix it next time.
69 remaining items