Reputation: 11
I created a simple project to launch facebook app on emulator. When the program is run the following error is displayed Test run failed: Instrumentation run failed due to 'java.lang.ClassNotFoundException
The code is fb.java file
package com.facebook.katana;
import junit.framework.Assert;
import com.jayway.android.robotium.solo.Solo;
//import junit.framework.Assert;
import android.test.ActivityInstrumentationTestCase2;
@SuppressWarnings("rawtypes")
public class fb extends ActivityInstrumentationTestCase2{
private Solo solo;
private static final String TARGET_PACKAGE_ID ="com.facebook.katana";
private static final String LAUNCHER_ACTIVITY_FULL_CLASSNAME = "com.facebook.katana.LoginActivity";
private static Class<?> launcherActivityClass;
static{
try{
launcherActivityClass = Class.forName(LAUNCHER_ACTIVITY_FULL_CLASSNAME);
} catch(ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
@SuppressWarnings({ "unchecked", "deprecation" })
public fb() {
super(TARGET_PACKAGE_ID, launcherActivityClass);
// TODO Auto-generated constructor stub
}
@Override
protected void setUp() throws Exception{
solo = new Solo(getInstrumentation(), getActivity());
}
public void testCanOpenSettings() throws InterruptedException{
// wait for the specified time
solo.sleep(3000);
solo.clearEditText(0);
solo.enterText(0, "abc@abc");
// wait for the specified time
solo.sleep(3000);
solo.enterText(1, "acd");
solo.sleep(3000);
}
private boolean assertTrue(Object clickOnImage) {
// TODO Auto-generated method stub
return false;
}
@Override
public void tearDown() throws Exception{
try{
solo.finalize();
} catch(Throwable e) {
e.printStackTrace();
}
getActivity().finish();
super.tearDown();
}
}
The manifest. xml file (FB2 Manifest.xml)
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.facebook.katana.test"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="18" />
<instrumentation
android:name="android.test.InstrumentationTestRunner"
android:targetPackage="com.facebook.katana" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<uses-library android:name="android.test.runner" />
</application>
</manifest>
Please help in resolving this issue
Upvotes: 0
Views: 5801
Reputation: 11
The LAUNCHER ACTIVITY FULL CLASS NAME specified was incorrect. Once this was set to the correct activity name, the program execution was successful.
Upvotes: 1