package org.powermock.api.easymock does not exist using gradle

4.3k views Asked by At

Using gradle with android.

I am trying to get powermock to compile as a dependency.

I have dumbed down my attempts to get this working and it is still not working. Below is my build.gradle and activity. I am just doing it this way to demonstrate the error and trying to get it working.


//Error
error: package org.powermock.api.easymock does not exist
import org.powermock.api.easymock.PowerMock;

//build.gradle
apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "22.0.0"

    defaultConfig {
        applicationId "android.testing.powermock"
        minSdkVersion 19
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.0.0'
    compile 'org.easymock:easymock:3.3.1'
    compile 'org.powermock:powermock-easymock-release-full:1.6.2'
}

//MainActivity
package android.testing.powermock;

import org.powermock.api.easymock.PowerMock;

public class MainActivity extends Activity {
    //not important
}
1

There are 1 answers

0
tomrozb On BEST ANSWER

Add this dependency to your build.gradle

testCompile 'org.powermock:powermock-api-easymock:1.6.2'

If you're using it outside of the test classes change the testCompile to compile.