-1
public class MainActivity extends ActionBarActivity  {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }
}

this is the error that i got

10-24 01:49:30.135: E/AndroidRuntime(1390): FATAL EXCEPTION: main
10-24 01:49:30.135: E/AndroidRuntime(1390): Process: com.example.nevigation, PID: 1390
10-24 01:49:30.135: E/AndroidRuntime(1390): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.nevigation/com.example.nevigation.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.nevigation.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.nevigation-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.nevigation-1, /system/lib]]
10-24 01:49:30.135: E/AndroidRuntime(1390):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2102)
10-24 01:49:30.135: E/AndroidRuntime(1390):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2226)
10-24 01:49:30.135: E/AndroidRuntime(1390):     at android.app.ActivityThread.access$700(ActivityThread.java:135)
10-24 01:49:30.135: E/AndroidRuntime(1390):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1397)
10-24 01:49:30.135: E/AndroidRuntime(1390):     at android.os.Handler.dispatchMessage(Handler.java:102)
10-24 01:49:30.135: E/AndroidRuntime(1390):     at android.os.Looper.loop(Looper.java:137)
10-24 01:49:30.135: E/AndroidRuntime(1390):     at android.app.ActivityThread.main(ActivityThread.java:4998)
10-24 01:49:30.135: E/AndroidRuntime(1390):     at java.lang.reflect.Method.invokeNative(Native Method)
10-24 01:49:30.135: E/AndroidRuntime(1390):     at java.lang.reflect.Method.invoke(Method.java:515)
10-24 01:49:30.135: E/AndroidRuntime(1390):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
10-24 01:49:30.135: E/AndroidRuntime(1390):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
10-24 01:49:30.135: E/AndroidRuntime(1390):     at dalvik.system.NativeStart.main(Native Method)
10-24 01:49:30.135: E/AndroidRuntime(1390): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.nevigation.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.nevigation-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.nevigation-1, /system/lib]]
10-24 01:49:30.135: E/AndroidRuntime(1390):     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
10-24 01:49:30.135: E/AndroidRuntime(1390):     at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
10-24 01:49:30.135: E/AndroidRuntime(1390):     at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
10-24 01:49:30.135: E/AndroidRuntime(1390):     at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
10-24 01:49:30.135: E/AndroidRuntime(1390):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2093)
Kevin Robatel
  • 8,025
  • 3
  • 44
  • 57

3 Answers3

0

Try Using the SupportActionBarActivity instead of ActionBar Activity

Sajidh Zahir
  • 526
  • 4
  • 13
0

below super.onCreate(savedInstanceState); add setContentView(R.layout.activity_main); then clead and build the project again. Hope this will help you, or paste the complete logcat error.

knownUnknown
  • 869
  • 11
  • 18
  • you have `java.lang.ClassNotFoundException: Didn't find class "com.example.nevigation.MainActivity"` means it is not getting the .class file. i think you should delete the apk file created then clean the project and rebuild the apk or try [this](http://wptrafficanalyzer.in/blog/implementing-action-bar-using-actionbarcompat-support-library-in-android/) if you are following the link then add `compile "com.android.support:appcompat-v7:21.0.+"` to build.gradle of Module: App – knownUnknown Oct 25 '16 at 05:32
0

Check for the package mentioned in your AndroidManifest.xml.

It should be <activity name="com.example.nevtest.MainActivity". The package specified here should be the same as the first line of your MainActivity.java file.

This is usually an effect of moving around your Activity class through different packages. Any change in the package of your Activity should reflect in the AndroidManifest.xml.

Kamran Ahmed
  • 7,661
  • 4
  • 30
  • 55
  • Can you paste here the very first line of your MainActivity.java? – Kamran Ahmed Oct 24 '16 at 17:16
  • Just the first line that starts with `package` is required for me to see if there is a problem in your manifest... – Kamran Ahmed Oct 24 '16 at 17:44
  • private DrawerLayout drawerlayout;private ListView listview;String planet[]; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); drawerlayout=(DrawerLayout) findViewById(R.id.drawer); listview=(ListView) findViewById(R.id.drawerlist); planet = getResources().getStringArray(R.array.planets); listview.setAdapter(new ArrayAdapter(this,android.R.layout.simple_expandable_list_item_1,planet)); listview.setOnItemClickListener(this); } – Zabiullah Shahbaz Oct 24 '16 at 17:45
  • many times i delete the project and and remake the project by other name but stil give that error – Zabiullah Shahbaz Oct 24 '16 at 17:47
  • import android.os.Bundle; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.ActionBarActivity; import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ArrayAdapter; import android.widget.ListView; – Zabiullah Shahbaz Oct 24 '16 at 17:47
  • see alose package – Zabiullah Shahbaz Oct 24 '16 at 17:48
  • package com.example.nevtest; – Zabiullah Shahbaz Oct 24 '16 at 17:48
  • Thats strange... can you copy the whole of your `` part of your manifest? – Kamran Ahmed Oct 24 '16 at 17:51
  • The error log you posted seems to be trying to start `com.example.nevigation.MainActivity` and you say it is defined as `com.example.nevtest.MainActivity` in your manifest... Is there a duplicate entry for that activity in your manifest file? – Kamran Ahmed Oct 24 '16 at 17:53
  • i told you i delete that previous project that log was i sent i made new project bt same thing app crash again – Zabiullah Shahbaz Oct 24 '16 at 17:57
  • EXCEPTION: main E/AndroidRuntime(818): Process: com.example.nevtest, E/AndroidRuntime(818): java.lang.NoClassDefFoundError: android.support.v7.appcompat.R$styleable E/AndroidRuntime(818): at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:107) E/AndroidRuntime(818): at android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.java:58) t android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.jav com.example.nevtest.MainActivity.onCreate(MainActivity.java:22) – Zabiullah Shahbaz Oct 24 '16 at 18:02
  • This is a completely different crash. I think you are using very old SDK. You can probably try changing `ActionBarActivity` to `Activity` and change your app theme in styles.xml to `Theme.AppCompat.NoActionBar`, this should get your app started. The other proper alternative would be to update your SDK and the version of libraries that you are using. – Kamran Ahmed Oct 24 '16 at 18:16
  • its kitkat version , API 19 – Zabiullah Shahbaz Oct 24 '16 at 18:25
  • How about the version of appcompat that you are using? – Kamran Ahmed Oct 24 '16 at 18:29
  • i dont know that , how to find out the version of appcompat? – Zabiullah Shahbaz Oct 25 '16 at 17:11
  • What are you using? Eclipse? – Kamran Ahmed Oct 25 '16 at 17:12