Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Suspicious namespace and prefix combination [NamespaceTypo] when I try create Signed APK

Tags:

android

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">
like image 299
Artem Avatar asked Dec 08 '15 15:12

Artem


3 Answers

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.

like image 115
Sujeet Kumar Mehta Avatar answered Nov 01 '22 17:11

Sujeet Kumar Mehta


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 :)

like image 23
Michele La Ferla Avatar answered Nov 01 '22 16:11

Michele La Ferla


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"
like image 4
Tofasio Avatar answered Nov 01 '22 17:11

Tofasio