If someone could help me with this. I downloaded AndroidSDK and everything else needed for android programming, and I faced some problems with (funny to say) hello world.
I just do not get the thing with tarketSdkVersion setting in AppManifest. Whenever it is not set to "13" (just noticed 8 which is my minSdkVersion is working also) application has "Unfortunately application stopped working" screen with this in LogCat:
07-01 01:26:47.820: E/AndroidRuntime(902): FATAL EXCEPTION: main
07-01 01:26:47.820: E/AndroidRuntime(902): Process: pl.bbZoftware.eclipsestandalone, PID: 902
07-01 01:26:47.820: E/AndroidRuntime(902): java.lang.RuntimeException: Unable to start activity ComponentInfo{pl.bbZoftware.eclipsestandalone/pl.bbZoftware.eclipsestandalone.MainActivity}: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
07-01 01:26:47.820: E/AndroidRuntime(902): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2197)
07-01 01:26:47.820: E/AndroidRuntime(902): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2258)
07-01 01:26:47.820: E/AndroidRuntime(902): at android.app.ActivityThread.access$800(ActivityThread.java:138)
07-01 01:26:47.820: E/AndroidRuntime(902): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209)
07-01 01:26:47.820: E/AndroidRuntime(902): at android.os.Handler.dispatchMessage(Handler.java:102)
07-01 01:26:47.820: E/AndroidRuntime(902): at android.os.Looper.loop(Looper.java:136)
07-01 01:26:47.820: E/AndroidRuntime(902): at android.app.ActivityThread.main(ActivityThread.java:5026)
07-01 01:26:47.820: E/AndroidRuntime(902): at java.lang.reflect.Method.invokeNative(Native Method)
07-01 01:26:47.820: E/AndroidRuntime(902): at java.lang.reflect.Method.invoke(Method.java:515)
07-01 01:26:47.820: E/AndroidRuntime(902): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
07-01 01:26:47.820: E/AndroidRuntime(902): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
07-01 01:26:47.820: E/AndroidRuntime(902): at dalvik.system.NativeStart.main(Native Method)
07-01 01:26:47.820: E/AndroidRuntime(902): Caused by: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
07-01 01:26:47.820: E/AndroidRuntime(902): at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:275)
07-01 01:26:47.820: E/AndroidRuntime(902): at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2872)
07-01 01:26:47.820: E/AndroidRuntime(902): at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3129)
07-01 01:26:47.820: E/AndroidRuntime(902): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:303)
07-01 01:26:47.820: E/AndroidRuntime(902): at android.app.Activity.setContentView(Activity.java:1930)
07-01 01:26:47.820: E/AndroidRuntime(902): at android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:217)
07-01 01:26:47.820: E/AndroidRuntime(902): at android.support.v7.app.ActionBarActivityDelegateICS.setContentView(ActionBarActivityDelegateICS.java:110)
07-01 01:26:47.820: E/AndroidRuntime(902): at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:77)
07-01 01:26:47.820: E/AndroidRuntime(902): at pl.bbZoftware.eclipsestandalone.MainActivity.onCreate(MainActivity.java:14)
07-01 01:26:47.820: E/AndroidRuntime(902): at android.app.Activity.performCreate(Activity.java:5242)
07-01 01:26:47.820: E/AndroidRuntime(902): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
07-01 01:26:47.820: E/AndroidRuntime(902): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2161)
07-01 01:26:47.820: E/AndroidRuntime(902): ... 11 more
07-01 01:26:55.340: I/Process(902): Sending signal. PID: 902 SIG: 9
I do not get if this is intentional, I got some SDK errors or something else.
I was googling for answers but coulnt find any. Tell me if I should add some more info from project, looking for your answers.
EDIT: Forgot to add, I got an android device with 4.4.2 KitKat so I wanted to make project target set to 20. That is how I noticed this errors.
EDIT2:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
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"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="pl.bbZoftware.eclipsestandalone.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" />
</RelativeLayout>
EDIT3:
manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="pl.bbZoftware.eclipsestandalone"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="13" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".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>
</application>
</manifest>
I just found where the problem was.
Do not use API Level of 20 and Platform 4.4W, as Android Virtual Device.
With Level 19 and Platform 4.2.2 set on ADV everything runs as it should.
Just remove android:targetSdkVersion from AndroidManifest.xml
Make following changes:
From
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
To:
<uses-sdk android:minSdkVersion="8" />
Most probably you are making mistake on activity_main.xml
Also target for 4.4.2 Kitkat is 19. Have a check in this android api levels page.
ChangetargetSdkVersion in [project directory]\app\build.gradle to something less than or equal to 19. Change:
defaultConfig {
applicationId '....'
minSdkVersion 8
targetSdkVersion 21
}
To:
defaultConfig {
applicationId '....'
targetSdkVersion 19
}
Android API 20 gives compilation issues. Make sure to be using the API 19 and set it as a Targeted SDK during development.
Related
I am a beginner in android developmnt.I followed a series of tutorials and made a piece of code.Whenever I run the app in the emulator it shows "Sorry! the application XXXX has stopped unexpectedly..Please try again." Please help me solve this error.
Here is the code I used...
package newapp.com;
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.widget.Button;
import android.widget.TextView;
import android.os.Build;
public class MainActivity extends ActionBarActivity {
int counter;
Button add,sub;
TextView display;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
counter=0;
add= (Button) findViewById(R.id.badd);
sub= (Button) findViewById(R.id.bsub);
display= (TextView) findViewById(R.id.tdisplay);
add.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
counter++;
}
});
}}
This is xml code i used....
<LinearLayout 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:orientation="vertical"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="newapp.com.MainActivity$PlaceholderFragment" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="The sum is"
android:textSize="45dp"
android:gravity="center"
android:id="#+id/tdisplay"
/>
<Button
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="add"
android:id="#+id/badd"
/>
<Button
android:id="#+id/bsub"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="subtract" />
</LinearLayout>
And here is the manifest....
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="newapp.com"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="newapp.com.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>
</application>
</manifest>
This is my logcat...and how logcat is useful to resolve this issue.
05-07 13:22:31.058: I/dalvikvm(609): Could not find method
android.content.pm.PackageManager.getActivityLogo, referenced from method
android.support.v7.internal.widget.ActionBarView.<init>
05-07 13:22:31.058: W/dalvikvm(609): VFY: unable to resolve virtual method 318:
Landroid/content/pm/PackageManager;.getActivityLogo
(Landroid/content/ComponentName;)Landroid/graphics/drawable/Drawable;
05-07 13:22:31.058: D/dalvikvm(609): VFY: replacing opcode 0x6e at 0x008b
05-07 13:22:31.058: I/dalvikvm(609): Could not find method
android.content.pm.ApplicationInfo.loadLogo, referenced from method
android.support.v7.internal.widget.ActionBarView.<init>
05-07 13:22:31.068: W/dalvikvm(609): VFY: unable to resolve virtual method 314:
Landroid/content/pm/ApplicationInfo;.loadLogo
(Landroid/content/pm/PackageManager;)Landroid/graphics/drawable/Drawable;
05-07 13:22:31.088: D/dalvikvm(609): VFY: replacing opcode 0x6e at 0x0099
05-07 13:22:31.108: D/dalvikvm(609): VFY: dead code 0x008e-0092 in
Landroid/support/v7/internal/widget/ActionBarView;.<init>
(Landroid/content/Context;Landroid/util/AttributeSet;)V
05-07 13:22:31.108: D/dalvikvm(609): VFY: dead code 0x009c-00a0 in
Landroid/support/v7/internal/widget/ActionBarView;.<init>
(Landroid/content/Context;Landroid/util/AttributeSet;)V
05-07 13:22:31.458: D/AndroidRuntime(609): Shutting down VM
05-07 13:22:31.458: W/dalvikvm(609): threadid=1: thread exiting with uncaught exception
(group=0x4001d800)
05-07 13:22:31.478: E/AndroidRuntime(609): FATAL EXCEPTION: main
05-07 13:22:31.478: E/AndroidRuntime(609): java.lang.RuntimeException: Unable to start
activity ComponentInfo{newapp.com/newapp.com.MainActivity}:
java.lang.NullPointerException
05-07 13:22:31.478: E/AndroidRuntime(609): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
05-07 13:22:31.478: E/AndroidRuntime(609): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
05-07 13:22:31.478: E/AndroidRuntime(609): at
android.app.ActivityThread.access$2300(ActivityThread.java:125)
05-07 13:22:31.478: E/AndroidRuntime(609): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
05-07 13:22:31.478: E/AndroidRuntime(609): at
android.os.Handler.dispatchMessage(Handler.java:99)
05-07 13:22:31.478: E/AndroidRuntime(609): at android.os.Looper.loop(Looper.java:123)
05-07 13:22:31.478: E/AndroidRuntime(609): at
android.app.ActivityThread.main(ActivityThread.java:4627)
05-07 13:22:31.478: E/AndroidRuntime(609): at
java.lang.reflect.Method.invokeNative(Native Method)
05-07 13:22:31.478: E/AndroidRuntime(609): at
java.lang.reflect.Method.invoke(Method.java:521)
05-07 13:22:31.478: E/AndroidRuntime(609): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-07 13:22:31.478: E/AndroidRuntime(609): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-07 13:22:31.478: E/AndroidRuntime(609): at dalvik.system.NativeStart.main(Native
Method)
05-07 13:22:31.478: E/AndroidRuntime(609): Caused by: java.lang.NullPointerException
05-07 13:22:31.478: E/AndroidRuntime(609): at
newapp.com.MainActivity.onCreate(MainActivity.java:32)
05-07 13:22:31.478: E/AndroidRuntime(609): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-07 13:22:31.478: E/AndroidRuntime(609): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
05-07 13:22:31.478: E/AndroidRuntime(609): ... 11 more
05-07 13:22:41.409: I/Process(609): Sending signal. PID: 609 SIG: 9
Apply theme in activity in manifest file
android:theme="#style/Theme.AppCompat.Light"
And in styles.xml
<style name="AppBaseTheme" parent="#style/Theme.AppCompat.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
The layout you posted that contains the Buttons and TextView you use is not R.layout.activity_main.
Make sure R.layout.activity_main is the layout that contains R.id.badd, R.id.bsub and R.id.tdisplay
I am building an app using Phonegap and Cordova. When I run the app in Eclipse emulator the apk gets installed successfully but after clicking on it I get an alert saying "Unfortunately AppName has Stopped" Any guidance or suggestion to solve this problem will be great, thanks.
Console:
[2013-11-13 12:18:47 - Challenger] Dx
trouble writing output: already prepared
[2013-11-13 12:18:48 - Challenger] ------------------------------
[2013-11-13 12:18:48 - Challenger] Android Launch!
[2013-11-13 12:18:48 - Challenger] adb is running normally.
[2013-11-13 12:18:48 - Challenger] Performing com.disciplinexgames.DisciplineXgames.Challenger activity launch
[2013-11-13 12:18:48 - Challenger] Automatic Target Mode: launching new emulator with compatible AVD 'testDevice'
[2013-11-13 12:18:48 - Challenger] Launching a new emulator with Virtual Device 'testDevice'
[2013-11-13 12:18:57 - Challenger] New emulator found: emulator-5554
[2013-11-13 12:18:57 - Challenger] Waiting for HOME ('android.process.acore') to be launched...
[2013-11-13 12:19:55 - Challenger] HOME is up on device 'emulator-5554'
[2013-11-13 12:19:55 - Challenger] Uploading Challenger.apk onto device 'emulator-5554'
[2013-11-13 12:20:09 - Challenger] Installing Challenger.apk...
[2013-11-13 12:21:33 - Challenger] Success!
[2013-11-13 12:21:33 - Challenger] Starting activity com.disciplinexgames.DisciplineXgames.Challenger on device emulator-5554
[2013-11-13 12:21:34 - Challenger] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.disciplinexgames.DisciplineXgames/.Challenger }
LogCat:
11-13 07:21:36.140: D/AndroidRuntime(837): Shutting down VM
11-13 07:21:36.140: W/dalvikvm(837): threadid=1: thread exiting with uncaught exception (group=0x41465700)
11-13 07:21:36.150: E/AndroidRuntime(837): FATAL EXCEPTION: main
11-13 07:21:36.150: E/AndroidRuntime(837): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.disciplinexgames.DisciplineXgames/com.disciplinexgames.DisciplineXgames.Challenger}: java.lang.ClassNotFoundException: Didn't find class "com.disciplinexgames.DisciplineXgames.Challenger" on path: DexPathList[[zip file "/data/app/com.disciplinexgames.DisciplineXgames-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.disciplinexgames.DisciplineXgames-1, /system/lib]]
11-13 07:21:36.150: E/AndroidRuntime(837): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
11-13 07:21:36.150: E/AndroidRuntime(837): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
11-13 07:21:36.150: E/AndroidRuntime(837): at android.app.ActivityThread.access$600(ActivityThread.java:141)
11-13 07:21:36.150: E/AndroidRuntime(837): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
11-13 07:21:36.150: E/AndroidRuntime(837): at android.os.Handler.dispatchMessage(Handler.java:99)
11-13 07:21:36.150: E/AndroidRuntime(837): at android.os.Looper.loop(Looper.java:137)
11-13 07:21:36.150: E/AndroidRuntime(837): at android.app.ActivityThread.main(ActivityThread.java:5103)
11-13 07:21:36.150: E/AndroidRuntime(837): at java.lang.reflect.Method.invokeNative(Native Method)
11-13 07:21:36.150: E/AndroidRuntime(837): at java.lang.reflect.Method.invoke(Method.java:525)
11-13 07:21:36.150: E/AndroidRuntime(837): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
11-13 07:21:36.150: E/AndroidRuntime(837): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
11-13 07:21:36.150: E/AndroidRuntime(837): at dalvik.system.NativeStart.main(Native Method)
11-13 07:21:36.150: E/AndroidRuntime(837): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.disciplinexgames.DisciplineXgames.Challenger" on path: DexPathList[[zip file "/data/app/com.disciplinexgames.DisciplineXgames-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.disciplinexgames.DisciplineXgames-1, /system/lib]]
11-13 07:21:36.150: E/AndroidRuntime(837): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
11-13 07:21:36.150: E/AndroidRuntime(837): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
11-13 07:21:36.150: E/AndroidRuntime(837): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
11-13 07:21:36.150: E/AndroidRuntime(837): at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
11-13 07:21:36.150: E/AndroidRuntime(837): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
11-13 07:21:36.150: E/AndroidRuntime(837): ... 11 more
androidManifest.xml
<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="1.0.0" android:windowSoftInputMode="adjustPan" package="com.disciplinexgames.DisciplineXgames" xmlns:android="http://schemas.android.com/apk/res/android">
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:debuggable="true" android:hardwareAccelerated="true" android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="#string/app_name" android:name="Challenger" android:theme="#android:style/Theme.Black.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="18" />
</manifest>
ClassNotFoundException. Your app is unable to find your class. check your all java files once. or post your manifest file.
Try going to Project -> Properties -> Java Build Path -> Order & Export and ensure Android Private Libraries are checked for your project and for all other library projects you are using. Clean all projects afterwards and see what happens.
Is it displaying the error when you click a button?
Try to avoid mixing upper- and lowercase-names in packagenames, it is destined for trouble. Especially if you are developing on a windows-machine.
So, instead of the package-name com.disciplinexgames.DisciplineXgames use com.disciplinexgames.disciplinexgames by renaming the package-directory and replacing the packagename in every file of your project.
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
Whenever I run my android application I get an exception:
05-07 12:03:55.356: E/AndroidRuntime(589): FATAL EXCEPTION: main
05-07 12:03:55.356: E/AndroidRuntime(589): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{packgname/de.fau.fsahoy.android.api15.Activities.LoginActivity}: java.lang.ClassNotFoundException: de.fau.fsahoy.android.api15.Activities.LoginActivity
05-07 12:03:55.356: E/AndroidRuntime(589): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)
05-07 12:03:55.356: E/AndroidRuntime(589): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
05-07 12:03:55.356: E/AndroidRuntime(589): at android.app.ActivityThread.access$600(ActivityThread.java:123)
05-07 12:03:55.356: E/AndroidRuntime(589): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
05-07 12:03:55.356: E/AndroidRuntime(589): at android.os.Handler.dispatchMessage(Handler.java:99)
05-07 12:03:55.356: E/AndroidRuntime(589): at android.os.Looper.loop(Looper.java:137)
05-07 12:03:55.356: E/AndroidRuntime(589): at android.app.ActivityThread.main(ActivityThread.java:4424)
05-07 12:03:55.356: E/AndroidRuntime(589): at java.lang.reflect.Method.invokeNative(Native Method)
05-07 12:03:55.356: E/AndroidRuntime(589): at java.lang.reflect.Method.invoke(Method.java:511)
05-07 12:03:55.356: E/AndroidRuntime(589): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
05-07 12:03:55.356: E/AndroidRuntime(589): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
05-07 12:03:55.356: E/AndroidRuntime(589): at dalvik.system.NativeStart.main(Native Method)
05-07 12:03:55.356: E/AndroidRuntime(589): Caused by: java.lang.ClassNotFoundException: packgname.Activities.LoginActivity
05-07 12:03:55.356: E/AndroidRuntime(589): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
05-07 12:03:55.356: E/AndroidRuntime(589): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
05-07 12:03:55.356: E/AndroidRuntime(589): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
05-07 12:03:55.356: E/AndroidRuntime(589): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
05-07 12:03:55.356: E/AndroidRuntime(589): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
05-07 12:03:55.356: E/AndroidRuntime(589): ... 11 more
However, in my AndroidManifest.xml there imho nothing wrong:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.fau.fsahoy.android.api15"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="15"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application
android:icon="#drawable/fsa_launcher"
android:label="#string/AppName">
<activity
android:name=".Activities.LoginActivity"
android:label="#string/AppName">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Activities.MainMenuActivity"></activity>
<activity android:name=".Activities.ProfileActivity"></activity>
</application>
</manifest>
I'm going crazy about that issue and trying to resolve it for the last 3 hours or so :<
Currently I am rebuilding the app by copy and pasting the code over to another clean project. I hope that works. Anyway, I see that many people have that issue. What is it?
I solved the problem by creating a new Android Project and manually copy and pasted the code from the old project.
Magically then - it worked :)
Might not be the best solution - especially for large projects with a huge codebase. Yet, it worked for me :)
I had a similar "poltergeist" in my code. I don't understand the reason but it seems to be related with my activity extending FragmentActivity and having a method with the following signature: public boolean isResumed().
I renamed the method and it worked.
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 :-)