I Googled my problem but I can't find a solution.
When I try to create a signed APK, I get this error:
Error:(6) Error: Suspicious namespace and prefix combination [NamespaceTypo]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Explanation for issues of type "NamespaceTypo":
track these down.
xmlns:app="http://schemas.android.com/tools"
obscure error messages. This check looks for potential misspellings to help
Accidental misspellings in namespace declarations can lead to some very
This is the fragment of this layout file:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/tools"
app:layout_behavior="@null"
android:layout_gravity="bottom|right">
change the code xmlns:app="http://schemas.android.com/tools" with this:
xmlns:app="http://schemas.android.com/apk/res-auto"
It made mine work.
Your first two lines of the xml code are incorrect. The whole xml file should look as follows:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/tools"
app:layout_behavior="@null"
android:layout_gravity="bottom|right">
The first 2 lines are the declaration of the xml file. Although you are able to view the actual layout of the page in the design view, the layout itslef would still have issues when being built since it needs the xml tools tag.
The purpose of this namespace is to be able to record information in XML files, and have that information stripped when the application is packaged such that there is no runtime or download size penalty. It is a dedicated Android XML namespace.
Hope this helps :)
The tools
namespace should be used for the preview tools of the xml on android studio. For example, if you are testing a view that is hidden by default, but you want to see it on your preview you should use tools:visibility=visible
.
The app
namespace, as far as I know, is used to add your custom views and layouts to the namespace of the xml you want to add your views.
So all your answers are correct, but I think no one explained what the namespaces do. So for convention I recommend to use them like this:
xmlns:yourAppName="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With