0

我更新了 Android Studio 并创建了一个新项目。我正在使用来自 GitHub 的一些依赖项,但现在同步后,我收到了这个警告。如果我忽略它,将不会安装该应用程序。 在此处输入图像描述

项目级 build.gradle

buildscript {
    ext {
        compose_version = '1.6.10'
    }
    dependencies {
        classpath 'com.google.gms:google-services:4.3.10'
        classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10'
    }
}

plugins {
    id 'com.android.application' version '7.1.0' apply false
    id 'com.android.library' version '7.1.0' apply false
    id 'org.jetbrains.kotlin.android' version '1.5.31' apply false
}

allprojects {
    repositories {
        google()
        maven { url 'https://jitpack.io' }
        maven {
            url "https://maven.google.com"
        }
//        mavenCentral()
        maven { url 'https://github.com/leonardocardoso/mvn-repo/raw/master/maven-deploy' }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

应用级 build.gradle

plugins {
    id 'com.android.application'
}

android {
    compileSdk 31

    buildFeatures {
        dataBinding true
    }

    defaultConfig {
        applicationId "com.eg.eg"
        minSdk 21
        targetSdk 31
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        vectorDrawables.useSupportLibrary = 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.appcompat:appcompat:1.4.1'
    implementation 'com.google.android.material:material:1.5.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$compose_version"
    implementation 'com.github.scottyab:showhidepasswordedittext:0.8'

}

设置.gradle

import org.gradle.api.initialization.resolve.RepositoriesMode

pluginManagement {
    repositories {
        gradlePluginPortal()
        google()
        mavenCentral()

    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
    repositories {
        google()
        mavenCentral()

    }
}
rootProject.name = "MyPro_v02"
include ':app'

如何在 Android Studio 最新版本 BumbleBee 中解决此问题?

4

1 回答 1

2

对于在 Android Studio Bumblebee 中创建的较新的 Android Studio 项目 | 2021.1.1或更高版本,需要将JitPack存储库添加到根级文件中settings.gradle instead of build.gradle:

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
      // ...
        maven { url 'https://jitpack.io' }
    }
}
于 2022-02-06T04:51:18.927 回答