Van*_*saF 3 java android gradle
我有一个我不明白的错误,我不知道如何解决它,尽管已经尝试了很多。错误是:
Could not find com.android.tools.build:gradle:7.6.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/7.6/gradle-7.6.pom
- https://repo.maven.apache.org/maven2/com/android/tools/build/gradle/7.6/gradle-7.6.pom
Required by:
project :
Add google Maven repository and sync project
Open File
Run Code Online (Sandbox Code Playgroud)
所以我的 Java 版本或与 build.grandle 文件的连接有问题。我有Java JDK 19。这是build.gradle文件的代码
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
def nav_version = "2.3.0"
classpath 'com.android.tools.build:gradle:7.6'
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
classpath 'com.google.gms:google-services:4.3.10'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenCentral()
maven {
url 'https://dl.google.com/android/maven2'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)
这是 gradle.wrapper-properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Run Code Online (Sandbox Code Playgroud)
根据该网站https://docs.gradle.org/current/userguide/compatibility.html,Java 19 与 gradle-7.6 兼容。所以我不明白为什么我仍然收到错误。
更新:我尝试了建议的内容,但仍然收到错误消息。这是我的文件
build.gradle(DrinkServer):
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
def nav_version = "2.3.0"
classpath ("com.android.tools.build:gradle:7.4.2")
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
classpath 'com.google.gms:google-services:4.3.10'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenCentral()
maven {
url 'https://dl.google.com/android/maven2'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)
构建.gradle(应用程序):
plugins {
id 'com.android.application'
}
apply plugin: "androidx.navigation.safeargs"
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 31
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.drinkserver"
minSdkVersion 21
targetSdkVersion 31
versionCode 1
versionName "1.1"
resConfigs "en", "de"
viewBinding {
enabled = true
}
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.navigation:navigation-runtime:2.3.5'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
def nav_version = "2.3.0"
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
testImplementation 'org.robolectric:robolectric:3.0'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'android.arch.core:core-testing:1.2.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation "androidx.recyclerview:recyclerview:1.1.0"
implementation 'androidx.cardview:cardview:1.0.0'
implementation "androidx.navigation:navigation-fragment:$nav_version"
implementation "androidx.navigation:navigation-ui:$nav_version"
implementation 'com.intuit.sdp:sdp-android:1.0.6'
implementation 'com.intuit.ssp:ssp-android:1.0.6'
implementation 'com.github.bumptech.glide:glide:4.12.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
implementation platform('com.google.firebase:firebase-bom:29.0.3')
implementation 'com.google.firebase:firebase-database'
}
gradle-wrapper. properties:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Run Code Online (Sandbox Code Playgroud)
我收到错误消息“Android Gradle 插件仅支持 Kotlin Gradle 插件版本 1.5.20 及更高版本。以下依赖项不满足所需版本:根项目 'DrinkServer' -> androidx.navigation:navigation-safe-args-gradle -plugin:2.3.0 -> org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.20 "
这有点奇怪,因为我根本不使用 Kotlin(只使用 Java)
提醒:由于我仍然遇到这个问题(尽管已经花了相当长的时间),我想提醒您这个问题。有人对为什么会发生这种情况以及如何解决这个问题有建议吗?我会很感激每一条评论。
我在发行版中看不到任何 gradle 版本 7.6。
gradle分布快照
你能改变吗
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip
Run Code Online (Sandbox Code Playgroud)
dependencies {
classpath ('com.android.tools.build:gradle:7.4.2')
}
Run Code Online (Sandbox Code Playgroud)
请将其添加到您的 build.gradle 中,确保分发 gradle url 为 7.6.1,在依赖项中为 7.4.2

| 归档时间: |
|
| 查看次数: |
8516 次 |
| 最近记录: |