i am using Action Bar in my App, extends ActionBarActivity , but it is giving following error in Logcat,
02-12 21:59:53.252: E/AndroidRuntime(7062): FATAL EXCEPTION: main
02-12 21:59:53.252: E/AndroidRuntime(7062): Process: com.example.a_bar, PID: 7062
02-12 21:59:53.252: E/AndroidRuntime(7062): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.a_bar/com.example.a_bar.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.a_bar.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.a_bar-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.a_bar-1, /system/lib, /data/downloads]]
02-12 21:59:53.252: E/AndroidRuntime(7062): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2121)
02-12 21:59:53.252: E/AndroidRuntime(7062): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
02-12 21:59:53.252: E/AndroidRuntime(7062): at android.app.ActivityThread.access$800(ActivityThread.java:135)
02-12 21:59:53.252: E/AndroidRuntime(7062): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
02-12 21:59:53.252: E/AndroidRuntime(7062): at android.os.Handler.dispatchMessage(Handler.java:102)
02-12 21:59:53.252: E/AndroidRuntime(7062): at android.os.Looper.loop(Looper.java:136)
02-12 21:59:53.252: E/AndroidRuntime(7062): at android.app.ActivityThread.main(ActivityThread.java:5021)
02-12 21:59:53.252: E/AndroidRuntime(7062): at java.lang.reflect.Method.invokeNative(Native Method)
02-12 21:59:53.252: E/AndroidRuntime(7062): at java.lang.reflect.Method.invoke(Method.java:515)
02-12 21:59:53.252: E/AndroidRuntime(7062): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:827)
02-12 21:59:53.252: E/AndroidRuntime(7062): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:643)
02-12 21:59:53.252: E/AndroidRuntime(7062): at dalvik.system.NativeStart.main(Native Method)
02-12 21:59:53.252: E/AndroidRuntime(7062): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.a_bar.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.a_bar-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.a_bar-1, /system/lib, /data/downloads]]
Manifest is as below,
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.a_bar"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.a_bar.MainActivity"
android:label="@string/app_name"
android:theme="@style/Theme.AppCompat.Light" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
style.xml is as below,
<resources>
<style name="AppBaseTheme" parent="Theme.AppCompat.Light"> </style>
<style name="AppTheme" parent="AppBaseTheme"> </style>
</resources>
MainActivity is as below,
package com.example.a_bar;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBar;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.os.Build;
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment()).commit();
}
}
i have added as library project android-support-v7-appcompat, in my App. And added theme into Manifest,
android:theme="@style/Theme.AppCompat.Light"
My App get crashed while stated . Why ClassNotFoundException generated ? But when i extend Activity instead of ActionBarActivity it is Running .