0

I am new to Android Studio and can't seem to get my xml document to work, the KT file runs fine but I am not able to get my design view to display for me to add more textboxes/constraints. I have tried almost everything online to find a solution. Even the "Invalidate Cache/Restart" method I did. Still nothing. Now I have just errors on line 2 saying "element <androidx.constraintlayout.widget.ConstraintLayout must be declared" and I get another error for every TextView and EditText in the code. Please help me with what I may be doing wrong or even if its a simple thing.

ManifestXML Lines 1-35

ManifestXML Lines 35+

MainActivity KT

Axifive
1,1512 gold badges19 silver badges31 bronze badges
asked Jan 18, 2020 at 3:54
5
  • R u able build your project? Commented Jan 18, 2020 at 3:59
  • You made a pretty large mistake somewhere. You are supposed to put your layout files in the res > layout directory, not in the manifest file. The manifest is used to declare all the components of your app such as activities, broadcast receivers or permissions. Please read more about how to properly set up your manifest file here: developer.android.com/guide/topics/manifest/manifest-intro and the layout directory here: developer.android.com/guide/topics/resources/… Commented Jan 18, 2020 at 4:14
  • No, I am not able to run it. I did part of it in class. Then saved it and did it on my laptop now. Commented Jan 19, 2020 at 22:00
  • I would suggest you to create a new project with a blank activity, then select Android from the dropdown where Project is selected. Now, with the new project and in Android mode, Your project structure will look like this. The layout will be under res->layout and all layout comes here. The manifest.xml lists all your activities, services, permissions and app's special settings. It doesn't contain your layout. You'll learn more as you'll go. Commented May 31, 2020 at 5:07
  • Now, First, copy your layout from manifest.xml into your activity_main.xml which is under res-> layout. You can easily access it by clicking on activity_main in your class, click should be ctrl+left mouse click. With the new project, you can copy its manifest in your existing project's manifest.xml to correct it, don't forget to change your app name in it, other things will be same for a new project. This will fix the errors. Commented May 31, 2020 at 5:14

1 Answer 1

1

The Mainfest file is not supposed work like that. Check this out to know more about the Manifest file: https://developer.android.com/guide/topics/manifest/manifest-intro

All of your design part, like the layouts for every activity/fragment should mostly be inside the res>layout. Notice the setContentView in your MainActivity.kt, it includes the activity_main.xml file which is where you should put your design(XML) code.

answered Jan 18, 2020 at 7:25
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.