Android Studio BumbleBee, Maven()

3
我更新了Android Studio并创建了一个新项目。 我正在使用来自GitHub的一些依赖项,但是在同步后,我收到了这个警告。如果我忽略它,应用程序将无法安装。 enter image description here 项目级别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'

}

settings.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 中解决此问题?
2个回答

14

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

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
      // ...
        maven { url 'https://jitpack.io' }
    }
}

2
谢谢!我花了大约两个小时才到这里。 - ingyesid
被低估的答案。+1000 - edgar_wideman

1
在你的settings.gradle文件中添加这行代码(蜜蜂版本), 在添加完这行代码后重新构建项目即可:
 jcenter()
 maven { url "https://jitpack.io" }

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接