栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

构造gradle时,同时配置VSCode和Android Studio(Flutter)时,配置根项目'android'时发生问题

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

构造gradle时,同时配置VSCode和Android Studio(Flutter)时,配置根项目'android'时发生问题

所以找到答案后回答我自己的问题我来这里是为了帮助别人

是否是第一次。当您在应用程序上单击运行时,您会收到X gradle构建错误如果您的错误中包含以下任何行,甚至只有一行,请尝试此解决方案

Launching libmain.dart on sdk gphone x86 in debug mode...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 builder.jar (com.android.tools.build:builder:3.5.0)      > Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/builder/3.5.0/builder-3.5.0.jar'.         > Premature end of Content-Length delimited message body (expected: 8174407; received: 4456416   > Could not download bundletool.jar (com.android.tools.build:bundletool:0.9.0)      > Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/bundletool/0.9.0/bundletool-0.9.0.jar'.         > Premature end of Content-Length delimited message body (expected: 5248142; received: 4456416

转到此位置:-

.flutter/packages/flutter_tools/gradle/flutter.gradle

  1. 在对其进行编辑之前,将文件备份到另一个位置
  2. 寻找某种东西buildscript;
  3. 它应该像这样出现(或类似,不要担心您有备份文件)
    并覆盖此代码

    buildscript {
    repositories {
    jcenter()
    }
    dependencies {
    classpath ‘com.android.tools.build:gradle:3.1.2’
    }
    }

With this

 buildscript {    repositories {        maven { url 'https://dl.google.com/dl/android/maven2'        }        jcenter()    }    dependencies {        classpath 'com.android.tools.build:gradle:3.1.2'    }}

还是,您的问题没有解决?如果解决了,请不要尝试下一个,否则请尝试。(即使这不起作用,也将备份文件放到原
处,看看它是否起作用)

然后在你的android文件夹去到build.gradle(在你的项目文件去到android/build.gradle),并改变buildscript这个(不必担心对代码不是100%这样的。只需添加指定的行中所示的位置,这就是它)

buildscript {    repositories {        google()        mavenCentral()  //add this line        jcenter()    }    dependencies {        classpath 'com.android.tools.build:gradle:3.2.1' // Doesn't matter what you have here    }}


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/406965.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号