The brazenhead project had the android.support.v4.jar within its libs folder, even though it was not using it. This conflicted with the android.suppor.v4 that the app it was instrumenting was using. Removing this file fixed my issue.
The way brazenhead is able to instrument any apk for testing models this Robotium Wiki Page. Basically, you need these things to blackbox text any apk:
- Test apk is signed with the same keystore as the apk you are testing
- The
targetPackageproperty is the same as thepackageof the apk that you are testing
That's pretty much it. Then, to launch any activity, you basically do what that article describes:
public class BlackBoxTest extends ActivityInstrumentationTestCase2 {
@SuppressWarnings("unchecked")
public ReallyBlackboxTest() throws ClassNotFoundException {
super(Class.forName("com.full.path.to.SomeActivity"));
}
...
}The GitHub AndroidManifest.xml is setup like this:
<activity
android:name=".ui.user.HomeActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:hardwareAccelerated="true" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data
android:name="android.app.default_searchable"
android:value=".ui.search.SearchActivity" />
</activity>However, when I try to launch com.github.mobile.ui.user.HomeActivity, in logcat I get a ClassNotFoundException. The odd thing is, if I launch com.github.mobile.accounts.LoginActivity, that loads fine. I'm not sure what the difference is. Please let me know if I can provide more information.
I found a portion in logcat that looks suspect:
W/dalvikvm: Class resolved by unexpected DEX: Landroid/support/v4/app/_ActionBarSherlockTrojanHorse;(0xb505c4b0):0xace77000 ref [Landroid/support/v4/app/FragmentActivity;] Landroid/support/v4/app/FragmentActivity;(0xb505c4b0):0xad049000
W/dalvikvm: (Landroid/support/v4/app/_ActionBarSherlockTrojanHorse; had used a different Landroid/support/v4/app/FragmentActivity; during pre-verification)
W/dalvikvm: Unable to resolve superclass of Landroid/support/v4/app/_ActionBarSherlockTrojanHorse; (156)
W/dalvikvm: Link of class 'Landroid/support/v4/app/_ActionBarSherlockTrojanHorse;' failed
W/dalvikvm: Unable to resolve superclass of Lcom/actionbarsherlock/app/SherlockFragmentActivity; (183)
W/dalvikvm: Link of class 'Lcom/actionbarsherlock/app/SherlockFragmentActivity;' failed
W/dalvikvm: Unable to resolve superclass of Lcom/github/rtyley/android/sherlock/roboguice/activity/RoboSherlockFragmentActivity; (422)
W/dalvikvm: Link of class 'Lcom/github/rtyley/android/sherlock/roboguice/activity/RoboSherlockFragmentActivity;' failed
W/dalvikvm: Unable to resolve superclass of Lcom/github/mobile/ui/DialogFragmentActivity; (1015)
W/dalvikvm: Link of class 'Lcom/github/mobile/ui/DialogFragmentActivity;' failed
W/dalvikvm: Unable to resolve superclass of Lcom/github/mobile/ui/PagerActivity; (736)
W/dalvikvm: Link of class 'Lcom/github/mobile/ui/PagerActivity;' failed
W/dalvikvm: Unable to resolve superclass of Lcom/github/mobile/ui/TabPagerActivity; (755)
W/dalvikvm: Link of class 'Lcom/github/mobile/ui/TabPagerActivity;' failed
W/dalvikvm: Unable to resolve superclass of Lcom/github/mobile/ui/user/HomeActivity; (761)
W/dalvikvm: Link of class 'Lcom/github/mobile/ui/user/HomeActivity;' failed
The classes that are Unable to resolve superclass ultimately derive from DialogFragment. I wonder if that has something to do with it?