2016-04-19 45 views
-1

I'm sorry if my question is awkward because I'm a novice programmer.在Newlly创建的Androidstudio 2.0项目中发生Junit错误

I'm sorry if my question is awkward because I'm a novice programmer.

我使用Android studio 2,gradle 2.10和Windows 10.创建新项目后,gradle开始同步项目。

同步完成后,我在设置中为Gradle启用“工作离线”模式。同步发生在我创建的每个新项目中。当我启用“脱机工作”时,在构建期间收到此错误。我应该如何解决这个问题?

错误:(23,17)无法解析:JUnit的:JUnit的:4.12

The screenshot of my build

+0

这可能是(在项目模板文件)androidstudio 2,因为我有两个单独的机器问题的错误(我的学生们太)。 – wmac

回答

2

只是删除了 “testCompile junit:junit:4.12” 从文件的build.gradle:

dependencies { 
     compile fileTree(dir: 'libs', include: ['*.jar']) 
    testCompile 'junit:junit:4.12' //remove this line and sync again... worked for me 
     compile 'com.android.support:appcompat-v7:23.3.0' 
     compile 'com.android.support:support-v4:23.3.0' 
     compile 'com.android.support:design:23.3.0' 
     } 
+0

是我为每个项目做这个吗?????????? – Pluto65

+0

@Susano Joon no只需打开build.gradle文件并根据建议更改依赖关系。 –

+0

我在将来删除代码时没有问题? – Pluto65

1

你将需要添加以下内容到你的build.gradle文件,它应该可以正常工作。

将此代码添加到build.gradle ..它将工作。

repositories { 
      maven { url 'http://repo1.maven.org/maven2' } 
      jcenter { url "http://jcenter.bintray.com/" } 
     } 

     android { 
     compileSdkVersion 23 
     buildToolsVersion "23.0.1" 

     defaultConfig { 
      applicationId "com.example.application" 
      minSdkVersion 16 
      targetSdkVersion 23 
      versionCode 1 
      versionName "3.0" 
     } 
     buildTypes { 

      release { 
       minifyEnabled false 
       proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
      } 
     } 
    } 

    dependencies { 
     compile fileTree(dir: 'libs', include: ['*.jar']) 
     testCompile 'junit:junit:4.12' 
     compile 'com.android.support:appcompat-v7:23.1.1' 
     compile 'com.android.support:design:23.1.1' 
    } 
相关问题