无法在ubuntu上的android studio 1.4中解析:junit:junit:4.12
当我在ubuntu上的android studio 1.4中创建新项目时 当gradle在上完成同步时,我收到此错误无法在ubuntu上的android studio 1.4中解析:junit:junit:4.12,android,ubuntu,android-studio,Android,Ubuntu,Android Studio,当我在ubuntu上的android studio 1.4中创建新项目时 当gradle在上完成同步时,我收到此错误 testCompile 'junit:junit:4.12' 在app/build.gradle上显示消息 Error:(23, 17) Failed to resolve: junit:junit:4.12 Show in File Show in Project Structure dialog //构建渐变(应用程序模块) //建筑梯度(项目) //顶级生成文件,您可
testCompile 'junit:junit:4.12'
在app/build.gradle上显示消息
Error:(23, 17) Failed to resolve: junit:junit:4.12
Show in File
Show in Project Structure dialog
//构建渐变(应用程序模块)
//建筑梯度(项目)
//顶级生成文件,您可以在其中添加所有子项目/模块通用的配置选项
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
- 我试过了
dependencies
{
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12' //remove this line from here
compile 'com.android.support:appcompat-v7:23.0.1'
}
有些人通过在下面添加存储库缺少URL的块来解决这个问题
android {
.....
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
.....
}
请注意:右键单击“应用程序”文件夹并转到“打开模块设置”。然后移动到最后一个选项卡“Dependencies”,并通过搜索重新添加junit。我尝试添加早期版本,但未能使其正常工作。在我的情况下,我使用了一个代理,问题已得到解决 两者兼用
jcenter {
url "http://jcenter.bintray.com/"
}
及
如果您使用的是OpenJDK8,则可能是因为cacerts存在错误。 也许您可以尝试以下方法来修复损坏的卡塞特:
$ sudo dpkg --purge --force-depends ca-certificates-java
$ sudo apt-get install ca-certificates-java
我尝试将我的jcenter()更改为带有url的,也尝试将其更改为maven{url…},但两种方法都不起作用。
这个给我修好了
见:
如果您正面临问题junit:junit4.12。这就是解决方案
repositories {
maven { url 'http://repo1.maven.org/maven2' }
jcenter { url "http://jcenter.bintray.com/" }
}
将这些添加到后面的两行之上
apply plugin: 'com.android.application'
是的,我知道,但我为什么要删除它?那么如果我想测试呢?我严重怀疑这是一个解决方案。一种猜测是,它使用的是JUnit3方法,应该包含在android.jar中(例如在Api 19中),而不需要JUnit4.x。或者更新的android API甚至有JUnit4。我可以验证这个补丁在Ubuntu15.10和Java8下工作(来自webupd8team)。
repositories {
maven { url 'http://repo1.maven.org/maven2' }
jcenter { url "http://jcenter.bintray.com/" }
}
apply plugin: 'com.android.application'