1

我想爲我的應用程序設置一個Instrumented Unit Tests。並且我已經添加了基於以下開發者網站鏈接的依賴關係。與依賴衝突'com.android.support:support-annotations'

https://developer.android.com/training/testing/unit-testing/instrumented-unit-tests.html#build

這是我的依賴列表

dependencies { 
    compile 'com.android.support:multidex:1.0.1' 
    compile 'com.android.support:support-v4:21.0.3' 
    testCompile 'junit:junit:4.12' 
    testCompile 'org.mockito:mockito-core:1.10.19' 
    androidTestCompile 'com.android.support:support-annotations:24.0.0' 
    androidTestCompile 'com.android.support.test:runner:0.5' 
    androidTestCompile 'com.android.support.test:rules:0.5' 
} 

當我建立我得到下面的編譯錯誤的項目:

Error:Conflict with dependency 'com.android.support:support-annotations' in project ':MyApp'. Resolved versions for the app (21.0.3) and test app (24.0.0) differ. See http://g.co/androidstudio/app-test-app-conflict for details. 

任何人都可以請幫我解決這個問題。

回答

3

註解是支持庫的一部分。所以,你的註釋和支持庫的版本應該是相同的,你必須使用下面的代碼強行調用。這代碼應該放在上面dependencies.For詳細 See here

configurations.all { 
    resolutionStrategy { 
    force 'com.android.support:support-annotations:21.0.3' 
    } 
} 
+0

我已經更改爲21.0.3,現在我獲取此錯誤錯誤:與項目':MyApp'中的依賴項'com.android.support:support-annotations'衝突。應用程序(21.0.3)和測試應用程序(23.1.1)的已解決版本不同。有關詳細信息,請參閱http://g.co/androidstudio/app-test-app-conflict。 – Vji

+0

謝謝Priya ... – Vji

+0

歡迎光臨:) –