flutter --version
dart --version
如何使用Flutter框架推流_音视频终端 SDK(Apsara Video SDK)-阿里云帮助中心
MediaBox音视频SDK下载指南_音视频终端 SDK(Apsara Video SDK)-阿里云帮助中心
终端输入 dart pub --trace get --no-precompile
打印详细报错信息
详细咨询chatgpt
pub.dev 中已经是最新版本了
项目中已经是最新版本了
最终定位到
终端输出dart版本是 电脑环境变量中的版本
和阿里云咨询的版本不匹配
您好 ,用我们的推荐版本吧 $ flutter --version Flutter 2.8.0 • channel unknown • unknown source Framework • revision cf44000065 (1 年 4 个月前) • 2021-12-08 14:06:50 -0800 Engine • revision 40a99c5951 Tools • Dart 2.15.0
尝试解决方案,电脑中重新设置环境变量
新配置flutter 2.8的环境变量 上移动到最上面
三步确定保存环境变量
更改后重启IntelliJ IDEA 2023.3.6 使环境变量生效
这样环境变量就对上了
运行
dart pub --trace get --no-precompile
提示如下
运行
dart pub --trace pub --trace get --no-precompile
Windows 新增两个环境变量
PUB_HOSTED_URL https://mirror.sjtu.edu.cn/dart-pub
FLUTTER_STORAGE_BASE_URL https://mirror.sjtu.edu.cn
替换为如下:
PUB_HOSTED_URL ===== https://pub.flutter-io.cn FLUTTER_STORAGE_BASE_URL ===== https://storage.flutter-io.cn
注意测试你的电脑要连上手机的数据流量进行下载依赖
执行 pub get 报错信息如下
报错信息翻译如下
遇到了新的报错信息
缺少这个包
pub.dev 搜索到安装
翻译如下 因为flatter_livepush_demo依赖于flatter_gen>=5.3.0 调整 flatter_gen版本为小于5.3
Running "flutter pub get" in ceshi... The current Dart SDK version is 2.15.0.
Because flutter_livepush_demo depends on flutter_gen >=5.3.0 which requires SDK version >=2.17.0 <4.0.0, version solving failed. pub get failed (1; Because flutter_livepush_demo depends on flutter_gen >=5.3.0 which requires SDK version >=2.17.0 <4.0.0, version solving failed.)
这个报错是什么呢 怎么解决
这个报错是因为你的项目中使用了一个依赖(flutter_gen)要求Dart SDK版本必须在2.17.0及以上但小于4.0.0,而你当前的Dart SDK版本是2.15.0,所以版本解析失败导致报错。
要解决这个问题,你可以尝试升级你的Dart SDK版本到符合要求的版本(>=2.17.0 <4.0.0)。你可以通过运行
flutter upgrade
来升级Flutter SDK,这可能会同时升级Dart SDK版本。然后再次运行flutter pub get
看看是否问题解决了。如果升级SDK版本后问题仍然存在,你可以尝试联系依赖库的开发者,看是否可以更新他们的依赖要求,或者尝试使用其他版本兼容的依赖。
这个报错是因为你的项目中使用了一个依赖(flutter_gen)要求Dart SDK版本必须在2.17.0及以上但小于4.0.0,而你当前的Dart SDK版本是2.15.0,所以版本解析失败导致报错。
解决方案 新增
flutter_gen: ^5.3.0 依赖
再次下载 flutter sdk 使用其中的 dart 版本 2.17.0 就没有这个报错了
新的报错问题如下
Launching lib\main.dart on V2164A in debug mode... Running Gradle task 'assembleDebug'... Exception in thread "main" java.net.UnknownHostException: android.googlesource.com安装包下载_开源镜像站-阿里云 at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:567) at java.base/java.net.Socket.connect(Socket.java:751) at java.base/java.net.Socket.connect(Socket.java:686) at java.base/sun.net.NetworkClient.doConnect(NetworkClient.java:183) at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:531) at java.base/sun.net.www.http.HttpClient1.run(HttpClient.java:590)atjava.base/sun.net.www.http.HttpClient1.run(HttpClient.java:590)atjava.base/sun.net.www.http.HttpClient1.run(HttpClient.java:588) at java.base/java.security.AccessController.doPrivileged(AccessController.java:571) at java.base/sun.net.www.http.HttpClient.privilegedOpenServer(HttpClient.java:587) at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:631) at java.base/sun.net.www.http.HttpClient.<init>(HttpClient.java:280) at java.base/sun.net.www.http.HttpClient.New(HttpClient.java:386) at java.base/sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1311) at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1258) at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1123) at java.base/sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:1052) at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1675) at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1599) at org.gradle.wrapper.Download.downloadInternal(Download.java:58) at org.gradle.wrapper.Download.download(Download.java:44) at org.gradle.wrapper.Install1.call(Install.java:61)atorg.gradle.wrapper.Install1.call(Install.java:61)atorg.gradle.wrapper.Install1.call(Install.java:48) at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65) at org.gradle.wrapper.Install.createDist(Install.java:48) at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:128) at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61) Exception: Gradle task assembleDebug failed with exit code 1
请问这个是怎么回事,怎么解决
这个错误是由于Gradle在下载依赖时无法连接到指定的主机导致的。可能是网络连接问题或者指定的主机不可用。
要解决这个问题,可以尝试以下方法:
- 检查网络连接,确保你的网络连接正常。
- 检查Gradle的配置文件,确认指定的依赖主机地址是否正确。
- 可以尝试使用VPN连接或者切换到其他网络环境进行下载。
- 如果问题仍然存在,可以尝试手动下载依赖并手动添加到项目中。
如果以上方法都无法解决问题,建议尝试联系Gradle的支持团队或者查看相关文档寻求帮助。
将flutter_gen 改成 flutter_gen_core
问题
原因 gradle下载不下来
解决参考
http://t.csdnimg.cn/B6mAh
问题:Flutter create新建项目之后运行,一直报错显示Exception in thread "main" java.net.ConnectException: Connection timed out: connect
Exception in thread "main" java.net.ConnectException: Connection timed out: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:666)
at sun.security.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl.java:173)
at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:463)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:558)
at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:264)
at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:367)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1156)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1050)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:263)
at org.gradle.wrapper.Download.downloadInternal(Download.java:58)
at org.gradle.wrapper.Download.download(Download.java:44)
at org.gradle.wrapper.Install$1.call(Install.java:61)
at org.gradle.wrapper.Install$1.call(Install.java:48)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
at org.gradle.wrapper.Install.createDist(Install.java:48)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:128)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 26.4s
Exception: Gradle task assembleDebug failed with exit code 1
其实主要估计就是网络超时问题,我上网搜了一波发现都建议
需要修改项目下 android/build.gradle 和 flutter 安装目录flutter/packages/flutter_tools/gradle/flutter.gradle 两个文件中 buildscript 和allprojects 中的google()
jcenter()
替换成阿里云镜像maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/jcenter' }
maven { url'http://maven.aliyun.com/nexus/content/groups/public' }
但是我替换后还是回显示同样的错误,开始思考其实之所以这样修改,是因为更快下载到需要的gradle.zip文件,所以我就直接在http://services.gradle.org/distributions/这里下载我所需要的grade文件直接引用本地的来运行,结果成功运行了步骤一:到你项目里面的gradle-wrapper.properties文件里面查找到你所需要的版本,我这里是gradle-6.7-all.zip
步骤二:到这里http://services.gradle.org/distributions/找到对应的版本下载
步骤三:找到你的.grade地方,我电脑所在是 C:\Users\husk\.gradle ,然后将刚刚下载成功的zip包放在该目录下(其实你喜欢放在哪都无所谓,反正到时候引入本地这个zip就好)
步骤四:到你项目里面的gradle-wrapper.properties文件里面将原来的 distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip 换乘本地的
然后运行,运行成功了!!!
————————————————版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/sinat_39326239/article/details/116824760
问题
原因当前java 版本21 可能是太高了 需要 java8版本
下载 jdk 1.8 Index of java-local/jdk/8u151-b12
Flutter 启动时 gradle 的错误
错误内容在启动一个 Flutter 项目时,遇到了 gradle 相关的错误,具体错误信息如下:
* What went wrong:
Could not open settings remapped class cache for 3gvp67rxesfd2nfkbvtuzjg3o (C:\Users\&unser_name%\.gradle\caches\5.6.2\scripts-remapped\settings_3j4cktj76tcwqa3p6pnijdwdi\3gvp67rxesfd2nfkbvtuzjg3o\settings8410a2d21ed2f87c8a0398566330ee52).
> Could not open settings generic class cache for settings file 'C:\Users\Administrator\AndroidStudioProjects\flutter_app\android\settings.gradle' (C:\Users\Administrator\.gradle\caches\5.6.2\scripts\3gvp67rxesfd2nfkbvtuzjg3o\settings\settings8410a2d21ed2f87c8a0398566330ee52).
> BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 57* 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 1s
Finished with error: Gradle task assembleDebug failed with exit code 1
对我无效的解决方案
有的资料说删除.gradle/caches可以解决问题,没用。
有的说删除项目文件夹下andoird/build.gradle、android/settings.gradle以及android/app/build.gradle三个文件中关于package的行。然而我的这三个文件中并没有相关行……当然也就没有任何卵用。
有效的解决方案看了很多资料后尝试将现在使用的 JDK 从java 13改为java 8,问题得到了解决。
运行得到正确的结果:
Using hardware rendering with device Android SDK built for x86. If you get graphics artifacts, consider enabling software rendering with
"--enable-software-rendering".
Launching lib\main.dart on Android SDK built for x86 in debug mode...
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 68.0s
√ Built build\app\outputs\apk\debug\app-debug.apk.
Installing build\app\outputs\apk\app.apk... 1.8s
D/FlutterActivity( 8673): Using the launch theme as normal theme.
D/FlutterActivityAndFragmentDelegate( 8673): Setting up FlutterEngine.
D/FlutterActivityAndFragmentDelegate( 8673): No preferred FlutterEngine was provided. Creating a new FlutterEngine for this FlutterFragment.
D/FlutterActivityAndFragmentDelegate( 8673): Attaching FlutterEngine to the Activity that owns this Fragment.
D/FlutterView( 8673): Attaching to a FlutterEngine: io.flutter.embedding.engine.FlutterEngine@4bf553e
D/FlutterActivityAndFragmentDelegate( 8673): Executing Dart entrypoint: main, and sending initial route: /
D/EGL_emulation( 8673): eglMakeCurrent: 0xeed7fbe0: ver 2 0 (tinfo 0xe3bd5bb0)
D/eglCodecCommon( 8673): setVertexArrayObject: set vao to 0 (0) 1 0
I/m.example.myap( 8673): NativeAlloc concurrent copying GC freed 1908(215KB) AllocSpace objects, 3(60KB) LOS objects, 57% free, 1114KB/2650KB, paused 653us total 486.487ms
I/OpenGLRenderer( 8673): Davey! duration=1832ms; Flags=1, IntendedVsync=4010927657182, Vsync=4010994323846, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=4010999132700, AnimationStart=4010999214400, PerformTraversalsStart=4010999287600, DrawStart=4012168475900, SyncQueued=4012173764500, SyncStart=4012175660200, IssueDrawCommandsStart=4012179313100, SwapBuffers=4012455218300, FrameCompleted=4012761766600, DequeueBufferDuration=161026000, QueueBufferDuration=513000,
I/Choreographer( 8673): Skipped 107 frames! The application may be doing too much work on its main thread.
D/EGL_emulation( 8673): eglMakeCurrent: 0xe3b242a0: ver 2 0 (tinfo 0xe3b8cb90)
Syncing files to device Android SDK built for x86...
D/eglCodecCommon( 8673): setVertexArrayObject: set vao to 0 (0) 1 0
Syncing files to device Android SDK built for x86... 9,633ms (!)�🔥 To hot reload changes while running, press "r". To hot restart (and rebuild state), press "R
An Observatory debugger and profiler on Android SDK built for x86 is available at: http://127.0.0.1:5083/tkseS6ZWRSc=/
For a more detailed help message, press "h". To detach, press "d"; to quit, press "q".解决办法:使用较低版本的 JDK,比如java 8。
顺便解决了Android license的问题在此前,执行命令flutter doctor时,会提示Android license status unknown的问题,具体信息如下:
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
✗ Android license status unknown.
Try re-installing or updating your Android SDK Manager.
See https://developer.android.com/studio/#downloads or visit https://flutter.dev/setup/#android-setup for detailed instructions.1
2
3
4在 JDK 从java 13改为java 8之后,相关信息也随之变成了:
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses1
2按照提示信息,执行flutter doctor --android-licenses,然后会弹出数个相关许可:
6 of 7 SDK package licenses not accepted. 100% Computing updates...
Review licenses that have not been accepted (y/N)? y1/6: License android-googletv-license:
---------------------------------------
Terms and Conditions
...
August 15, 2011
---------------------------------------
Accept? (y/N): y2/6: License android-sdk-arm-dbt-license:
---------------------------------------
Terms and Conditions
...
January 16, 2019
---------------------------------------
Accept? (y/N): y3/6: License android-sdk-preview-license:
---------------------------------------
To get started with the Android SDK Preview, ...
...June 2014.
---------------------------------------
Accept? (y/N): y4/6: License google-gdk-license:
---------------------------------------
This is a Developer Preview of the GDK that is subject to change.Terms and Conditions
...
November 19, 2013
---------------------------------------
Accept? (y/N): y5/6: License intel-android-extra-license:
---------------------------------------
Intel (R) Hardware Accelerated Execution Manager End-User License AgreementCopyright (c) 2012 Intel Corporation. All rights reserved.
...
---------------------------------------
Accept? (y/N): y
All SDK package licenses accepted逐个同意之后,得到提示All SDK package licenses accepted。
此时再次执行命令flutter doctor,相关信息就变成了:
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
1
使用命令flutter doctor -v查看更详细的信息如下:
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at C:\Users\%user_name%\AppData\Local\Android\Sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.3
• Java binary at: C:\Program Files\Java\java-1.8.0-openjdk-1.8.0.212-3.b04.redhat.windows.x86_64\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_212-3-redhat-b04)
• All Android licenses accepted.
————————————————版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/w573719227/article/details/105019360
设置环境变量 重启 idea 运行到手机
C:\Program Files\Java\jdk-21\
替换为C:\Program Files\Java\jdk-1.8
解决Flutter编译一直显示Running Gradle task 'assembleDebug'
该问题由 Gradle 的Maven仓库在国外访问受限引起,使用阿里云的镜像仓库地址替代解决
1.修改Flutte SDK目录下的Flutter打包配置文件flutter.gradle
一般位于flutter\packages\flutter_tools\gradle\flutter.gradle
https://www.cnblogs.com/fanqisoft/p/17528904.html
运行后出问题
算了 还是明天问阿里的工作人员把
问题
今天我有又来了
您好,这个问题,白天找后端看下,有进展反馈您
售后工程师
2024-04-12 09:03
您好 ,Gradle 版本与Java JDK版本不兼容, 这种问题网上找一下解决方案
参天果树啊
2024-04-12 11:36
你那边的 java jdk版本是要求多少
项目也要换
将电脑环境变量中的 java jdk版本11.0.22 换成16.0.2
C:\Users\Administrator\.jdks\corretto-11.0.22
C:\Users\Administrator\.jdks\corretto-16.0.2
三步确定 后记得重启 开发工具 使开发环境生效
遇到新的问题
解决方案参考
Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns解决方法_warning: mapping new ns-CSDN博客
在运行Flutter应用程序时,调试控制台中打印了如下错误:
Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/03 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/03 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/03 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
上述错误是,将新 ns 映射到旧 ns,可以尝试删除并重新安装 SDK 平台。根本的解决方案是升级gradle。首先,打开gradle-wrapper.properties,修改gradle版本。
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip
推荐用迅雷将 gradle下载到本地 将 distributionUrl修改为如下
distributionUrl=file:///D:/gradle-7.2-all.zip
然后,再修改android/build.gradle。
dependencies {
classpath 'com.android.tools.build:gradle:7.0.4'
}
点击运行到手机 其中构建要很长时间 不知道怎么 回事,只能等待 5到8分钟
测试到这里我的心态崩了
但是好歹最后运行成功了