Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cordova does not create AndroidManifest.xml

I am working in Cordova and AndroidStudio to create Android/iOS apps. Everything was working fine until I updated my Cordova to 8 yesterday. I also updated Node to the latest. When I create a Cordova project and add the Android platform. It yields a totally different directory structure. I cannot see assets, res and src folders in project's platform directory D:\testApp1\platforms\android. More importantly, the above directory is missing AndroidManifest.xml, which is causing the admob plugin to fail in getting added.

Here is the error that I get while adding the plugin:

Failed to install 'cordova-plugin-admobpro': Error: ENOENT: no such file or directory, open 'D:\Projects\testApp1\platforms\android\AndroidManifest.xml' at Object.fs.openSync (fs.js:646:18) at Object.fs.readFileSync (fs.js:551:33) at Object.parseElementtreeSync (D:\Projects\testApp1\platforms\android\cordova\node_modules\cordova-common\src\util\xml-helpers.js:180:27) at new AndroidManifest (D:\Projects\testApp1\platforms\android\cordova\lib\AndroidManifest.js:29:20) at AndroidProject.getPackageName (D:\Projects\testApp1\platforms\android\cordova\lib\AndroidProject.js:99:12) at Api.addPlugin (D:\Projects\testApp1\platforms\android\cordova\Api.js:223:57) at handleInstall (C:\Users\Rao\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\plugman\install.js:594:10) at C:\Users\Rao\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\plugman\install.js:357:28 at _fulfilled (C:\Users\Rao\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:787:54) at self.promiseDispatch.done (C:\Users\Rao\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:816:30)

Can someone please help?

like image 819
Kamran Avatar asked Dec 21 '17 14:12

Kamran


People also ask

Where is the AndroidManifest XML file?

It is located under android folder inside your monaca project as shown below: For Cordova 6.2 or higher, AndroidManifest.

Where is AndroidManifest XML in ionic?

xml ​ Android apps manage permissions, device features, and other settings in the AndroidManifest. xml file, which is located at android/app/src/main/AndroidManifest.

What is AndroidManifest XML?

The AndroidManifest. xml file contains information of your package, including components of the application such as activities, services, broadcast receivers, content providers etc.

Where is AndroidManifest XML in flutter?

Android app manifest file, AndroidManifest. xml is located in <app dir>/android/app/src/main. It contains entire details about an android application.


3 Answers

Cordova CLI v8.0 will use [email protected] by default.

As most of the cordova plugins do not support [email protected] yet, you can also try using the older one by specifying version:

cordova platform add [email protected]

Or, if you feel comfortable to use [email protected], you can also wait for a update on cordova-plugi-admobpro to support the [email protected], it's coming soon.

like image 183
Raymond Xie Avatar answered Oct 13 '22 17:10

Raymond Xie


Final edit:

cordova-android 7.1.4 is out, it should fix most of this kind of problems.

edit:

As people keep upvoting the answer I'll give more details about the problem.

The problem isn't really the plugin writing on the AndroidManifest.xml or on the config.xml. It's true that the location changed and plugins should update the path, but it's not mandatory and Cordova takes care of the new paths.

The problem is some plugins using source-file tag for things that are not source code. (i.e, using it for copying images instead of using resource-file tags) That creates a res folder (or lib) that confuses Cordova, making it believe it's an old Eclipse project, while it's really an Android studio project, and searches for the files on the old locations instead of looking into the new locations.

This has been patched in cordova-android and will be fixed in next release. The workaround is to look for the plugin using source-file tag and update it to use resource-file tag

OLD ANSWER:

It is now in app/src/main/AndroidManifest.xml.

If the plugin is writing on it, it should be updated to write on the right place.

Read the cordova-android 7.0.0 release blog post

like image 36
jcesarmobile Avatar answered Oct 13 '22 17:10

jcesarmobile


In config.xml file of the cordova project, under xml tag <platform name="android"> section, Add the following tag:

<resource-file src="platforms/android/app/src/main/AndroidManifest.xml" target="AndroidManifest.xml" />
like image 22
Sukalyan Debsingha Avatar answered Oct 13 '22 16:10

Sukalyan Debsingha