I would like to test an activity from an other apk, and this test extends ActivityInstrumentationTestCase2 (http://developer.android.com/reference/android/test/ActivityInstrumentationTestCase2.html) because I will need to get the Activity and Instrumentation.
I try to use a DexClassLoader like this:
public MainActivityTest() throws ClassNotFoundException{
super((new DexClassLoader(
"/data/app/my-application.apk", "/data/app/my-application",null, MainActivityTest.class.getClassLoader())).loadClass("my-application.MainActivity")))}
But I get as result an Exception: optimizedDirectory not readable/writable: /data/data/valentin.myapplication2
Is there a solution to do it?
I need the activity because i use this after: activity.getWindow().getDecorView()
FYI:
@Before
public void setUp() throws Exception {
super.setUp();
injectInstrumentation(InstrumentationRegistry.getInstrumentation());
mActivity = getActivity();
}
@Test
public void testRecorder(){
new ActivityListener(InstrumentationRegistry.getInstrumentation(),mActivity,12).start();
while(true){
}
}