I'm trying to use the SlideMenu library with ActionBarSherlock.
https://github.com/jfeinstein10/SlidingMenu
http://actionbarsherlock.com/
I had not issue installing actionbarsherlock and run the examples provided.
But, can't do the same with the example og the SlideMenu library :(
I can set up the library fine (or so i think) without errors (under eclipse with jre6).
For the slidemenu example, i created the project, and added com_actionbarssherlock.jar as a "referenced libraies".
But i have lots of :
- R cannot resolve erros ;
- can't overrides some methods erros;
- methods from actionbarsherlock are not recognized ; ex : "The method getSupportActionBar() is undefined for the type BaseActivity"
- can't load style from actionbarsherlock erros.
It is as if the project doesn't see the classes from actionbarsherlock.
Thanks for any help.
For the error
"The method getSupportActionBar() is undefined for the type BaseActivity"
Inside the SlidingMenu library, edit the class SlidingFragmentActivity to extend SherlockFragmentActivity (like below). Then clean and rebuild, this method should now be found.
public class SlidingFragmentActivity extends SherlockFragmentActivity implements SlidingActivityBase {
Source
Look add Problems tab to see there are any error ?
Right click your project and check your all Libraries.
If everthing ok, try to clean your project.
There are lots of issues on github with that bug. Mrcb123's solution works, but I suppose it will be good to separate example ABS dependency from library.
Related
My Current Situation
I am working on an existing app that is using CustomFragment derived from android.app.Fragment. I want to add a new functionnality with a ViewPager which will show my CustomFragments. For that I need to use a FragmentPagerAdapter.
Oooh snap !
Here I am, importing android.support.v4.view.ViewPager and android.support.v4.app.FragmentPagerAdapter to achieve my goal. And now the funny part begins :
When I try to use my FragmentPagerAdapter with my CustomFragment, I get the classic error Type mismatch: cannot convert from android.app.Fragment to android.support.v4.app.Fragment
Knowing that I can't change the whole app fragments to android.support.v4.app.Fragment, I searched and found that the android.support.v13.app.FragmentPagerAdapter was made to use native fragments. Great !
Not great. When I try to import the v13 FragmentPagerAdapter, I get the error The import android.support.v13 cannot be resolved. For the record, I checked in SDKManager what support version is installed : v19.0.1
I searched again, because of course I can't be the first one with that problem. I found that you can't use support.v4 and support.v13 in the same app because v4 is included in v13. And for everyone that encoutered my problem, the solution was to use only android.support.v4.app.FragmentPagerAdapter and android.support.v4.app.Fragment
What to do now ?
Since I have to use android.app.Fragment and I can't use only support.v4, I don't know where to go search next. Any help would be highly appreciated !
Well that is simply not possible. I went to use support.v4.app.Fragment.
So I have just started running through the tutorial located here
Even though it starts off easily enough, with everything being described, the second chapter rushes you through action bars.
I have managed to import appCompat; which was located at C:\Users\New\Desktop\Programmin' languages\Android dev\adt-bundle-windows-x86_64-20130522\eclipse\sdk\extras\android\support\v7\appcompat - for me.
After importing appCompat I referenced it by going to properties>android and then the adding it to libraries.
What is confusing me is that the compiler allows me to write
public class DisplayMessageActivity extends ActionBarActivity {
without any errors; though I have referenced
android:support:v7:app:ActionBarActivity
so I didn't think that would give me an error.
Errors are coming from things like action_search (which I'll assume is a referenced xml) and openSearch() (a referenced class) - in my java activities
and #drawable/tab_unselected - which is located in my drawable-hdpi (under res).
I'm assuming that the person who wrote the tutorial presumed that my project would get these resources from the appCompat directory, but for some reason it isn't.
Please help, because the next chapter just goes on to describe how to develop new things - without addressing issues that could arise first.
Please see here on how to properly include the appcompat libraries in your Android project.
I was trying the sample roboguice project in ActionBarSherlock library. It uses roboguice2.0b4.jar (a beta release) but when i replace it with the stable release roboguice2.0.jar I am getting
java.lang.IllegalArgumentException: com.actionbarsherlock.sample.roboguice.activity.AstroboyMasterConsole#40533b68 does not appear to be a RoboGuice context (instanceof RoboContext)
what can be done to resolve this issue.
Your activity (AstroboyMasterConsole) must implement the RoboContext interface, means you have to extend it from one of the classes below:
I am using Eclipse Indigo for Android development. The problem i face is that it does not allow #Override for non Activity overwritten methods. For example if i implement onErrorListner of MediaPlayer and i set attribute #Override with it then it gives the following compile time error:
The method onError(MediaPlayer, int, int) of type MyActivity must override a superclass method
And to fix this problem, i am suggested the following
Remove "#Override" annotation
Tough removing the #Override fixes the issue but why does it complain about it and also removing it may cause stopping some functionality of its parent etc??
I have downloaded many examples which use this "#Override" attribute with non-activity methods which proves that this is used and i might be missing some obvious thing. But i cannot run these examples in Eclipse Indigo without removing these "#Override" attributes from all the classes.
Why?
Any help is greatly appreciated.
Your project Java compiler level is set to 1.5 instead of 1.6. See here.
It is not good to remove that line. you need to change to JDK version in your eclipse then you will not get such errors. Follow, following steps for it,
Right Click on your Project & select Properties.
Then from the left section Select Java Compiler & select the Version of the JDK you installed. If it is already selected then de-select it & try it.
I'm making a paid/free version of my app so have a 'Library Project' that the two apps use.
I'm trying to use Android Annotations to clean up my code:
http://code.google.com/p/androidannotations/
Unfortunately when I use this in my shared library project, one of my projects gets the error in Eclipse:
The type xActivity_ is already defined xActivity_.java /ProjectName/.apt_generated/lib/activities/
Because Android Annotations automatically creates a new activity with an extra '_' in the folder .apt_generated one of the apps is allowed to create this file, but the other gets the error "already defined".
Is there a way in Eclipse to resolve this? Or is it a problem with the Android Annotations?
This seems to be an AndroidAnnotations bug, and should be reported on the dedicated bug tracker.
AndroidAnnotations wasn't designed with this use case in mind, but this is still a very valid use case. The problem seems to be that the activity is generated in the shared library project, when it should be generated in each depending project, am I right ?
(please answer in the bug tracker)
This question is quite old, but I thought that I should mention android annotations now supports being used in libaries:
https://github.com/excilys/androidannotations/wiki/Library-projects
One caveat is that due to the way android library projects generate the R class, you cannot reference resouces directly inside the annotations. Eg, you cant do this:
#EActivity(R.layout.myLayout)
public class MyActivity extends Activity {
#Click(R.id.myButton1, R.id.myButton2})
public void someButtonClicked() {
}
}
Instead you must do this:
#EActivity(resName="myLayout")
public class MyActivity extends Activity {
#Click(resName={"myButton1", "myButton2"})
public void someButtonClicked() {
}
}
I just knew AndroidAnnotations (which seems a great tool!) but I think that if you do this using different projects (sharing the same library) your problem should be solved.