Reputation: 169
I have an error catch when I extend ActionBarActivity
. If I extend Activity
there is no errors.
The thing is in my other activities it works perfectly. At first, I thought it's was because my previous activity put extras in the intent. But even without it the app crash.
Here is my code :
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
public class FullscreenActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fullscreen);
}
}
EDIT : and the result of logs :
09-21 18:21:39.413: E/AndroidRuntime(26944): FATAL EXCEPTION: main
09-21 18:21:39.413: E/AndroidRuntime(26944): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.testlfm/com.example.testlfm.FullscreenActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
09-21 18:21:39.413: E/AndroidRuntime(26944): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2308)
09-21 18:21:39.413: E/AndroidRuntime(26944): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2358)
09-21 18:21:39.413: E/AndroidRuntime(26944): at android.app.ActivityThread.access$600(ActivityThread.java:153)
09-21 18:21:39.413: E/AndroidRuntime(26944): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1247)
09-21 18:21:39.413: E/AndroidRuntime(26944): at android.os.Handler.dispatchMessage(Handler.java:99)
09-21 18:21:39.413: E/AndroidRuntime(26944): at android.os.Looper.loop(Looper.java:137)
09-21 18:21:39.413: E/AndroidRuntime(26944): at android.app.ActivityThread.main(ActivityThread.java:5227)
09-21 18:21:39.413: E/AndroidRuntime(26944): at java.lang.reflect.Method.invokeNative(Native Method)
09-21 18:21:39.413: E/AndroidRuntime(26944): at java.lang.reflect.Method.invoke(Method.java:511)
09-21 18:21:39.413: E/AndroidRuntime(26944): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
09-21 18:21:39.413: E/AndroidRuntime(26944): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
09-21 18:21:39.413: E/AndroidRuntime(26944): at dalvik.system.NativeStart.main(Native Method)
09-21 18:21:39.413: E/AndroidRuntime(26944): Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
09-21 18:21:39.413: E/AndroidRuntime(26944): at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:102)
09-21 18:21:39.413: E/AndroidRuntime(26944): at android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.java:58)
09-21 18:21:39.413: E/AndroidRuntime(26944): at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:98)
09-21 18:21:39.413: E/AndroidRuntime(26944): at com.example.testlfm.FullscreenActivity.onCreate(FullscreenActivity.java:36)
09-21 18:21:39.413: E/AndroidRuntime(26944): at android.app.Activity.performCreate(Activity.java:5104)
09-21 18:21:39.413: E/AndroidRuntime(26944): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
09-21 18:21:39.413: E/AndroidRuntime(26944): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2262)
09-21 18:21:39.413: E/AndroidRuntime(26944): ... 11 more
Upvotes: 3
Views: 8978
Reputation:
I had the same problem and tried whole bunch of things (themes, importing external appcompat jars etc).
The only one helped to me:
1) manually copy android-support-v4.jar and android-support-v7-appcompat.jar to the lib folder of the project;
2) right click on the project -> Properties -> Libraries -> Add JARs (not external jars) - > select jars from the lib folder (which we copied on step 1) -> Order and Export tap -> Uncheck old support libraries and check new, which we just added. -> OK.
Upvotes: 0
Reputation: 1
If there is no assets folder in your project create a one under src/main. Copy your font file into the assets folder.
in your java file you can use like this //Font path String fontPath = "MyCustomFOnt.TTF";
EditText txtCustom = (EditText) findViewById(R.id.editor1);
// Loading Font Face
Typeface tf = Typeface.createFromAsset(getAssets(), fontPath);
// Applying font
txtCustom.setTypeface(tf);
Upvotes: 0
Reputation: 31
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.theredpill.myfirstapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.AppCompat.Light" >
<activity
android:name="com.theredpill.myfirstapp.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>
<activity
android:name="com.theredpill.myfirstapp.DisplayMessageActivity"
android:label="@string/title_activity_display_message"
android:parentActivityName="com.example.myfirstapp.MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.myfirstapp.MainActivity" />
</activity>
</application>
</manifest>
Upvotes: 3
Reputation: 2215
As per the error you have posted: "You need to use a Theme.AppCompat theme (or descendant) with this activity." You should be using the appcompat library as a Library Project, in which case you'll see the available themes under res/values in that project
Upvotes: 9