折腾:
【已解决】mac中用Android Studio连接安卓真机调试Flutter项目
期间,点击Debug后,要初始化gradle
好像有很多东西要更新呢:
Android Emulator
Android SDK Platform
Android SDK …
感觉是:
Android Studio 首次调试Flutter卡死在 Initializing gradle
第一次构建Flutter项目一直卡在Initializing gradle… – weixin_34253539的博客 – CSDN博客
稍微等了会
Flutter 新创建的demo 运行 一直Initializing gradle… 处理 – trues的博客 – CSDN博客
解决Flutter项目卡在Initializing gradle…界面的问题 – 简书
Flutter实践——AndroidStudio环境初体验 – 简书
flutter initializing gradle终极解决方案 – 叶de第柒章 – 博客园
结果等了会,直接报错:
Launching lib/main.dart on MI 9 in debug mode... Initializing gradle... Resolving dependencies... * Error running Gradle: ProcessException: Process "/Users/crifan/dev/xxx/android/gradlew" exited abnormally: Starting a Gradle Daemon (subsequent builds will be faster) FAILURE: Build failed with an exception. * What went wrong: A problem occurred configuring root project 'android'. > Could not resolve all artifacts for configuration ':classpath'. > Could not download asm-commons.jar (org.ow2.asm:asm-commons:6.0) > Could not get resource 'https://jcenter.bintray.com/org/ow2/asm/asm-commons/6.0/asm-commons-6.0.jar'. > Read timed out * 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 1m 59s Command: /Users/crifan/dev/dev_root/xxx/android/gradlew app:properties Finished with error: Please review your Gradle project setup in the android/ folder.
Error running Gradle ProcessException Process exited abnormally
初学flutter 刚折腾完环境遇上如下问题,* Error running Gradle: 不知道如何下手寻找! – the_pp的回答 – SegmentFault 思否
Could not get resource https://jcenter.bintray.com/org/ow2/asm/asm-commons/6.0/asm-commons-6.0.jar
Read timed out
解决Flutter 新建项目 Error running Gradle 错误 – weixin_34050427的博客 – CSDN博客
解决Flutter 新建项目 Error running Gradle 错误 – 简书
第一次运行flutter_app的坑 – qq_34715162的博客 – CSDN博客
去看看自己的app中的build.gradle
没看到有build.gradle
终于找到了:
android/build.gradle
里面有个:
jcenter()
估计这里的
https://jcenter.bintray.com/org/ow2/asm/asm-commons/6.0/asm-commons-6.0.jar
下载不到,就是从jcenter中无法翻墙下载导致的
另外,也看到了
android/gradle/wrapper/gradle-wrapper.properties
中有别人提到的:
gradle的地址
#Fri Jun 23 08:50:38 CEST 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
所以去修改
android/build.gradle
buildscript { repositories { google() jcenter() }
改为:
buildscript { repositories { // 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’ }
}
另外,再去找到Flutter的根目录
注:
此处用可以从:
android/local.properties
sdk.dir=/Users/crifan/dev/dev_tool/android/AndroidSDK flutter.sdk=/Users/crifan/dev/dev_tool/Flutter/flutter
得知是:
/Users/crifan/dev/dev_tool/Flutter/flutter
packages/flutter_tools/gradle/fultter.gradle
去把
改为同样的:
重新debug,结果
就可以继续了(只不过CPU占用率很高,很卡):
Launching lib/main.dart on MI 9 in debug mode... Initializing gradle... Resolving dependencies... Running Gradle task 'assembleDebug'...
转载请注明:在路上 » 【已解决】Android Studio中首次调试Flutter卡死在Initializing gradle