Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to use Roboguice and ActionbarSherlock in one project?

I'd like to use the libraries mentioned in the title in one project.

However, both need my Activities to extend from a special Activity class: in the case of Roboguice it's RoboAcitivity, and it's FragmentActivity for ActionbarSherlock.

ActionbarSherlock extends the compatibility library, which is nice, because I also need to use fragments, and the project level s < API level 11.

Has anyone succeeded in doing this? Since Java does not support multiple inheritance (which is a good thing usually), I tried to make the FragmentActivity in the ActionbarSherlock project to extend RoboActivity instead of the standard Activity. But I can't get it to compile this way.

Part of the console output is:

[2011-10-15 17:46:31 - RetainFragmentTest2] /Users/scythe/JavaLibs/JakeWharton-ActionBarSherlock-a4855d0/library/res/values-v11/abs__styles.xml:170: error: Error: No resource found that matches the given name: attr 'android:logo'.
[2011-10-15 17:46:31 - RetainFragmentTest2] /Users/scythe/JavaLibs/JakeWharton-ActionBarSherlock-a4855d0/library/res/values-v11/abs__styles.xml:171: error: Error: No resource found that matches the given name: attr 'android:navigationMode'.
[2011-10-15 17:46:31 - RetainFragmentTest2] /Users/scythe/JavaLibs/JakeWharton-ActionBarSherlock-a4855d0/library/res/values-v11/abs__styles.xml:174: error: Error: No resource found that matches the given name: attr 'android:progressBarPadding'.
[2011-10-15 17:46:31 - RetainFragmentTest2] /Users/scythe/JavaLibs/JakeWharton-ActionBarSherlock-a4855d0/library/res/values-v11/abs__styles.xml:176: error: Error: No resource found that matches the given name: attr 'android:subtitle'.
[2011-10-15 17:46:31 - RetainFragmentTest2] /Users/scythe/JavaLibs/JakeWharton-ActionBarSherlock-a4855d0/library/res/values-v11/abs__styles.xml:177: error: Error: No resource found that matches the given name: attr 'android:subtitleTextStyle'.
[2011-10-15 17:46:31 - RetainFragmentTest2] /Users/scythe/JavaLibs/JakeWharton-ActionBarSherlock-a4855d0/library/res/values-v11/abs__styles.xml:173: error: Error: No resource found that matches the given name: attr 'android:titleTextStyle'.
like image 397
Zsombor Erdődy-Nagy Avatar asked Oct 15 '11 15:10

Zsombor Erdődy-Nagy


3 Answers

I'm sure there's a better way, but this is how I finally got ActionBarSherlock and RoboGuice working in my little app.

like image 50
Max Avatar answered Sep 24 '22 12:09

Max


I would just like to add that by 'simply' adding roboguice-sherlock to your maven pom it magicly works.

    <dependency>
        <groupId>com.github.rtyley</groupId>
        <artifactId>roboguice-sherlock</artifactId>
        <version>1.5</version>
    </dependency>
like image 38
pl3kn0r Avatar answered Sep 23 '22 12:09

pl3kn0r


Besides the issues with the compatibility library, you might also struggle with how to extend your activity both from RoboActivityand SherlockActivity - in Java, you don't have mulitple inheritance :-)

The way you solve this is by hand-crafting your own RoboSherlockActivity or use Roberto Tyley's library.

See example.

like image 43
Jörg Avatar answered Sep 22 '22 12:09

Jörg