首次安装时Android Studio中出现Gradle错误
我最近开始使用Android Studio,并尝试遵循“第一个应用”教程()。然而,当我在Android Studio中创建一个新项目时,我几乎立刻就遇到了这个错误首次安装时Android Studio中出现Gradle错误,android,android-studio,gradle,Android,Android Studio,Gradle,我最近开始使用Android Studio,并尝试遵循“第一个应用”教程()。然而,当我在Android Studio中创建一个新项目时,我几乎立刻就遇到了这个错误 ERROR: Could not create an instance of Tooling API implementation using the specified Gradle distribution 'https://services.gradle.org/distributions/gradle-5.4.1-all.z
ERROR: Could not create an instance of Tooling API implementation using the specified Gradle distribution 'https://services.gradle.org/distributions/gradle-5.4.1-all.zip'.
在重新启动android studio之前,我尝试删除我的~/.gradle目录并使缓存无效,但这并不能解决问题。我还尝试下载gradle并使用它的本地发行版,以及使用本地版本和tradle-wrapper.properties文件中的默认gradle包装版本。我尝试了使用最新的发行版(6.0.1)和几个版本,但没有任何效果
我在Mac OS 10.13.6和Android Studio 3.5.2上运行,为我的项目使用牛轧糖发行版(API 24,Android 7.0)
编辑:当我打开事件记录器时,我看到:
11:18 Gradle sync started with single-variant sync
11:18 Gradle sync failed: ch.qos.logback.classic.Logger cannot be cast to org.gradle.api.logging.Logger (2 s 7 ms)
11:18 NDK Resolution Outcome: Project settings: Gradle model version=5.4.1, NDK version is UNKNOWN
编辑:
build.gradle文件
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "eecs285.proj4.nortoncofirstapp"
minSdkVersion 24
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}
你能在这里添加两个Gradle文件吗?请不要在注释中添加代码。您可以通过编辑上面添加的postNoted代码来添加代码。很抱歉。不,我甚至还没有开始我想做的项目。在Android Studio中启动新项目后立即发生此错误。您的系统中安装了java吗?如果是,那么安装的java版本是什么?
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}