Gradle Android Could not find testPackage () method

I have a project using Gradle. Now I am trying to add our tests to the assembly. I'm not quite sure how this works, or what actall syntax will use.

Here is the build script for the test application I'm trying to get. My tests are in the src / instrumentTest / java directory.

buildscript { repositories { maven { url 'http://repo1.maven.org/maven2' } } dependencies { classpath 'com.android.tools.build:gradle:0.4' } } apply plugin: 'android' dependencies { compile files('libs/android-support-v4.jar') } android { compileSdkVersion 17 buildToolsVersion "17.0.0" defaultConfig { minSdkVersion 8 targetSdkVersion 16 testPackage "com.example.myapplication.test" testInstrumentationRunner "android.test.InstrumentationTestRunner" } } 

When I build, I get the following error.

FAILURE: build failed with exception.

  • Where: Create the file '/Users/kbrown/AndroidStudioProjects/MyApplicationProject/MyApplication/build.gradle': 22

  • What went wrong: There was a problem evaluating the MyApplication project.

    Could not find testPackage () method for [com.example.myapplication.test] arguments in ProductFlavorDsl_Decorated {name = main, minSdkVersion = 8, targetSdkVersion = 16, renderscriptTargetApi = -1, versionCode = -1, versionName = null, packageName = null , testPackageName = null, testInstrumentationRunner = null, signedConfig = null}.

+4
source share
3 answers

The property name for setting the package name of the test application is "testPackageName", not "testPackage".

Please note that you do not have to provide this, it is automatically calculated based on the name of the tested application by default.

The same thing with the toolkit class toolkit, setting it to the default runner has no effect.

+5
source

Different attribute names have been changed in Gradle version 1.0

"testPackageName" is also replaced by "testApplicationId"

Further information can be found in Migrating Gradle Projects in Version 1.0.0

+14
source

If you have some problems now, see this question.

+4
source

Source: https://habr.com/ru/post/1484914/


All Articles