-1

Okay, so I opened android studio and created new project of empty activity. I changed the layout of xml and modified the xml code without typing a single word in java file and run the android emulator and emulator works properly, but whenever I typed something (i.e. according to java code) in java file and run the android emulator, app crashes everytime. I cant figure it out, what is happening with the java file. plz assist me...

a_local_nobody
  • 7,947
  • 5
  • 29
  • 51
aw_santo
  • 17
  • 3
  • nothing you've posted so far actually helps us figure out what's wrong. find the stack trace, research the error, resolve it yourself so that you don't have these issues in future. when posting here on SO, you need to include enough _relevant_ detail for us to recreate here, at the moment, you haven't _nearly_ done that – a_local_nobody Apr 30 '21 at 08:57
  • ok, got it! I'll try to be more relevant next time – aw_santo Apr 30 '21 at 09:00
  • always ask yourself if you'd be able to understand/recreate your own question without any knowledge of the situation. you are welcome to [edit](https://stackoverflow.com/posts/67330918/edit) your post to add more detail – a_local_nobody Apr 30 '21 at 09:02

1 Answers1

1

Does this java file appear in AndroidManifest.xml? You can find this file in the directory app/manifests. For each java file associated with an activity, an activity entry must be made in this file. This manifest file is what let's your app know which activities it can run. Thus, if you try to run code for an activity that is not defined in the manifest, the app crashes immediately. If your java activity is called "ActivityOne", you want to have inside the .. /> tags of this file.

Here is what the AndroidManifest should look like for an app with a MainActivity and another activity named "ActivityOne"

Additionally, you can click "run" on the bottom bar in android studio to view the application output as it runs. Error messages upon app crashes will also be displayed here. Posting a screenshot of your error message along with your word description of the problem is the best way to ensure that those who want to help you have enough information to do so.

This is what the bottom bar and "run" button look like, as well as an example of a live application output stream

If the problem does not appear to be with AndroidManifest, please post a follow up with a picture of your error message.

Nic
  • 11
  • 1