LinearLayout element must be declared

I updated my android studio and now I have a problem in my main.xml, it displays the following error: element LinearLayout must be declared

this is my code:

 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="fill_parent" android:layout_width="fill_parent" android:gravity="center_vertical|center_horizontal" > <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/monBouton" android:text="Cliquez ici !" > </Button> </LinearLayout> 

this error message: Error: execution completed for task ': app: compileDebugJava'.

Compilation error; see compiler error output for details.

error: cannot find character variable action_settings

How can I solve it?

+7
android-studio android-linearlayout
source share
3 answers

Make sure your action_settings defined inside the xml menu file

 res/menu/yourmenufile.xml 

like this:

 <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" tools:context="com.example.app" > <item android:id="@+id/action_settings" android:title="@string/action_settings" android:orderInCategory="100" app:showAsAction="never" /> </menu> 
+3
source share

Your layout files should be in the res/layout folder.

Provision of resources

+13
source share

There was the same mistake. The problem was that in the layout dialog in the menu folder instead of the layout folder

+4
source share

All Articles