• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Some help please with Eclipse

ktUK

Newbie
Hello all, I am very new to programming and learning to build android apps is pretty much the first thing I have done.

Having got over the initial frustration of not being able to get anything to work I have made some progress on a couple of apps. Both involve an EditText for the user to enter a number, and a button which takes the number, multiplies it by another number and then changes a TextView to give the answer.

It was working perfectly until I started messing around with it and trying to make it do something useful. Now whenever I run the app I get '"app name" has stopped working' on the emulator. The version is Android 4.0.

Any help at all would be appreciated, thank you
 
We need more info than that. Tell us what you're trying to do, and also post the exception thrown in logcat
 
When that happens, it means their is a flaw in your code logic, have you tried reverting to an earlier version? Logcat will tell you where you went wrong.
 
Okay here's the logcat once the app is uploaded to the emulator



02-10 18:59:58.929: D/dalvikvm(559): Not late-enabling CheckJNI (already on)
02-10 19:00:00.308: D/AndroidRuntime(559): Shutting down VM
02-10 19:00:00.308: W/dalvikvm(559): threadid=1: thread exiting with uncaught exception (group=0x409951f8)
02-10 19:00:00.518: E/AndroidRuntime(559): FATAL EXCEPTION: main
02-10 19:00:00.518: E/AndroidRuntime(559): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{converter.units.kitchen/converter.units.kitchen.menu}: java.lang.ClassNotFoundException: converter.units.kitchen.menu
02-10 19:00:00.518: E/AndroidRuntime(559): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1879)
02-10 19:00:00.518: E/AndroidRuntime(559): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
02-10 19:00:00.518: E/AndroidRuntime(559): at android.app.ActivityThread.access$600(ActivityThread.java:122)
02-10 19:00:00.518: E/AndroidRuntime(559): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
02-10 19:00:00.518: E/AndroidRuntime(559): at android.os.Handler.dispatchMessage(Handler.java:99)
02-10 19:00:00.518: E/AndroidRuntime(559): at android.os.Looper.loop(Looper.java:137)
02-10 19:00:00.518: E/AndroidRuntime(559): at android.app.ActivityThread.main(ActivityThread.java:4340)
02-10 19:00:00.518: E/AndroidRuntime(559): at java.lang.reflect.Method.invokeNative(Native Method)
02-10 19:00:00.518: E/AndroidRuntime(559): at java.lang.reflect.Method.invoke(Method.java:511)
02-10 19:00:00.518: E/AndroidRuntime(559): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
02-10 19:00:00.518: E/AndroidRuntime(559): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
02-10 19:00:00.518: E/AndroidRuntime(559): at dalvik.system.NativeStart.main(Native Method)
02-10 19:00:00.518: E/AndroidRuntime(559): Caused by: java.lang.ClassNotFoundException: converter.units.kitchen.menu
02-10 19:00:00.518: E/AndroidRuntime(559): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
02-10 19:00:00.518: E/AndroidRuntime(559): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
02-10 19:00:00.518: E/AndroidRuntime(559): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
02-10 19:00:00.518: E/AndroidRuntime(559): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
02-10 19:00:00.518: E/AndroidRuntime(559): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1870)
02-10 19:00:00.518: E/AndroidRuntime(559): ... 11 more

I have no idea where all this came from as I had it working fine when multiplying two integers together, I then tried to make 3 seperate outputs with different multipliers and this happened. Another app also stops working as soon as it uploads, could there be a more general problem?

Thank you in advance for your help
 
02-10 19:00:00.518: E/AndroidRuntime(559): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{converter.units.kitchen/converter.units.kitchen.menu}: java.lang.ClassNotFoundException: converter.units.kitchen.menu

This is the critical line. It's saying that Android is trying to start an activity converters.units.kitchen.menu, but that class doesn't exist.

This is a symptom of a misconfiguration in your AndroidManifest.xml. (One of) your activities in this XML file will have MAIN action and LAUNCHER category its intent filter. This activity is the one that launches when a user taps your app from the launcher. The android:name attribute of this activity is currently "converter.units.kitchen.menu", or possibly ".menu" with the package attribute of the root manifest element being "converter.units.kitchen". You don't have a menu class (case sensitive) in the converter.units.kitchen package.

Either change AndroidManifest.xml to match your code, or change your code to match AndroidManifest.xml.
 
If you haven't messed around with your activities you can try Project -> Clean in eclipse. This will rebuild your app.
 
Thank you both for your help, with which I have been able to get the app working on the emulator again.

An error I get often when first starting a build, but an app I've been working on for a while is now plagued with too is

'R cannont be resolved to a variable'

in all the java files. It seems to come out of nowhere and I often have to paste all my code into a new project to get rid of it. I know it has been asked before on forums because I must have read nearly all of the posts! I have tried putting

//import android.R;

which does work sometimes but didn't today.

Sorry if this is a regularly asked question with a simple answer but I have done a lot of searching around for an answer all ready.

Thank you in anticipation
 
If R cannot be resolved to a variable, you have errors in your project, most likely in some xml file.
 
I fixed it by altering the CATEGORY in the manifest which I think was for some reason missing some words, not that I know why this should have caused that error.

Thanks
 
Back
Top Bottom