17

I keep getting the following error when I try to launch an inappbrowser:

Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:8000/cordova_plugins.js

When I look for "cordova/platforms/android/assets/www/cordova_plugins.js" the file is indeed missing.

The strange thing is that I see:

Writing out cordova_plugins.js...

My build process looks like this:

cordova create cordova com.myapp.mobile myapp
cd cordova
cordova platform add android
cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser.git
cordova build
cordova serve android
Guy Korland
  • 9,139
  • 14
  • 59
  • 106

9 Answers9

12

Since I use the same environment to produce multiple apps (with different names and skins) I often run rm -rf /platform/{platform} to remove my old platform project.

To start a fresh project using my config.xml I run cordova build {platform} the project will recreate this directory and the project will compile successfully although cordova_plugins is not created in /platform/{platform}/platform_www.

To solve this issue, I started by running cordova platform add {platform}.

Then cordova prepare {platform} to copy www assets into that folder

Last but not least cordova build {plaftorm}!

Hope this helps someone facing the same issue.

Lothre1
  • 3,523
  • 7
  • 43
  • 64
7

run cordova plugin add cordova-plugin-device

Petter Friberg
  • 21,252
  • 9
  • 60
  • 109
3

try cordova prepare, that will show the specific error, mainly the error is missing plugins added to plugin.xml but not installed yet

2

I think this might be a bug in Cordova (I'm running 3.0.6). I am experiencing the same problem. The file gets generated fine (check after the cordova build line) but gets deleted when I run the cordova serve android line.

update:

As a workaround, running the server in the background and then building seems to make the file available again.

It seems that the problem is the www folder gets replaced by the 'serve' action. Had a quick flick through the source code but nothing jumped out :(

Tim Croydon
  • 1,866
  • 1
  • 19
  • 30
2

As of cordova 5.1.1 this file is at \platforms\platform_name\assets\www\

Nishikant
  • 305
  • 4
  • 17
2

I downgraded to Cordova version 7.1.0 (from 8.0.0):

sudo npm i -g cordova@7.1.0

I also removed the Android platform and added it again:

ionic cordova platform rm android
ionic cordova platform add android@6.4.0

This worked for me.

craigcaulfield
  • 3,381
  • 10
  • 32
  • 40
0

I would re-generate the android folder by deleting /platforms/android, run cordova platform add android and check if there are any warning/error messages in the console. This will give you a clue to what went wrong. For me, it was because my Windows>System Environment Variables>ANDROID_HOME was not set correctly.

ushika
  • 1,521
  • 1
  • 11
  • 4
0

I faced the same problem. So I uninstalled cordova and installed again globally.

npm install -g cordova

Now it's working fine for me.

feedMe
  • 3,431
  • 2
  • 36
  • 61
Mohsin
  • 1
  • 1
0

In my case, when I was trying to remove one of my plugins this error was coming, downgrading my cordova version to 8.0.0 version did the trick for me

npm install -g cordova@8.0.0

Muhammad Awais
  • 1,608
  • 1
  • 21
  • 21