It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
My main class:
package com.example.hi;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class SampleLogin extends Activity {
EditText txtUserName;
EditText txtPassword;
Button btnLogin;
Button btnCancel;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
txtUserName=(EditText)this.findViewById(R.id.txtUname);
txtPassword=(EditText)this.findViewById(R.id.txtPwd);
btnLogin=(Button)this.findViewById(R.id.btnLogin);
btnLogin=(Button)this.findViewById(R.id.btnLogin);
btnLogin.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
if((txtUserName.getText().toString()).equals(txtPassword.getText().toString())){
Toast.makeText(SampleLogin.this, "Login Successful",Toast.LENGTH_LONG).show();
} else{
Toast.makeText(SampleLogin.this, "Invalid Login",Toast.LENGTH_LONG).show();
}
}
});
}
}
My XML file...
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="1">
<TableRow>
<TextView
android:text="#string/User_Name: "
android:id="#+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
<EditText
android:inputType="textPassword|number"
android:text=""
android:id="#+id/txtUname"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</EditText>
</TableRow>
<TableRow>
<TextView
android:text="#string/Password: "
android:id="#+id/TextView02"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
<EditText
android:inputType="textPassword|number"
android:text=""
android:id="#+id/txtPwd"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</TableRow>
<TableRow>
<Button
android:text="#string/Cancel"
android:id="#+id/btnCancel"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</Button>
<Button
android:text="#string/Login"
android:id="#+id/btnLogin"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</Button>
</TableRow>
</TableLayout>
So here is my code for some reason the application stops working when I open it, the "application () has stopped unexpectedly. please try again avd... " I have no idea why that is happening, help please!
I'm new to android, can someone tell me how do I get the catlog file?
About the Strings on the xml file, again I'm new to this, I was getting an error about "hard coded string" or something like that and it said I needed to add it to the strings file found in the res folder so I added the strings and then added the #string
CatLog File:
12-28 17:36:50.883: E/Zygote(33): setreuid() failed. errno: 2
12-28 17:37:00.573: E/Zygote(33): setreuid() failed. errno: 17
12-28 17:37:01.933: E/BatteryService(61): usbOnlinePath not found
12-28 17:37:01.933: E/BatteryService(61): batteryVoltagePath not found
12-28 17:37:01.933: E/BatteryService(61): batteryTemperaturePath not found
12-28 17:37:01.953: E/SurfaceFlinger(61): Couldn't open /sys/power/wait_for_fb_sleep or /sys/power/wait_for_fb_wake
12-28 17:37:02.173: E/SensorService(61): couldn't open device for module sensors (Invalid argument)
12-28 17:37:06.682: E/System(61): Failure starting core service
12-28 17:37:06.682: E/System(61): java.lang.SecurityException
12-28 17:37:06.682: E/System(61): at android.os.BinderProxy.transact(Native Method)
12-28 17:37:06.682: E/System(61): at android.os.ServiceManagerProxy.addService(ServiceManagerNative.java:146)
12-28 17:37:06.682: E/System(61): at android.os.ServiceManager.addService(ServiceManager.java:72)
12-28 17:37:06.682: E/System(61): at com.android.server.ServerThread.run(SystemServer.java:206)
12-28 17:37:06.712: E/EventHub(61): could not get driver version for /dev/input/mouse0, Not a typewriter
12-28 17:37:06.712: E/EventHub(61): could not get driver version for /dev/input/mice, Not a typewriter
12-28 17:37:07.122: E/SoundPool(61): error loading /system/media/audio/ui/Effect_Tick.ogg
12-28 17:37:07.122: E/SoundPool(61): error loading /system/media/audio/ui/KeypressStandard.ogg
12-28 17:37:07.122: E/SoundPool(61): error loading /system/media/audio/ui/KeypressSpacebar.ogg
12-28 17:37:07.122: E/SoundPool(61): error loading /system/media/audio/ui/KeypressDelete.ogg
12-28 17:37:07.122: E/SoundPool(61): error loading /system/media/audio/ui/KeypressReturn.ogg
12-28 17:37:07.164: E/UsbObserver(61): java.lang.NullPointerException
12-28 17:37:07.164: E/UsbObserver(61): at com.android.server.UsbObserver.init(UsbObserver.java:131)
12-28 17:37:07.164: E/UsbObserver(61): at com.android.server.UsbObserver.<init>(UsbObserver.java:65)
12-28 17:37:07.164: E/UsbObserver(61): at com.android.server.ServerThread.run(SystemServer.java:402)
12-28 17:37:07.673: E/ThrottleService(61): Could not open GPS configuration file /etc/gps.conf
12-28 17:37:08.392: E/logwrapper(135): executing /system/bin/tc failed: No such file or directory
12-28 17:37:08.392: E/logwrapper(136): executing /system/bin/tc failed: No such file or directory
12-28 17:37:08.432: E/logwrapper(138): executing /system/bin/tc failed: No such file or directory
12-28 17:37:35.198: E/AndroidRuntime(335): FATAL EXCEPTION: main
12-28 17:37:35.198: E/AndroidRuntime(335): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.hi/com.example.hi.MainActivity}: java.lang.ClassNotFoundException: com.example.hi.MainActivity in loader dalvik.system.PathClassLoader[/data/app/com.example.hi-1.apk]
12-28 17:37:35.198: E/AndroidRuntime(335): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)
12-28 17:37:35.198: E/AndroidRuntime(335): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
12-28 17:37:35.198: E/AndroidRuntime(335): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
12-28 17:37:35.198: E/AndroidRuntime(335): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
12-28 17:37:35.198: E/AndroidRuntime(335): at android.os.Handler.dispatchMessage(Handler.java:99)
12-28 17:37:35.198: E/AndroidRuntime(335): at android.os.Looper.loop(Looper.java:123)
12-28 17:37:35.198: E/AndroidRuntime(335): at android.app.ActivityThread.main(ActivityThread.java:3683)
12-28 17:37:35.198: E/AndroidRuntime(335): at java.lang.reflect.Method.invokeNative(Native Method)
12-28 17:37:35.198: E/AndroidRuntime(335): at java.lang.reflect.Method.invoke(Method.java:507)
12-28 17:37:35.198: E/AndroidRuntime(335): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
12-28 17:37:35.198: E/AndroidRuntime(335): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
12-28 17:37:35.198: E/AndroidRuntime(335): at dalvik.system.NativeStart.main(Native Method)
12-28 17:37:35.198: E/AndroidRuntime(335): Caused by: java.lang.ClassNotFoundException: com.example.hi.MainActivity in loader dalvik.system.PathClassLoader[/data/app/com.example.hi-1.apk]
12-28 17:37:35.198: E/AndroidRuntime(335): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
12-28 17:37:35.198: E/AndroidRuntime(335): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
12-28 17:37:35.198: E/AndroidRuntime(335): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
12-28 17:37:35.198: E/AndroidRuntime(335): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
12-28 17:37:35.198: E/AndroidRuntime(335): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
12-28 17:37:35.198: E/AndroidRuntime(335): ... 11 more
12-28 17:38:05.517: E/AndroidRuntime(344): FATAL EXCEPTION: main
12-28 17:38:05.517: E/AndroidRuntime(344): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.hi/com.example.hi.MainActivity}: java.lang.ClassNotFoundException: com.example.hi.MainActivity in loader dalvik.system.PathClassLoader[/data/app/com.example.hi-1.apk]
12-28 17:38:05.517: E/AndroidRuntime(344): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)
12-28 17:38:05.517: E/AndroidRuntime(344): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
12-28 17:38:05.517: E/AndroidRuntime(344): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
12-28 17:38:05.517: E/AndroidRuntime(344): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
12-28 17:38:05.517: E/AndroidRuntime(344): at android.os.Handler.dispatchMessage(Handler.java:99)
12-28 17:38:05.517: E/AndroidRuntime(344): at android.os.Looper.loop(Looper.java:123)
12-28 17:38:05.517: E/AndroidRuntime(344): at android.app.ActivityThread.main(ActivityThread.java:3683)
12-28 17:38:05.517: E/AndroidRuntime(344): at java.lang.reflect.Method.invokeNative(Native Method)
12-28 17:38:05.517: E/AndroidRuntime(344): at java.lang.reflect.Method.invoke(Method.java:507)
12-28 17:38:05.517: E/AndroidRuntime(344): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
12-28 17:38:05.517: E/AndroidRuntime(344): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
12-28 17:38:05.517: E/AndroidRuntime(344): at dalvik.system.NativeStart.main(Native Method)
12-28 17:38:05.517: E/AndroidRuntime(344): Caused by: java.lang.ClassNotFoundException: com.example.hi.MainActivity in loader dalvik.system.PathClassLoader[/data/app/com.example.hi-1.apk]
12-28 17:38:05.517: E/AndroidRuntime(344): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
12-28 17:38:05.517: E/AndroidRuntime(344): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
12-28 17:38:05.517: E/AndroidRuntime(344): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
12-28 17:38:05.517: E/AndroidRuntime(344): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
12-28 17:38:05.517: E/AndroidRuntime(344): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
12-28 17:38:05.517: E/AndroidRuntime(344): ... 11 more
It doesn't crash anymore but I can't type anything!! I changed something on the xml file about typing because it was giving me a problem
android:inputType="textPassword|number"
I think it was this but when I try to type something it does nothing!
Is this supposed to work?
<EditText
android:inputType="textPassword|number"
android:text=""
android:id="#+id/txtPwd"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<EditText
android:inputType="textPassword|number"
android:text=""
android:id="#+id/txtUname"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
From your LogCat:
Caused by: java.lang.ClassNotFoundException: com.example.hi.MainActivity in loader dalvik.system.PathClassLoader[/data/app/com.example.hi-1.apk]
This means that you probably changed your class name to SampleLogin from MainActivity but forgot to update your manifest.
Update the manifest to look like this:
<activity
android:name=".SampleLogin"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
(You will also need to address android:text="#string/User_Name: " and android:text="#string/Password: " as I mentioned in the comments before you can compile your app again.)
You should see the LogCat to know what is the error exactly.
The only thing I can spot in your code is that you are initilizing the btnLogin twice and missing the initialization of btnCancel. This would not be the source of the error unless you are using btnCancel object somewhere.
btnLogin=(Button)this.findViewById(R.id.btnLogin);
btnLogin=(Button)this.findViewById(R.id.btnLogin);
If you can post the error from LogCat, it will be easier to help.
Edit
In your layout XML file you have something looks odd
android:text="#string/Password: "
android:id="#+id/TextView01"
There are not appropriate name for resources it should be all small letters with only underscore as word separator if needed.
Related
I don't know why the app crashes whenever it's supposed to go to the next Activity. I made a practice app that works as it should when using the same format. I uploaded the files to gist.github.
The error is
1216-1216/com.example.chiozokamalu.newfreshstart E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.ArrayIndexOutOfBoundsException
at com.example.chiozokamalu.newfreshstart.MainActivity.onClick(MainActivity.java:164)
at android.view.View.performClick(View.java:2485)
at android.view.View$PerformClick.run(View.java:9080)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
On line 164 of MainActivity.java:
questionView.setText(questions[questionIndex]); // set the text to the next question
EDIT: After Varun helped me, I get a new error which is
1307-1307/com.example.chiozokamalu.newfreshstart E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.chiozokamalu.newfreshstart/com.example.chiozokamalu.newfreshstart.Results1}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
at android.app.ActivityThread.access$1500(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.example.chiozokamalu.newfreshstart.Results1.onCreate(Results1.java:58)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
at android.app.ActivityThread.access$1500(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
The questions array at line no. 164 is going out of bound that means questionIndex is greater than the total length of the questions array. So you should add a check on the length before extracting value from the array.
You have added the check but after that you incremented the value so either you modify the if condition to if (questionIndex < questions.length -1)
or modify the questionIndex variable before the if condition
You are getting problem because you haven't initiated resultView9 that is why it is null and giving nullpointer, just initiatlise it as you done with other and everything is fine. You have initialised the resultView8 twice just add resultview9 over there
So... I'm developing an app and I had to change my project in order to add the Google API (and I wanted to change the name of the project too).
I copied/pasted the code into a new project and even though Eclipse isn't showing any error, I'm getting one in the logCat.
12-28 23:10:44.945: E/AndroidRuntime(1259): FATAL EXCEPTION: main
12-28 23:10:44.945: E/AndroidRuntime(1259): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{eu.nigsia.christianismissues/eu.nigsia.christianismsissues.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "eu.nigsia.christianismsissues.MainActivity" on path: DexPathList[[zip file "/data/app/eu.nigsia.christianismissues-1.apk"],nativeLibraryDirectories=[/data/app-lib/eu.nigsia.christianismissues-1, /vendor/lib, /system/lib]]
12-28 23:10:44.945: E/AndroidRuntime(1259): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
12-28 23:10:44.945: E/AndroidRuntime(1259): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
12-28 23:10:44.945: E/AndroidRuntime(1259): at android.app.ActivityThread.access$600(ActivityThread.java:141)
12-28 23:10:44.945: E/AndroidRuntime(1259): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
12-28 23:10:44.945: E/AndroidRuntime(1259): at android.os.Handler.dispatchMessage(Handler.java:99)
12-28 23:10:44.945: E/AndroidRuntime(1259): at android.os.Looper.loop(Looper.java:137)
12-28 23:10:44.945: E/AndroidRuntime(1259): at android.app.ActivityThread.main(ActivityThread.java:5103)
12-28 23:10:44.945: E/AndroidRuntime(1259): at java.lang.reflect.Method.invokeNative(Native Method)
12-28 23:10:44.945: E/AndroidRuntime(1259): at java.lang.reflect.Method.invoke(Method.java:525)
12-28 23:10:44.945: E/AndroidRuntime(1259): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
12-28 23:10:44.945: E/AndroidRuntime(1259): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
12-28 23:10:44.945: E/AndroidRuntime(1259): at dalvik.system.NativeStart.main(Native Method)
12-28 23:10:44.945: E/AndroidRuntime(1259): Caused by: java.lang.ClassNotFoundException: Didn't find class "eu.nigsia.christianismsissues.MainActivity" on path: DexPathList[[zip file "/data/app/eu.nigsia.christianismissues-1.apk"],nativeLibraryDirectories=[/data/app-lib/eu.nigsia.christianismissues-1, /vendor/lib, /system/lib]]
12-28 23:10:44.945: E/AndroidRuntime(1259): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
12-28 23:10:44.945: E/AndroidRuntime(1259): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
12-28 23:10:44.945: E/AndroidRuntime(1259): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
12-28 23:10:44.945: E/AndroidRuntime(1259): at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
12-28 23:10:44.945: E/AndroidRuntime(1259): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
12-28 23:10:44.945: E/AndroidRuntime(1259): ... 11 more
Any Ideas?
When i'm trying to run my application i receive the error as The application Sample 2 (com.example.sample2) has stopped unexpectedly. Please try again Force close error. Logcat error is given below
02-07 03:46:52.292: I/Process(275): Sending signal. PID: 275 SIG: 9
02-07 03:47:01.045: D/AndroidRuntime(335): Shutting down VM
02-07 03:47:01.045: W/dalvikvm(335): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
02-07 03:47:01.106: E/AndroidRuntime(335): FATAL EXCEPTION: main
02-07 03:47:01.106: E/AndroidRuntime(335): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.projectsample1/com.example.projectsample1.MainActivity}: java.lang.ClassNotFoundException: com.example.projectsample1.MainActivity in loader dalvik.system.PathClassLoader[/data/app/com.example.projectsample1-1.apk]
02-07 03:47:01.106: E/AndroidRuntime(335): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
02-07 03:47:01.106: E/AndroidRuntime(335): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
02-07 03:47:01.106: E/AndroidRuntime(335): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
02-07 03:47:01.106: E/AndroidRuntime(335): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
02-07 03:47:01.106: E/AndroidRuntime(335): at android.os.Handler.dispatchMessage(Handler.java:99)
02-07 03:47:01.106: E/AndroidRuntime(335): at android.os.Looper.loop(Looper.java:123)
02-07 03:47:01.106: E/AndroidRuntime(335): at android.app.ActivityThread.main(ActivityThread.java:4627)
02-07 03:47:01.106: E/AndroidRuntime(335): at java.lang.reflect.Method.invokeNative(Native Method)
02-07 03:47:01.106: E/AndroidRuntime(335): at java.lang.reflect.Method.invoke(Method.java:521)
02-07 03:47:01.106: E/AndroidRuntime(335): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
02-07 03:47:01.106: E/AndroidRuntime(335): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
02-07 03:47:01.106: E/AndroidRuntime(335): at dalvik.system.NativeStart.main(Native Method)
02-07 03:47:01.106: E/AndroidRuntime(335): Caused by: java.lang.ClassNotFoundException: com.example.projectsample1.MainActivity in loader dalvik.system.PathClassLoader[/data/app/com.example.projectsample1-1.apk]
02-07 03:47:01.106: E/AndroidRuntime(335): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
02-07 03:47:01.106: E/AndroidRuntime(335): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
02-07 03:47:01.106: E/AndroidRuntime(335): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
02-07 03:47:01.106: E/AndroidRuntime(335): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
02-07 03:47:01.106: E/AndroidRuntime(335): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
02-07 03:47:01.106: E/AndroidRuntime(335): ... 11 more
02-07 03:52:01.252: I/Process(335): Sending signal. PID: 335 SIG: 9
Initially, this application was working well. But after a few days, it stopped working giving the above error. I don't seem to understand what is wrong. Please help me.
You have done one of two things:
Renamed your activity package or class name and not updated it in the manifest
or
Changed your manifest to reflect an activity that doesn't exist
Check your manifest against the fully qualified class name for that Activity. Make sure they match. Then go to Project -> Clean and clean your project.
I think, you declared Activity in AndroidManifes.xml, and register it as default to launch in your application. But, you have no Activity with this name as you declared in manifest. Just correct activity name in AndroidManifest.xml
Here is the error:
java.lang.ClassNotFoundException: com.example.projectsample1.MainActivity
The MainActivity class of the projectsample1 Application was not found.
Try to clear the dalvik-cache if you know how to do it.
Otherwise, re-install the application.
Or if you are the developer of the application, make sure to change the name of the class in the Manifest.xml file if you changed the name of the MainActivity class.
I'm trying to add a bookmark from my application using Browser.saveBookmark
protected void saveBookmark(String title, String url){
Browser.saveBookmark(this, title, url);
}
The window where the user can modify my title and press "Save bookmark" displays correctly, but when I press save, the browser closes unexpectedly
12-28 18:07:20.864: E/AndroidRuntime(560): java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
12-28 18:07:20.864: E/AndroidRuntime(560): at android.os.Handler.<init>(Handler.java:121)
12-28 18:07:20.864: E/AndroidRuntime(560): at android.webkit.WebIconDatabase$EventHandler.<init>(WebIconDatabase.java:46)
12-28 18:07:20.864: E/AndroidRuntime(560): at android.webkit.WebIconDatabase$EventHandler.<init>(WebIconDatabase.java:46)
12-28 18:07:20.864: E/AndroidRuntime(560): at android.webkit.WebIconDatabase.<init>(WebIconDatabase.java:43)
12-28 18:07:20.864: E/AndroidRuntime(560): at android.webkit.WebIconDatabase.getInstance(WebIconDatabase.java:293)
12-28 18:07:20.864: E/AndroidRuntime(560): at com.android.browser.Bookmarks.addBookmark(Bookmarks.java:136)
12-28 18:07:20.864: E/AndroidRuntime(560): at com.android.browser.AddBookmarkPage$SaveBookmarkRunnable.run(AddBookmarkPage.java:136)
12-28 18:07:20.864: E/AndroidRuntime(560): at java.lang.Thread.run(Thread.java:1096)
I'm calling this action from the UI thread, so I don't know what's happening.
I've tried using the WRITE_HISTORY_BOOKMARKS permission
<uses-permission android:name="com.android.browser.permission.WRITE_HISTORY_BOOKMARKS" />
but nothing changes.
I've tested this on an emulator and a Galaxy S.
Looks like this might be a bug in earlier versions of Android
http://code.google.com/p/android/issues/detail?id=11291
I've been trying to get started with Android programming for a while now. I'm mainly a .NET developer with no Java experience for 8 years (university).
I can compile and run samples no problem but the moment I try and rename my package/class it fails. I believe I've updated the manifest and triple checked it (Copied and pasted name, selected it with Eclipse) yet it always fails with a java.lang.ClassNotFoundException:
12-02 09:12:21.088: ERROR/AndroidRuntime(233): Uncaught handler: thread main exiting due to uncaught exception
12-02 09:12:21.178: ERROR/AndroidRuntime(233): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{org.anddev.cheesemp.helloandworld/org.anddev.cheesemp.helloandworld.HelloAndEngine}: java.lang.ClassNotFoundException: org.anddev.cheesemp.helloandworld.HelloAndEngine in loader dalvik.system.PathClassLoader#43d0c0d0
12-02 09:12:21.178: ERROR/AndroidRuntime(233): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2417)
12-02 09:12:21.178: ERROR/AndroidRuntime(233): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
12-02 09:12:21.178: ERROR/AndroidRuntime(233): at android.app.ActivityThread.access$2200(ActivityThread.java:119)
12-02 09:12:21.178: ERROR/AndroidRuntime(233): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
12-02 09:12:21.178: ERROR/AndroidRuntime(233): at android.os.Handler.dispatchMessage(Handler.java:99)
12-02 09:12:21.178: ERROR/AndroidRuntime(233): at android.os.Looper.loop(Looper.java:123)
12-02 09:12:21.178: ERROR/AndroidRuntime(233): at android.app.ActivityThread.main(ActivityThread.java:4363)
12-02 09:12:21.178: ERROR/AndroidRuntime(233): at java.lang.reflect.Method.invokeNative(Native Method)
12-02 09:12:21.178: ERROR/AndroidRuntime(233): at java.lang.reflect.Method.invoke(Method.java:521)
12-02 09:12:21.178: ERROR/AndroidRuntime(233): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
12-02 09:12:21.178: ERROR/AndroidRuntime(233): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
12-02 09:12:21.178: ERROR/AndroidRuntime(233): at dalvik.system.NativeStart.main(Native Method)
12-02 09:12:21.178: ERROR/AndroidRuntime(233): Caused by: java.lang.ClassNotFoundException: org.anddev.cheesemp.helloandworld.HelloAndEngine in loader dalvik.system.PathClassLoader#43d0c0d0
12-02 09:12:21.178: ERROR/AndroidRuntime(233): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
12-02 09:12:21.178: ERROR/AndroidRuntime(233): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
12-02 09:12:21.178: ERROR/AndroidRuntime(233): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
12-02 09:12:21.178: ERROR/AndroidRuntime(233): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
12-02 09:12:21.178: ERROR/AndroidRuntime(233): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2409)
12-02 09:12:21.178: ERROR/AndroidRuntime(233): ... 11 more
Manifest is here:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1"
android:versionName="1.0" package="org.anddev.cheesemp.helloandworld">
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:label="#string/app_name" android:name="org.anddev.cheesemp.helloandworld.HelloAndEngine">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="4" \>
</manifest>
Class definition is here:
package org.anddev.cheesemp.helloandworld;
import org.anddev.andengine.engine.Engine;
import org.anddev.andengine.engine.camera.Camera;
import org.anddev.andengine.engine.options.EngineOptions;
import org.anddev.andengine.engine.options.EngineOptions.ScreenOrientation;
import org.anddev.andengine.engine.options.resolutionpolicy.RatioResolutionPolicy;
import org.anddev.andengine.entity.scene.Scene;
import org.anddev.andengine.entity.scene.background.ColorBackground;
import org.anddev.andengine.entity.text.Text;
import org.anddev.andengine.entity.util.FPSLogger;
import org.anddev.andengine.opengl.font.Font;
import org.anddev.andengine.opengl.texture.Texture;
import org.anddev.andengine.opengl.texture.TextureOptions;
import org.anddev.andengine.ui.activity.BaseGameActivity;
import org.anddev.andengine.util.HorizontalAlign;
import android.graphics.Color;
import android.graphics.Typeface;
/**
* #author Nicolas Gramlich
* #since 11:54:51 - 03.04.2010
*/
public class HelloAndEngine extends BaseGameActivity
This sample is from AndEngine but I've had the same issue with every sample I modify. I can't help but feel I've missed something and nothing I found searching has helped.
Any advice appreciated!
Try this.
<activity android:label="#string/app_name" android:name=".HelloAndEngine">
You don't need the fully qualified class name. Also, if you are working with Eclipse and rename a package go to Project → Clean and let it clean up your project, fixing up references and so on if anything is broken.
This is a bug in eclipse android tools
http://code.google.com/p/android/issues/detail?id=2824
To Fix -> Right click on the project go to Android tools -> Rename application package..
And also check AndroidManifest.xml if it updated correctly, in my case it didn't, that should solve this problem