Jacob
Jacob

Reputation: 659

CORDOVA: Missing 'name' key attribute

I'm trying to create a simple Cordova plugin but when I try to BUILD it I get this error:

Missing 'name' key attribute on element uses-permission at AndroidManifest.xml:14:5-84 Missing 'name' key attribute on element uses-permission at AndroidManifest.xml:15:5-78 Missing 'name' key attribute on element uses-permission at AndroidManifest.xml:16:5-90 FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':processDebugManifest'.

    Manifest merger failed with multiple errors, see logs

This is my plugin's AndroidManifest.xml:

<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
    xmlns:android="http://schemas.android.com/apk/res/android"
    id="cordova-plugin-pluginTest"
    version="1.0.0">

  <description>
    Cordova Plugin
  </description>

    <license>MIT</license>

    <engines>
    <engine name="cordova" version=">=6.0" />
    </engines>

    <js-module src="www/index.js" name="index">
      <clobbers target="window.plugins.pluginTest" />
    </js-module><!--  -->

    <!-- android -->
    <platform name="android">
      <config-file target="res/xml/config.xml" parent="/*">
        <feature name="pluginTest">
          <param name="android-package" value="pluginTest.plugin.cordova.pluginTest"/>
        </feature>
      </config-file>
      <config-file target="AndroidManifest.xml" parent="/*">
        <uses-permission name="android.permission.WRITE_SETTINGS" platform="android"/>
        <uses-permission name="android.permission.INTERNET" platform="android"/>
        <uses-permission name="android.permission.ACCESS_NETWORK_STATE" platform="android"/>
        <uses-permission name="android.permission.CHANGE_NETWORK_STATE" platform="android"/>
        <uses-permission name="android.permission.ACCESS_WIFI_STATE" platform="android"/>
        <uses-permission name="android.permission.CHANGE_WIFI_STATE" platform="android"/>
      </config-file>

      <source-file src="src/android/pluginTest.java" target-dir="src/pluginTest/plugin/cordova"/>
    </platform>

</plugin>

What I'm doing wrong? Any suggestions?

Upvotes: 2

Views: 4079

Answers (2)

Ashwin
Ashwin

Reputation: 7657

In my case one of the category tag had an empty value like this:

<intent-filter>
    ...
    <category
        android:name="" />
</intent-filter>

So make sure none of the name attributes is empty in your AndroidManifest file.

Upvotes: 2

DaveAlden
DaveAlden

Reputation: 30366

You need to prefix the attribute name with the android: namespace. You can also get rid of platform="android" as it's unnecessary:

  <config-file target="AndroidManifest.xml" parent="/*">
    <uses-permission android:name="android.permission.WRITE_SETTINGS"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
  </config-file>

Upvotes: 4

Related Questions