2

Try to begin with ActionBarSherlock. Download library. Set ADT with last updates, SDK the same.

Try to make simple activity:

import com.actionbarsherlock.app.SherlockActivity;
import android.os.Bundle;

public class MainActivity extends SherlockActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

The manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="ru.alxr.usingsherlocksample"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="17" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/Sherlock.__Theme" >
    <activity
        android:name="ru.alxr.usingsherlocksample.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
  </application>

 </manifest>

ADT does not let to set android:theme="@style/Sherlock" with red x.

So, I got expexcted error in logcat:

03-23 21:25:54.437: E/AndroidRuntime(13145): FATAL EXCEPTION: main
03-23 21:25:54.437: E/AndroidRuntime(13145): java.lang.RuntimeException: Unable to start activity ComponentInfo{ru.alxr.usingsherlocksample/ru.alxr.usingsherlocksample.MainActivity}: java.lang.IllegalStateException: You must use Theme.Sherlock, Theme.Sherlock.Light, Theme.Sherlock.Light.DarkActionBar, or a derivative.
03-23 21:25:54.437: E/AndroidRuntime(13145):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
03-23 21:25:54.437: E/AndroidRuntime(13145):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
03-23 21:25:54.437: E/AndroidRuntime(13145):    at android.app.ActivityThread.access$1500(ActivityThread.java:117)
03-23 21:25:54.437: E/AndroidRuntime(13145):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
03-23 21:25:54.437: E/AndroidRuntime(13145):    at android.os.Handler.dispatchMessage(Handler.java:99)
03-23 21:25:54.437: E/AndroidRuntime(13145):    at android.os.Looper.loop(Looper.java:130)
03-23 21:25:54.437: E/AndroidRuntime(13145):    at android.app.ActivityThread.main(ActivityThread.java:3687)
03-23 21:25:54.437: E/AndroidRuntime(13145):    at java.lang.reflect.Method.invokeNative(Native Method)
03-23 21:25:54.437: E/AndroidRuntime(13145):    at java.lang.reflect.Method.invoke(Method.java:507)
03-23 21:25:54.437: E/AndroidRuntime(13145):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
03-23 21:25:54.437: E/AndroidRuntime(13145):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
03-23 21:25:54.437: E/AndroidRuntime(13145):    at dalvik.system.NativeStart.main(Native Method)
03-23 21:25:54.437: E/AndroidRuntime(13145): Caused by: java.lang.IllegalStateException: You must use Theme.Sherlock, Theme.Sherlock.Light, Theme.Sherlock.Light.DarkActionBar, or a derivative.
03-23 21:25:54.437: E/AndroidRuntime(13145):    at com.actionbarsherlock.internal.ActionBarSherlockCompat.generateLayout(ActionBarSherlockCompat.java:1003)
03-23 21:25:54.437: E/AndroidRuntime(13145):    at com.actionbarsherlock.internal.ActionBarSherlockCompat.installDecor(ActionBarSherlockCompat.java:915)
03-23 21:25:54.437: E/AndroidRuntime(13145):    at com.actionbarsherlock.internal.ActionBarSherlockCompat.setContentView(ActionBarSherlockCompat.java:849)
03-23 21:25:54.437: E/AndroidRuntime(13145):    at com.actionbarsherlock.app.SherlockActivity.setContentView(SherlockActivity.java:229)
03-23 21:25:54.437: E/AndroidRuntime(13145):    at ru.alxr.usingsherlocksample.MainActivity.onCreate(MainActivity.java:13)
03-23 21:25:54.437: E/AndroidRuntime(13145):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-23 21:25:54.437: E/AndroidRuntime(13145):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
03-23 21:25:54.437: E/AndroidRuntime(13145):    ... 11 more

What to do?

Aleksandr
  • 737
  • 4
  • 22

2 Answers2

7

In your manifest replace:

android:theme="@style/Sherlock.__Theme"

With:

android:theme="@style/Theme.Sherlock"

Or any other valid theme, for example:

android:theme="@style/Theme.Sherlock.Light"
android:theme="@style/Theme.Sherlock.Light.DarkActionBar"
Andres
  • 5,544
  • 10
  • 55
  • 102
  • as I mentioned ADT makes red x when I try to write "Theme.Sherlock" – Aleksandr Mar 23 '13 at 15:06
  • How you added the ActionSherlock library to your project? Do you create a library project and then add it to your project? Here is described how to use a project as a library as you should do with ActionSherlock library: http://stackoverflow.com/questions/8248196/how-to-add-a-library-project-to-a-android-project – Andres Mar 23 '13 at 15:09
  • I made everything via this tutorial http://actionbarsherlock.com/faq.html http://www.youtube.com/watch?feature=player_embedded&v=4GJ6yY1lNNY – Aleksandr Mar 23 '13 at 15:11
  • I made library project. Then made sample code project and add link to library in Project properties -> Android -> Add... – Aleksandr Mar 23 '13 at 15:20
  • Is the ActionBar folder from where you created the library project in the same workspace folder as your main project? – Andres Mar 23 '13 at 15:23
  • yes. workspase is \workspace ; library root is \workspace\JakeWharton-ActionBarSherlock-e5c2d1c\library ; my project is \workspace\UsingSherlockSample – Aleksandr Mar 23 '13 at 15:28
  • Pretty weird I had this issue once. Try cleaning your main project, updating ADT and SDK Manager and also try setting you library project to Android 4.1.2 or higher instead of Android 4.0 (right click on the library project -> properties -> Android and there set to Android 4.1.2 API 16) – Andres Mar 23 '13 at 15:33
  • Everything updated. Cleaned a lot of times. For both projects (lib & app) I set Android 4.2.2. Nothing helps. – Aleksandr Mar 23 '13 at 15:44
  • No more ideas :/ Try to set the theme inside your onCreate() method on this way: if (Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH){ this.setTheme(com.actionbarsherlock.R.style.Theme_Sherlock); } And remove android:theme="@style/Sherlock.__Theme" from your manifest. – Andres Mar 23 '13 at 16:02
  • This way is not good. My target is make working project like in tutorial. – Aleksandr Mar 23 '13 at 17:52
  • Yeah I know, is a workaround until someone can give you an answer, it'es pretty weird because I have it perfectly working on that way. Do you have any errors in the Error Log View of Eclipse? – Andres Mar 23 '13 at 18:39
  • I just downloaded new one ADT 32-bit to the new folder, update it to Build: v21.1.0-569685, then updete SDK. Made new lib project in new workplace, made new project to use lib. And got the same ... situation. – Aleksandr Mar 23 '13 at 19:19
  • Looks like it finally helps. Last comment was from tired me. So, I can accept that solution was 32bit ADT. – Aleksandr Mar 24 '13 at 05:07
0

Solution was to install 32bit ADT instead 64 bit one.

Aleksandr
  • 737
  • 4
  • 22