flutter app could not locate aapt while building

Viewed 11125

When I was trying to build and run a flutter app it shows me the following message: "Could not locate aapt. Please ensure you have the Android buildtools installed. Exception: Problem building Android application: see above error(s)." I already have both build tools and the android sdk installed, so I don't know what might have caused this issue.

8 Answers

Going into the folder where the android sdk is located and under the 'build-tools' delete everything inside it, then using android studio re install the build tools this will fix the issue

check in cmd flutter doctor something like this will occur

[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3) X Android SDK file not found: C:\Users\aksha\AppData\Local\Android\sdk\build-tools\30.0.3\aapt.

problem is your sdk version 30.0.3 is not installed successfully try to download it seperatelly from https://androidsdkoffline.blogspot.com/p/android-sdk-build-tools.html?m=1

and unzip it and replace its contant with 30.0.3 at location C:\Users\aksha\AppData\Local\Android\sdk\build-tools\30.0.3

restart

done

For me the issue was resolved by running flutter doctor in cmd. The issue was accepting licenses. Running flutter doctor --android-licenses and then typing y for all licenses resolved the issue. enter image description here

You can use this command flutter config --android-sdk after updating the android studio and can refer to the path from SDK manager

I was able to generate apk but I was also unable to install the apk in device I removed the error by following steps-

  1. go to C:\Users\aksha\AppData\Local\Android\sdk\build-tools\30.0.3 (check show hidden items option)
  2. delete this folder inside build-tools (because the error is not installed properly).
  3. for resolving this issue, we have to uncheck all the latest plateforms (android (S)12 etc) and click apply after this restart the studio and check all these platforms again at least one latest and apply(ok).
  4. Open Android Studio->files->Settings->Appearence & Behavior->System Settings->Android SDK->SDK plateforms(Latest) enter image description here
  1. run flutter command to accept the licenses. (type Y then enter for all) flutter doctor --android-licenses
  2. all is done

It will be an Android Studio bug. I updated Android Studio to the latest Beta version and fixed it. I hope it will be of help to you too.

If you are using ubuntu check /home/username/Android/Sdk folder present or not, I think your sdk folder deleted or moved to new location. thats why this issue happen.

You must update your build tools of SDK by using SDK manager in android studio. go to androidstudio->sdkmanager->sdktools->then update build tools

Related