DBedrenko
DBedrenko

Reputation: 5029

How to add Android Studio plugin as dependency in Gradle?

I installed the TestNG plugin through Android Studio. On my filesystem the following files were installed:

C:\Program Files\Android\Android Studio\plugins\testng\lib\testng.jar
C:\Program Files\Android\Android Studio\plugins\testng\lib\testng-plugin.jar
C:\Program Files\Android\Android Studio\plugins\testng\lib\resources_en.jar
C:\Program Files\Android\Android Studio\gradle\gradle-2.2.1\lib\plugins\testng-6.3.1.jar

I added the the TestNG dependency to the build.gradle of my Module--not "Project":

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.2.0'
    testCompile 'testng:testng:6.3.1' // Added this line
}

But Gradle couldn't find the library:

Error:Gradle: A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugUnitTestCompile'.
   > Could not find testng:testng:6.3.1.
     Searched in the following locations:
         https://jcenter.bintray.com/testng/testng/6.3.1/testng-6.3.1.pom
         https://jcenter.bintray.com/testng/testng/6.3.1/testng-6.3.1.jar
         file:/C:/Users/UserFoo/AppData/Local/Android/sdk/extras/android/m2repository/testng/testng/6.3.1/testng-6.3.1.pom
         file:/C:/Users/UserFoo/AppData/Local/Android/sdk/extras/android/m2repository/testng/testng/6.3.1/testng-6.3.1.jar
         file:/C:/Users/UserFoo/AppData/Local/Android/sdk/extras/google/m2repository/testng/testng/6.3.1/testng-6.3.1.pom
         file:/C:/Users/UserFoo/AppData/Local/Android/sdk/extras/google/m2repository/testng/testng/6.3.1/testng-6.3.1.jar
     Required by:
         MyBlackjack2:app:unspecified

How do I add TestNG to the search path? On the other hand, Android Studio installed the plugin in that location for a reason, but what's the best way to include it in my project?

Upvotes: 0

Views: 1263

Answers (1)

Cedric Beust
Cedric Beust

Reputation: 15608

Use TestNG 6.9.4, which is distributed on both JCenter and Maven (6.3.1 is on Maven Central only, which you don't seem to have in your repositories list).

Upvotes: 1

Related Questions