I am new to Android development.
Been recently tried to have my own Facebook like sliding out menu , but can’t get it work , its doesn’t contain any error in eclipse checking and build up , but when i run it on emulator , the emulator gave me a force close error just no reason.Have done a lot of
this is the tutorial i follow Johnkil Sidenavigation
have done some reseach on debugging technique but don’t know where should i start ,
But i think it is just my layout problem , What am i missing?
Here is part of my code , please let me know how kind of information i need to provide
MainActivity.java
package com.nazartt.johntest;
import com.actionbarsherlock.app.SherlockActivity;
import com.actionbarsherlock.view.MenuItem;
import android.os.Bundle;
public class MainActivity extends SherlockActivity {
SideNavigationView sideNavigationView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
SideNavigationView sideNavigationView = (SideNavigationView)findViewById(R.id.side_navigation_view);
sideNavigationView.setMenuItems(R.menu.side_navigation_menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
sideNavigationView.toggleMenu();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}
here is part my related xml code
activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/hello_world" />
<com.devspark.sidenavigation.SideNavigationView
android:id="@+id/side_navigation_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
this is insert menu folder…
side_navigation_menu.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
</menu>
here is the logcat,
12-28 05:29:33.643: E/Trace(11550): error opening trace file: No such file or directory (2)
12-28 05:29:33.656: E/AndroidRuntime(11550): FATAL EXCEPTION: main
12-28 05:29:33.656: E/AndroidRuntime(11550): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.nazartt.johntest/com.nazartt.johntest.MainActivity}: java.lang.ClassNotFoundException: com.nazartt.johntest.MainActivity
12-28 05:29:33.656: E/AndroidRuntime(11550): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1983)
12-28 05:29:33.656: E/AndroidRuntime(11550): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
12-28 05:29:33.656: E/AndroidRuntime(11550): at android.app.ActivityThread.access$600(ActivityThread.java:130)
12-28 05:29:33.656: E/AndroidRuntime(11550): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
12-28 05:29:33.656: E/AndroidRuntime(11550): at android.os.Handler.dispatchMessage(Handler.java:99)
12-28 05:29:33.656: E/AndroidRuntime(11550): at android.os.Looper.loop(Looper.java:137)
12-28 05:29:33.656: E/AndroidRuntime(11550): at android.app.ActivityThread.main(ActivityThread.java:4745)
12-28 05:29:33.656: E/AndroidRuntime(11550): at java.lang.reflect.Method.invokeNative(Native Method)
12-28 05:29:33.656: E/AndroidRuntime(11550): at java.lang.reflect.Method.invoke(Method.java:511)
12-28 05:29:33.656: E/AndroidRuntime(11550): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
12-28 05:29:33.656: E/AndroidRuntime(11550): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
12-28 05:29:33.656: E/AndroidRuntime(11550): at dalvik.system.NativeStart.main(Native Method)
12-28 05:29:33.656: E/AndroidRuntime(11550): Caused by: java.lang.ClassNotFoundException: com.nazartt.johntest.MainActivity
12-28 05:29:33.656: E/AndroidRuntime(11550): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
12-28 05:29:33.656: E/AndroidRuntime(11550): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
12-28 05:29:33.656: E/AndroidRuntime(11550): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
12-28 05:29:33.656: E/AndroidRuntime(11550): at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
12-28 05:29:33.656: E/AndroidRuntime(11550): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1974)
12-28 05:29:33.656: E/AndroidRuntime(11550): ... 11 more
here is my manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.nazartt.johntest"
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/Theme.Sherlock.Light" >
<activity
android:name="com.nazartt.johntest.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.actionbarsherlock.ActionBarSherlock"
android:label="@string/app_name" >
</activity>
<activity
android:name="com.nazartt.johntest.ISideNavigationCallback"
android:label="@string/app_name" >
</activity>
<activity
android:name="com.nazartt.johntest.SideNavigationItem"
android:label="@string/app_name" >
</activity>
<activity
android:name="com.nazartt.johntest.SideNavigationView"
android:label="@string/app_name" >
</activity>
</application>
</manifest>
I ended up restudy about android project setup and download some android example from github and learn how they setup and import library. To newbies who might encounter the same problem , make sure you understand how an android application build , especially when you importing other library into your project.
Important path to look at when you want to import a library