gpt4 book ai didi

Android studio - gradle 无法解析依赖项

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:19:24 25 4
gpt4 key购买 nike

我已经在我的系统中安装了 Android Studio 版本 2.1.2,如果我在 Gradle 文件中添加任何依赖项,那么我无法解决错误

It happen the all the libraries likes Picasso not only for Junit

所以我尝试在gradle.properties 文件中添加代理设置

systemProp.http.proxyHost=http://xxxx/xxx
systemProp.http.proxyPort=80
systemProp.https.proxyHost=http://xxxx/xxx
systemProp.https.proxyPort=80

但我收到以下错误:

Error:A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
> Could not resolve junit:junit:4.12.
Required by:
MyApplication2:app:unspecified
> Could not resolve junit:junit:4.12.
> Could not get resource 'https://jcenter.bintray.com/junit/junit/4.12/junit-4.12.pom'.
> Could not GET 'https://jcenter.bintray.com/junit/junit/4.12/junit-4.12.pom'.
> http://xxxx/xxx

如何解决这个问题,请帮忙解决。

build.gradle 文件:

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "24.0.0"

defaultConfig {
applicationId "com.example.muraliathmarao.myapplication"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
}

最佳答案

您需要在主 build.gradle 的末尾添加一个部分 allprojects 来定义项目模块的存储库:

allprojects {
repositories {
jcenter()
}
}

这是build.gradle(项目)

buildscript {
repositories {
jcenter()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
jcenter()
mavenCentral()
}
}

关于Android studio - gradle 无法解析依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38502427/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com