2016-04-19 49 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' 
    } 
相關問題