android studio第一个flutter工程踩坑

1.最后一坑: 

各种环境, 路径都配置好了,  但是新建flutter工程,  竟然是空的,   最后在我犀利的小眼神扫射下,  发现新建工程的时候, android studio 右下角有个报错,这个报错如果你5秒钟之内没看到的话,  就会一闪而过,  本猿就是新建了三个工程才发现.   具体报错信息如下:

"TestFlutter" is not a valid Dart package name. From the [Pubspec format description](https://www.dartlang.org/tools/pub/pubspec.html): **DO** use `lowercase_with_underscores` for package names. Package names should be all lowercase, with underscores to separate words, `just_like_this`. Use only basic Latin letters and Arabic digits: [a-z0-9_]. Also, make sure the name is a valid Dart identifier -- that it doesn't start with digits and isn't a reserved word.

解决方法:

       从报错信息看出,  是因为工程名称不合法,  百度了一圈回来, 发现很多人都遇到了这个坑,  把工程名称,包名,全都改成小写,就没有问题了.  下图是我新建Flutter工程成功的画面,  好嗨哟!

2.又有一坑:

编译运行到手机上的时候,  怀着无比紧张 而且还有点小兴奋的心情,  等待着AS的编译运行.   但是现实的大嘴巴子,总是会无情的将猿们抽醒!  又报错了:

Launching lib\main.dart on Redmi Note 4 in debug mode...
Initializing gradle...
Resolving dependencies...
* Error running Gradle:
ProcessException: Process "D:\MineX\Flutter\firstflutter\android\gradlew.bat" exited abnormally:

> Configure project :app
NDK is missing a "platforms" directory.
If you are using NDK, verify the ndk.dir is set to a valid NDK directory.  It is currently set to D:\download\SDK\sdk-lite\ndk-bundle.
If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.

Checking the license for package Android SDK Build-Tools 28.0.3 in D:\download\SDK\sdk-lite\licenses
Warning: License for package Android SDK Build-Tools 28.0.3 not accepted.
Checking the license for package Android SDK Platform 28 in D:\download\SDK\sdk-lite\licenses
Warning: License for package Android SDK Platform 28 not accepted.


FAILURE: Build failed with an exception.

* Where:
Build file 'D:\MineX\Flutter\firstflutter\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 Android SDK packages as some licences have not been accepted.
        build-tools;28.0.3 Android SDK Build-Tools 28.0.3
        platforms;android-28 Android SDK Platform 28
     To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
     Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html

     Using Android SDK: D:\download\SDK\sdk-lite

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 3s
  Command: D:\MineX\Flutter\firstflutter\android\gradlew.bat app:properties

Finished with error: Please review your Gradle project setup in the android/ folder.

里面有句关键的报错信息:

Failed to install the following Android SDK packages as some licences have not been accepted.

解决方法:

百度了一圈回来:  大概意思是 android sdk 没有同意授权

具体解决方法:  可以参考Flutter 04: 图解第一个程序遇到的安装依赖问题

cmd -->  flutter doctor --android-licenses  

然后一路的y ,  y ,  y,  最后重新编译运行工程即可

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值