配置根项目时出现问题';安卓&x27;在构建gradle时,VSCode和Android Studio(颤振)
今天我开始学习颤振并成功下载了所有内容。但是当我运行我的应用程序时,调试器(无论是配置根项目时出现问题';安卓&x27;在构建gradle时,VSCode和Android Studio(颤振),android,android-studio,flutter,gradle,visual-studio-code,Android,Android Studio,Flutter,Gradle,Visual Studio Code,今天我开始学习颤振并成功下载了所有内容。但是当我运行我的应用程序时,调试器(无论是VSCode还是Android Studio)都会给我这个错误 Launching lib\main.dart on sdk gphone x86 in debug mode... FAILURE: Build failed with an exception. * What went wrong: A problem occurred configuring root project 'android'. &
VSCode
还是Android Studio
)都会给我这个错误
Launching lib\main.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
* 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 21m 37s
Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
这是build.gradle
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
任何帮助将不胜感激,因为我试图解决这个问题6小时
注意:-这是我在Flatter和Android Studio中的第一个应用程序,VSCode,所以在找到答案后,我来这里是为了帮助他人 不管是不是第一次。当您在应用程序上单击“运行”时,您会收到一个X gradle生成错误。如果您的错误中有以下任何一行,甚至只有一行,请尝试此解决方案
Launching lib\main.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
解决方案
转到以下位置:-.flatter/packages/flatter\u tools/gradle/flatter.gradle
**
buildscript
的东西李>
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
}
}
用这个
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%像这样。只需在显示的位置添加指定的行即可)
因此,在找到答案后,为了回答我自己的问题,我来到这里帮助他人 不管是不是第一次。当您在应用程序上单击“运行”时,您会收到一个X gradle生成错误。如果您的错误中有以下任何一行,甚至只有一行,请尝试此解决方案
Launching lib\main.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
解决方案
转到以下位置:-.flatter/packages/flatter\u tools/gradle/flatter.gradle
**
buildscript
的东西李>
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
}
}
用这个
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%像这样。只需在显示的位置添加指定的行即可)
在android Studio中:
以这种方式修改android\build.gradle以解决此问题
buildscript {
repositories {
google()
mavenCentral() //Add.
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.2'
}
}
allprojects {
repositories {
google()
mavenCentral() //Add
jcenter()
}
}
我有同样的问题,并通过更新此文件解决了它。
此问题在android Studio的中得到解决:
以这种方式修改android\build.gradle以解决此问题
buildscript {
repositories {
google()
mavenCentral() //Add.
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.2'
}
}
allprojects {
repositories {
google()
mavenCentral() //Add
jcenter()
}
}
我有同样的问题,并通过更新此文件解决了它。
此问题在将颤振升级到最新版本时得到解决 然后将gradle插件升级到最新版本 目前
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
}
将颤振升级到最新版本 然后将gradle插件升级到最新版本 目前
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
}