1

I have a Android Maven project and am having difficulties to maintain compatibility using ActionBar.

Before I was using ActionBarSherlock, but I saw that Google released the v7 support library would have the same goal. I decided to remove the dependence of ActionBarSherlock and use v7. I've tried several ways:

  • 1 - Import the folder "android-sdk\extras\android\support\v7\appcompat" as a "Existing Android Code into Workspace" on Eclipse IDE and registered him as Library. But the project stopped identifying the classes generated by the framework AndroidAnnotations. For example LoginActivity_
  • 2 - Adding maven appcompat-v7 dependency using the repository showing this question. But I could not make the project compile, even trying different configurations of dependence.

Has anyone set up an android project with library support v7 using Maven? Could you help me please?

Community
  • 1
  • 1
falvojr
  • 3,060
  • 4
  • 31
  • 54

1 Answers1

3

Implement ActionBar in 2.2 device and other Functionlity like ViewPager,Framgmet Tag in 2.2 then there is two way using sherlockActionbar and AppCompat

Sherlock is and third party library while AppCompat is Android library.
step to use AppCompact in project

just update android skd-> extra-> Android support library
Then goto you sdk in your system-> Androidsdk\extras\android\support\v7 find appcompat source code. Import this appcompact in you eclipse.
Create you project and select appcompact library from property->android-> Library.
open you manifeast file and change theme **android:theme="@style/Theme.AppCompat.Light**" Then extend your activity with ActionBarActivity if you cannot found it then pls manualy import `

 import android.support.v7.app.ActionBar;
 import android.support.v7.app.ActionBar.Tab;
 import android.support.v7.app.ActionBarActivity;`

Then Add below code to activity

final ActionBar actionBar = getSupportActionBar();
actionBar.setHomeButtonEnabled(false);
PankajAndroid
  • 2,689
  • 3
  • 27
  • 41
  • Thanks for answering! I followed your instructions and also leaned on the [Android](http://developer.android.com/tools/support-library/setup.html#) documentation and now I have the following problem: `java.lang.RuntimeException: Unable to start activity ComponentInfo{com.msplearning.android.app/com.msplearning.android.app.LoginActivity_}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.` – falvojr Mar 22 '14 at 19:36
  • It is easy to see that the problem is related to the theme applied to the application. But I believe I'm doing this correctly, see my style.xml content: `` and ``. And in the file AndroidManifest.xml I relate the Theme to my App: `android:theme="@style/AppTheme"` – falvojr Mar 22 '14 at 19:39
  • Hello @PankajAndroid! I solved the problem mentioned in the above comments. The styles of folders `values-v11` and `values-v14` were overwriting the style.xml ​​of the `values` folder. To fix I had to specify the parent attribute to `@style/Theme.Base.AppCompat.Light` in 3 files style.xml. This problem was solved, but now I'm not but managing to build via Maven ... – falvojr Mar 23 '14 at 14:49