简体   繁体   中英

Unable to "flutter run" due to failure to install SDK but flutter doctor runs fine

flutter doctor output on windows is

C:\\WINDOWS\\system32> flutter doctor Doctor summary (to see all details, run flutter doctor -v): [√] Flutter (Channel stable, v1.0.0,> on Microsoft Windows [Version 10.0.17134.523], locale en-US) [√]Android toolchain - develop for Android devices (Android SDK 27.0.3) [√] Android Studio (version 3.2) [√] VS Code, 64-bit edition (version 1.31.1) [√] Connected device (1 available)

• No issues found!

as you can see no issues found BUT flutter is detecting latest sdk installed as 27 when i have installed 28 already.

when i try to flutter run from vs code an app(first sample app from docs) i get this error

FAILURE: Build failed with an exception.

  • Where: Build file 'D:\\VSProjects\\Flutter\\myapp\\android\\build.gradle' line: 24

  • What went wrong: A problem occurred evaluating root project 'android'.

    A problem occurred configuring project ':app'. Failed to install the following SDK components: build-tools;28.0.3 Android SDK Build-Tools 28.0.3 The SDK directory is not writable (C:\\Program Files (x86)\\Android\\android-sdk)

i tried changing the permission of the file to remove read-only access and still get the same error, i use the same sdk to build android apps with android studio(native) and visual studio(xamarin) just fine...i have the latest sdk version installed already so why is flutter giving me this error?

Can i downgrade my sdk requirement somehow?

You shoudn't install the Android SDK into C:\\Program Files (x86) which requires elevated privileges to write. Android Studio seems to install it into C:\\Users\\someUser\\AppData\\Local\\Android\\Sdk where the current user has sufficient privileges.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM