After migrating from Eclipse to the new version of Android Studio 3.2, API 28, I am getting the following error on my app's layout:
The layout in layout has no declaration in the base layout folder; this can lead to crashes when the resource is queried in a configuration that does not match this qualifier
One of the layouts that I am getting this error is:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:background="@null" > <FrameLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <ImageView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="top|center_horizontal" android:adjustViewBounds="true" android:contentDescription="@string/hello_world" android:src="@drawable/loading_top" /> <ImageView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom|center_horizontal" android:adjustViewBounds="true" android:contentDescription="@string/hello_world" android:src="@drawable/loading_bottom" /> <ImageView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center" android:contentDescription="@string/hello_world" android:background="@color/white" android:layout_marginBottom="5dp" android:paddingTop="10dp" android:paddingBottom="10dp" android:src="@drawable/loading_logo" /> <ImageView android:id="@+id/loading" android:layout_width="fill_parent" android:layout_height="match_parent" android:layout_gravity="center|center_vertical" android:layout_marginBottom="0dp" android:layout_marginTop="0dp" android:contentDescription="@string/hello_world" android:scaleType="fitXY" android:src="@null" /> </FrameLayout> </LinearLayout>
I get the error on the first line of the first LinearLayout.
Does anyone know how to solve this error?
UPDATE: It seems to a be an encoding issue. I had copied the xml files in the folder using Windows Explorer. After deleting the files and coping them inside Android Studio, the problem has been solved.
In my case closing and reopening Android studio solved the problem. Rebuilding the project or Invalidating the cache didn't help.
You can also try this :
File => Invalidate Caches / Restart => Invalidate and Restart.
In my case it was the use of capital letters in the file name. I left everything in lowercase and it was fixed.
If you devise your layout : layout-sw320dp layout-sw480dp layout-sw600dp layout-sw720dp
you should add layout by default like thise:
In my case i resolved that with this:
the Android say me this id-error:MissingDefaultResource as documentation say:
If a resource is only defined in folders with qualifiers like -land or -en, and there is no default declaration in the base folder (layout or values etc), then the app will crash if that resource is accessed on a device where the device is in a configuration missing the given qualifier.
As a special case, drawables do not have to be specified in the base folder; if there is a match in a density folder (such as drawable-mdpi) that image will be used and scaled. Note however that if you only specify a drawable in a folder like drawable-en-hdpi, the app will crash in non-English locales.
There may be scenarios where you have a resource, such as a -fr drawable, which is only referenced from some other resource with the same qualifiers (such as a -fr style), which itself has safe fallbacks. However, this still makes it possible for somebody to accidentally reference the drawable and crash, so it is safer to create a default dummy fallback in the base folder. Alternatively, you can suppress the issue by adding tools:ignore="MissingDefaultResource" on the element.
(This scenario frequently happens with string translations, where you might delete code and the corresponding resources, but forget to delete a translation. There is a dedicated issue id for that scenario, with the id ExtraTranslation.)
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingDefaultResource" <!--this--> android:layout_width="match_parent" android:layout_height="match_parent">
But this is the easy solution, 'cause you make missing the resourse in Android.
I resolve this with file system option. If Android tell you about missing resourse meaning some thing is missing and you should replenish that.
you should be go to \app\src\main\res
maybe: right click in file's missing folder, show in Exporer,and go back to \app\src\main\res
You should be find
/layout /layout-normal /layout-large /some more folders
You should be find where do the files is missing. In my case that's missing in /layout
I received this error when moving layout files between Gradle modules. I didn't have to go so far as to invalidate caches as it resolved itself when I restarted
Android Studio and cleaned the project. It seems likely to be an IDE bug.
In my case, this issue was caused by Uppercase letter. Wrong chars like "-" can also cause the issue.
I changed the name from
activity_disease.xml and the issue fixed.
Nothing worked for me like rebuilding the project or Invalidating the cache. In my case closing and reopening Android studio solved the problem.
I just did
Build > Clean Project
In my case it seems that Google used to expect (or at least accept) different names between different layouts; I had a
time_dialog.xml and a
time_dialog_landscape.xml. Renaming the latter to
time_dialog.xml fixed the problem.
I solved this issue by just syncing project with gradle
For me the following steps made it work:
- Cut all the code out of the page (ctrl+A+X for windows)
- Paste the code back.
This issue seems to be happening because studio or compiler is not able to find the resource file inside the base layout folder. To solve the problem you might need to create the file into different layout folders. If you are using layout folders v21, v25 etc. folders for designing layouts for different target devices then you also might need to place your resource files there too.
In my case this warning appeared due to "wrong" character (dot) used in value name:
Removing dots (right click on a name, then Refactor-Rename in Android Studio) resolved the problem.
Late to the party but My case is different from above.
I just renamed the resource and it started working.
Actually my resource name was ic_menu_black_24dp.xml so it was conflicting with the android's menu resource.
What worked for me is to remove the id attribute
android:id="@+id/[id same as filename]"
from the layout resource.
(1) Delete the original layout land (2) add layout land again [step] : https://i.stack.imgur.com/MyZr0.png
[step] : https://i.stack.imgur.com/GQQV5.png
What solved it for me:
In Android Studio, right-click on the filename in the layout directory, and choose Reformat code, with no special tickbox selected on the next screen.
Not sure what exactly goes on under the hood here, but that worked.