I am trying to create facebook like sliding i have tried this library seems its not working for me..I need something like this screen.. where in the sliding layout the listview with header and while click on that in the same activity content should change.actually using the above library i tried like this:
public class MainActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle(R.string.attach);
// set the content view
setContentView(R.layout.content);
// configure the SlidingMenu
SlidingMenu menu = new SlidingMenu(this);
menu.setMode(SlidingMenu.LEFT);
menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
menu.setShadowWidthRes(R.dimen.shadow_width);
menu.setShadowDrawable(R.drawable.shadow);
menu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
menu.setFadeDegree(0.35f);
menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
menu.setMenu(R.layout.menu);
}
}
which is not at all working!
error:
07-20 10:17:19.776: E/AndroidRuntime(1134): FATAL EXCEPTION: main
07-20 10:17:19.776: E/AndroidRuntime(1134): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.app.example/com.app.example.MainActivity}: java.lang.IllegalStateException: Both setBehindContentView must be called in onCreate in addition to setContentView.
07-20 10:17:19.776: E/AndroidRuntime(1134): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
07-20 10:17:19.776: E/AndroidRuntime(1134): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
07-20 10:17:19.776: E/AndroidRuntime(1134): at android.app.ActivityThread.access$600(ActivityThread.java:141)
07-20 10:17:19.776: E/AndroidRuntime(1134): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
07-20 10:17:19.776: E/AndroidRuntime(1134): at android.os.Handler.dispatchMessage(Handler.java:99)
07-20 10:17:19.776: E/AndroidRuntime(1134): at android.os.Looper.loop(Looper.java:137)
07-20 10:17:19.776: E/AndroidRuntime(1134): at android.app.ActivityThread.main(ActivityThread.java:5041)
07-20 10:17:19.776: E/AndroidRuntime(1134): at java.lang.reflect.Method.invokeNative(Native Method)
07-20 10:17:19.776: E/AndroidRuntime(1134): at java.lang.reflect.Method.invoke(Method.java:511)
07-20 10:17:19.776: E/AndroidRuntime(1134): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
07-20 10:17:19.776: E/AndroidRuntime(1134): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
07-20 10:17:19.776: E/AndroidRuntime(1134): at dalvik.system.NativeStart.main(Native Method)
07-20 10:17:19.776: E/AndroidRuntime(1134): Caused by: java.lang.IllegalStateException: Both setBehindContentView must be called in onCreate in addition to setContentView.
07-20 10:17:19.776: E/AndroidRuntime(1134): at com.jeremyfeinstein.slidingmenu.lib.app.SlidingActivityHelper.onPostCreate(SlidingActivityHelper.java:55)
07-20 10:17:19.776: E/AndroidRuntime(1134): at com.jeremyfeinstein.slidingmenu.lib.app.SlidingActivity.onPostCreate(SlidingActivity.java:36)
07-20 10:17:19.776: E/AndroidRuntime(1134): at android.app.Instrumentation.callActivityOnPostCreate(Instrumentation.java:1143)
07-20 10:17:19.776: E/AndroidRuntime(1134): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2163)
07-20 10:17:19.776: E/AndroidRuntime(1134): ... 11 more
menu xml:
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:name="com.app.example.SampleListFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</fragment>
manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.app.example"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.Myactionbar"
>
<activity
android:name="com.app.example.MainActivity"
android:configChanges="orientation|screenSize|screenLayout"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Could somebody help me out #thanks
go through this http://developer.android.com/design/patterns/navigation-drawer.html no need for extra 3rd party libs
go through this:: https://github.com/jfeinstein10/SlidingMenu
This will sure helpful to you.
Inside your AndroidManifest.xml you have declared com.app.example.MainActivity but your Activity is named com.app.example.SlidingExample
Change
<activity
android:name="com.app.example.MainActivity"
android:configChanges="orientation|screenSize|screenLayout"
>
with
<activity
android:name="com.app.example.SlidingExample"
android:configChanges="orientation|screenSize|screenLayout"
>
the layout containing the listview that you want dispay in the sliding menu should be set using setBehindContentView(R.layout.yourlistlayout);you could do that after setcontentview() in your code.
you can add header to your listview like this
TextView header = new TextView(this);
header.setText("Effects");
header.setTextColor(Color.WHITE);
header.setPadding(10, 10, 10, 10);
header.setTextSize(20);
header.setBackgroundColor(Color.parseColor("#054472"));
lv.addHeaderView(header);
As an alternative you can use the new NavigationDrawer made available by google in the recent API.but again it is not available for older versions of android,which means you will have to use a library(like ActioBarSherlock) for backward compatibility. So its up to you.
here is the link for navigation drawer.
http://developer.android.com/training/implementing-navigation/nav-drawer.html
Related
I made an app with a widget, and when I add or remove the widget on my phone, or restart my phone with the widget on my homescreen, it comes up with an error "Unfortunate, Clock has stopped." (Clock is the name of my app.) The widget works fine, but I need to get rid of the error message. Eclipse didn't say that there was any problem.
Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.tzemachzr.clock"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar" >
<activity
android:name="com.tzemachzr.clock.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>
<receiver android:name="com.tzemachzr.clock.ClockWidgetProvider">
<intent-filter>
<action
android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="#xml/clock_appwidget" />
</receiver>
</application>
</manifest>
Widget Layout
<?xml version="1.0" encoding="utf-8"?>
<AnalogClock xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</AnalogClock>
App Widget Provider (res-xml-clock_appwidget.xml)
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:minHeight="140dp"
android:minWidth="140dp"
android:initialLayout="#layout/clock_appwidget_layout" android:resizeMode="horizontal|vertical">
</appwidget-provider>
Logcat
E/AndroidRuntime( 5480): FATAL EXCEPTION: main
08-12 15:56:27.433 E/AndroidRuntime( 5480): java.lang.RuntimeException: Unable to instantiate receiver com.tzemachzr.clock.ClockWidgetProvider: java.lang.ClassNotFoundException: com.tzemachzr.clock.ClockWidgetProvider
08-12 15:56:27.433 E/AndroidRuntime( 5480): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2383)
08-12 15:56:27.433 E/AndroidRuntime( 5480): at android.app.ActivityThread.access$1500(ActivityThread.java:139)
08-12 15:56:27.433 E/AndroidRuntime( 5480): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1322)
08-12 15:56:27.433 E/AndroidRuntime( 5480): at android.os.Handler.dispatchMessage(Handler.java:99)
08-12 15:56:27.433 E/AndroidRuntime( 5480): at android.os.Looper.loop(Looper.java:156)
08-12 15:56:27.433 E/AndroidRuntime( 5480): at android.app.ActivityThread.main(ActivityThread.java:4977)
08-12 15:56:27.433 E/AndroidRuntime( 5480): at java.lang.reflect.Method.invokeNative(Native Method)
08-12 15:56:27.433 E/AndroidRuntime( 5480): at java.lang.reflect.Method.invoke(Method.java:511)
08-12 15:56:27.433 E/AndroidRuntime( 5480): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
08-12 15:56:27.433 E/AndroidRuntime( 5480): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
08-12 15:56:27.433 E/AndroidRuntime( 5480): at dalvik.system.NativeStart.main(Native Method)
08-12 15:56:27.433 E/AndroidRuntime( 5480): Caused by: java.lang.ClassNotFoundException: com.tzemachzr.clock.ClockWidgetProvider
08-12 15:56:27.433 E/AndroidRuntime( 5480): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
08-12 15:56:27.433 E/AndroidRuntime( 5480): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
08-12 15:56:27.433 E/AndroidRuntime( 5480): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
08-12 15:56:27.433 E/AndroidRuntime( 5480): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2378)
08-12 15:56:27.433 E/AndroidRuntime( 5480): ... 10 more
08-12 15:56:27.453 D/Launcher.Model( 1729): DbDebug Add item (null) to db, id: 66 (-100, 2, 0, 2)
08-12 15:56:27.453 E/EmbeddedLogger( 1598): App crashed! Process: com.tzemachzr.clock
08-12 15:56:27.453 E/EmbeddedLogger( 1598): App crashed! Package: com.tzemachzr.clock v1 (1.0)
08-12 15:56:27.463 E/EmbeddedLogger( 1598): Application Label: Clock
08-12 15:56:27.513
You got a ClassNotFoundException, that means that android doesnt find the class
com.tzemachzr.clock.ClockWidgetProvider
Edit:
Okay, it seems that the basics arent clear.
You need a class, named ClockidgetProvider.
This class extends AppWidgetProvider and uses the meta data, stored in your clock_appwidget.xml.
So, when you declare a receiver in your Android manifest, android creates a receiver, which consists of your AppWidgetProvider class and your meta data.
See example:
package com.tzemachzr.clock;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.Context;
public class ClockWidgetProvider extends AppWidgetProvider {
#Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager,
int[] appWidgetIds) {
// TODO Auto-generated method stub
super.onUpdate(context, appWidgetManager, appWidgetIds);
}
}
Your meta data xml file is correct.
Add this class and see ,whether is solves your problem or not.
PS: you can set flags, by simply call:
System.out.println("hello");
This will print "hello" in your Logcat!
I just instilled Android Studio and when I run the sample project hello world in the emulator it gives me my project has stopped and it doesn't work
myActivity.java
package b3du.im.myapplication;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
public class MyActivity extends ActionBarActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my);
}
}
activity_my.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"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin"
tools:context=".MyActivity">
<TextView
android:text="#string/hello_world"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="b3du.im.myapplication" >
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MyActivity"
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>
logcat error
08-01 05:13:56.557 1884-1884/b3du.im.myapplication I/Process﹕ Sending signal. PID: 1884 SIG: 9
08-01 05:21:26.244 1944-1944/b3du.im.myapplication D/AndroidRuntime﹕ Shutting down VM
08-01 05:21:26.244 1944-1944/b3du.im.myapplication W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0xb2cc9b20)
08-01 05:21:26.284 1944-1944/b3du.im.myapplication E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: b3du.im.myapplication, PID: 1944
java.lang.RuntimeException: Unable to start activity ComponentInfo{b3du.im.myapplication/b3du.im.myapplication.MyActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:108)
at android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.java:57)
at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:98)
at b3du.im.myapplication.MyActivity.onCreate(MyActivity.java:11)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
This is because you are using ActionBarActivity, which requires the AppCompat theme to be applied.
Either use that theme, Or use simple Activity. See a similar issue
as Stated by MysticMagic change ActionBarActivity to Activity or change your theme to AppCompat
explore package got to res-> values->style.xml and change style
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
Your issue is with AppTheme that you have set currently in you app.
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:108)
You are inheriting you from ActionBarActivity so you have to use Theme.AppCompat for your application. Change app base theme in styles.xml to
<style name="AppBaseTheme" parent="#style/Theme.AppCompat.Light">
If you are facing issue in loading this theme than please follow the below link to resolve compilation issue.
Can't Find Theme.AppCompat.Light for New Android ActionBar Support
am getting this exception:
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{business.premium/business.premium.Problemio}:
java.lang.ClassNotFoundException: business.premium.Problemio
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
at android.app.ActivityThread.access$600(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: business.premium.Problemio
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
... 11 more
java.lang.ClassNotFoundException: business.premium.Problemio
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
at android.app.ActivityThread.access$600(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
it says that class is not there, but it IS there. I tried to configure things in my project's build path, but not too sure what to tweak there.
And here is how I start my Manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="business.premium"
android:versionCode="1"
android:versionName="1.0" >
<supports-screens android:largeScreens="true" android:normalScreens="true" android:smallScreens="true"/>
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="15"/>
<uses-permission android:name="android.permission.INTERNET" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/CustomTheme"
android:name="MyApplication"
android:debuggable="true">
<activity
android:name=".Problemio"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Any thoughts on how to solve this, or what to look into? Thanks!
Its because you specified the "android:name" attribute in the application node in the manifest file.
Do not use the android:name attribute!
It, misleadingly, does not have anything to do with the name of your app and is actually the name of an extra class to load before loading your application. That's why you are getting the ClassNotFoundException.
Remove it and it should work:
<application
android:icon="#drawable/icon"
android:label="#string/app_name"
android:description="#string/help_text" >
This answer is taken from: java.lang.ClassNotFoundException on working app
I made a test a program for my University which uses Google maps following a tutorial. I made everything like in tutorial, but my app crashes before even showing anything with message "Unfortunately SocialFoot has stopped". I tried to debug and it seems like it crashes even before entering to onCreate method. This is my code:
package it.univpm.dii.socialfoot;
import com.actionbarsherlock.app.SherlockMapActivity;
import android.os.Bundle;
public class SocialFootActivity extends SherlockMapActivity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
#Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
Logcat:
05-18 19:29:59.343: E/AndroidRuntime(3405): FATAL EXCEPTION: main
05-18 19:29:59.343: E/AndroidRuntime(3405): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{it.univpm.dii.socialfoot/it.univpm.dii.socialfoot.activities.SocialFootActivity}: java.lang.ClassNotFoundException: it.univpm.dii.socialfoot.activities.SocialFootActivity
05-18 19:29:59.343: E/AndroidRuntime(3405): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)
05-18 19:29:59.343: E/AndroidRuntime(3405): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
05-18 19:29:59.343: E/AndroidRuntime(3405): at android.app.ActivityThread.access$600(ActivityThread.java:123)
05-18 19:29:59.343: E/AndroidRuntime(3405): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
05-18 19:29:59.343: E/AndroidRuntime(3405): at android.os.Handler.dispatchMessage(Handler.java:99)
05-18 19:29:59.343: E/AndroidRuntime(3405): at android.os.Looper.loop(Looper.java:137)
05-18 19:29:59.343: E/AndroidRuntime(3405): at android.app.ActivityThread.main(ActivityThread.java:4424)
05-18 19:29:59.343: E/AndroidRuntime(3405): at java.lang.reflect.Method.invokeNative(Native Method)
05-18 19:29:59.343: E/AndroidRuntime(3405): at java.lang.reflect.Method.invoke(Method.java:511)
05-18 19:29:59.343: E/AndroidRuntime(3405): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
05-18 19:29:59.343: E/AndroidRuntime(3405): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
05-18 19:29:59.343: E/AndroidRuntime(3405): at dalvik.system.NativeStart.main(Native Method)
05-18 19:29:59.343: E/AndroidRuntime(3405): Caused by: java.lang.ClassNotFoundException: it.univpm.dii.socialfoot.activities.SocialFootActivity
05-18 19:29:59.343: E/AndroidRuntime(3405): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
05-18 19:29:59.343: E/AndroidRuntime(3405): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
05-18 19:29:59.343: E/AndroidRuntime(3405): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
05-18 19:29:59.343: E/AndroidRuntime(3405): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
05-18 19:29:59.343: E/AndroidRuntime(3405): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
05-18 19:29:59.343: E/AndroidRuntime(3405): ... 11 more
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="it.univpm.dii.socialfoot"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_GPS" />
<uses-sdk android:minSdkVersion="15" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.Sherlock" >
<uses-library android:name="com.google.android.maps" />
<activity
android:name=".SocialFootActivity"
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>
Layout:
The logs indicate the app is trying to launch it.univpm.dii.socialfoot.activities.SocialFootActivity, but SocialFootActivity is in package it.univpm.dii.socialfoot. If this is happening at the start of your application (since that activity is set as the launch activity), I would try cleaning and rebuilding your project and trying again.
I've started to learn Android Development and I got this snippit off of google android development site, it keeps on crashing.
My specs are:
Android 4.0.3
API 15
Code:
package lewes.android.hello;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class HelloAndroid extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView tv = new TextView(this);
tv.setText("Hello, Android");
setContentView(tv);
}
}
I get...
Unfortenualy, HelloAndroid is not responding.
Please help me!
MY MANIFEST:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="lewes.android.hello"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="15" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".HelloWorld"
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>
LogCat:
03-17 11:35:19.835: D/AndroidRuntime(562): Shutting down VM
03-17 11:35:19.835: W/dalvikvm(562): threadid=1: thread exiting with uncaught
exception (group=0x409c01f8)
03-17 11:35:19.914: E/AndroidRuntime(562): FATAL EXCEPTION: main
03-17 11:35:19.914: E/AndroidRuntime(562): java.lang.RuntimeException: Unable to
instantiate activity
ComponentInfo{lewes.android.hello/lewes.android.hello.HelloWorld}:
java.lang.ClassNotFoundException: lewes.android.hello.HelloWorld
03-17 11:35:19.914: E/AndroidRuntime(562): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)
03-17 11:35:19.914: E/AndroidRuntime(562): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
03-17 11:35:19.914: E/AndroidRuntime(562): at
android.app.ActivityThread.access$600(ActivityThread.java:123)
03-17 11:35:19.914: E/AndroidRuntime(562): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
03-17 11:35:19.914: E/AndroidRuntime(562): at
android.os.Handler.dispatchMessage(Handler.java:99)
03-17 11:35:19.914: E/AndroidRuntime(562): at android.os.Looper.loop(Looper.java:137)
03-17 11:35:19.914: E/AndroidRuntime(562): at
android.app.ActivityThread.main(ActivityThread.java:4424)
03-17 11:35:19.914: E/AndroidRuntime(562): at
java.lang.reflect.Method.invokeNative(Native Method)
03-17 11:35:19.914: E/AndroidRuntime(562): at
java.lang.reflect.Method.invoke(Method.java:511)
03-17 11:35:19.914: E/AndroidRuntime(562): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
03-17 11:35:19.914: E/AndroidRuntime(562): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-17 11:35:19.914: E/AndroidRuntime(562): at dalvik.system.NativeStart.main(Native
Method)
03-17 11:35:19.914: E/AndroidRuntime(562): Caused by:
java.lang.ClassNotFoundException: lewes.android.hello.HelloWorld
03-17 11:35:19.914: E/AndroidRuntime(562): at
dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
03-17 11:35:19.914: E/AndroidRuntime(562): at
java.lang.ClassLoader.loadClass(ClassLoader.java:501)
03-17 11:35:19.914: E/AndroidRuntime(562): at
java.lang.ClassLoader.loadClass(ClassLoader.java:461)
03-17 11:35:19.914: E/AndroidRuntime(562): at
android.app.Instrumentation.newActivity(Instrumentation.java:1023)
03-17 11:35:19.914: E/AndroidRuntime(562): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
03-17 11:35:19.914: E/AndroidRuntime(562): ... 11 more
03-17 11:40:20.114: I/Process(562): Sending signal. PID: 562 SIG: 9
Delete one of the application sections from your manifest.
Keep the one where the activity corresponds to the name of your class.
make your manifest look exactly like this
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="lewes.android.hello"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="15" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".HelloAndroid"
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>
Change
<activity
android:name=".HelloAndroidActivity"
to
<activity
android:name=".HelloAndroid"
SDK does not mention about this. But as my experience, activity (this) can not be used inside onCreate(Bundle) to initialize new objects. To be used as a parameter for constructors, this is nothing within onCreate().
You can follow this hello world. It uses static xml layout.
Hope this helps you :-)