简体   繁体   中英

How to build APK file from Flutter project?

Here I want build apk file for my flutter project. But a problem occurred when I build APK file with flutter build apk command. I already define flutter SDK path, android SDK path, JDK path in environment variable, but still this problem occurred. How to accomplish this?
Below I share the image of error which actually display in terminal.
点击此处查看错误图片

Another Error also I Put below side此图像显示有上述错误。

You need to set the sdk dir for your project

Go to your Flutter Project -> Android if local.properties file was not there Create a file local.properties other wise open it Open the file paste your Android SDK path like below

  • in Windows sdk.dir = C:\Users\USERNAME\AppData\Local\Android\sdk
  • in macOS sdk.dir = /Users/USERNAME/Library/Android/sdk
  • in linux sdk.dir = /home/USERNAME/Android/Sdk

Replace USERNAME with your user name

I will suggest to run

flutter clean .

before creating the app file

example of how a local.properties file data look like

for Windows

sdk.dir=C:\\Users\\UserName\\AppData\\Local\\Android\\sdk
flutter.sdk=C:\\src\\flutter

for Mac

sdk.dir=/Users/UserName/Library/Android/sdk
flutter.sdk=/Users/UserName/Desktop/Workspace/Flutter/flutter
flutter.buildMode=debug
flutter.versionName=1.0.0
flutter.versionCode=1

where sdk.dir is the sdk directory for android and flutter.sdk is sdk directory for flutter

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