Android – Flutter: SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable

androidandroid-studioflutter

I'm building app using different ways, two works but one fails.

Method:1 (Working)

flutter build appbundle 

Method:2 (Working)

Opening module in Android Studio, after that, choosing

Build > Generate Signed Bundle/APK... > filling all info afterwards

In this case, I am able to build both app bundle and APK file.


Method:3 (Not working)

flutter build apk

I get this error:

FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android_intent'.

SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.


If I remove android_intent, I start getting error in other packages, so definitely the package isn't a problem. I double checked that I have

local.properties, gradle.properties and settings.gradle in my android root folder.

And my other projects seem to work.

Best Answer

I have faced this issue with file_picker plugin, Just upgrade gradle version in android/build.gradle to one of these versions :

3.3.3

3.4.3

3.5.4

3.6.4

4.0.1

I followed this link : file_picker troubleshooting

Related Topic