(urgent) Failed to build android

  • 7
  • Problem
  • Updated 5 years ago
Im having problem to build android app. Everything is working on last week. But today when i try to update some layout in my apps and sent it to phonegap build to publish, android build is failed.

attach the error log i found. Hope someone can help me.

-compile:
[javac] Compiling 30 source files to /project/bin/classes
[javac] /project/src/org/apache/cordova/filetransfer/FileTransfer.java:59: error: package org.apache.cordova.file does not exist
[javac] import org.apache.cordova.file.FileUtils;
[javac] ^
[javac] /project/src/org/apache/cordova/mediacapture/Capture.java:31: error: package org.apache.cordova.file does not exist
[javac] import org.apache.cordova.file.FileUtils;
[javac] ^
[javac] /project/src/org/apache/cordova/mediacapture/Capture.java:32: error: package org.apache.cordova.file does not exist
[javac] import org.apache.cordova.file.LocalFilesystemURL;
[javac] ^
[javac] /project/src/org/apache/cordova/filetransfer/FileTransfer.java:934: error: cannot find symbol
[javac] FileUtils filePlugin = (FileUtils) pm.getPlugin("File");
[javac] ^
[javac] symbol: class FileUtils
[javac] /project/src/org/apache/cordova/filetransfer/FileTransfer.java:934: error: cannot find symbol
[javac] FileUtils filePlugin = (FileUtils) pm.getPlugin("File");
[javac] ^
[javac] symbol: class FileUtils
[javac] /project/src/org/apache/cordova/mediacapture/Capture.java:451: error: cannot find symbol
[javac] FileUtils filePlugin = (FileUtils) pm.getPlugin("File");
[javac] ^
[javac] symbol: class FileUtils
[javac] location: class Capture
[javac] /project/src/org/apache/cordova/mediacapture/Capture.java:451: error: cannot find symbol
[javac] FileUtils filePlugin = (FileUtils) pm.getPlugin("File");
[javac] ^
[javac] symbol: class FileUtils
[javac] location: class Capture
[javac] /project/src/org/apache/cordova/mediacapture/Capture.java:452: error: cannot find symbol
[javac] LocalFilesystemURL url = filePlugin.filesystemURLforLocalPath(fp.getAbsolutePath());
[javac] ^
[javac] symbol: class LocalFilesystemURL
[javac] location: class Capture
[javac] Note: Some input files use or override a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 8 errors

BUILD FAILED
/android-sdk/tools/ant/build.xml:716: The following error occurred while executing this line:
/android-sdk/tools/ant/build.xml:730: Compile failed; see the compiler error output for details.

Total time: 12 seconds

/project/cordova/node_modules/q/q.js:126
throw e;
^
Error code 1 for command: ant with args: release,-f,/project/build.xml
Photo of Koh Ren Chien

Koh Ren Chien

  • 11 Posts
  • 0 Reply Likes

Posted 5 years ago

  • 7
Photo of Koh Ren Chien

Koh Ren Chien

  • 11 Posts
  • 0 Reply Likes
Anyone know what happen?? urgent...someone pls helppp
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
Looks like you are using older, deprecated plugins.
Try using the latest plugins from npm, especially the filetransfer plugin. Don't also include the file plugin, since the latter is integrated in the former.
Photo of Koh Ren Chien

Koh Ren Chien

  • 11 Posts
  • 0 Reply Likes
Hi Petra V,

im using file and file transfer plugin by adding this two lines in my config.xml

gap:plugin name="cordova-plugin-file" source="npm"
gap:plugin name="cordova-plugin-file-transfer" source="npm"

It supposes get the latest from npm automatically when i use phonegap build to generate the apk file?

I have done some experiments. If i remove source="npm" from the filetransfer plugin tag Android apk is builded successfully. If i add in the source="npm" Andoird build will fail.

And i wondering this is not causing any issue on iOS?

Thanks for your advises.
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
They recently updated the file plugin. This may affect the file transfer plugin, due to dependencies.
Try removing the file plugin from your config.
Photo of Himanshu NakLabs

Himanshu NakLabs

  • 74 Posts
  • 1 Reply Like
I am using both plugins and not specifying any version code. So this will pull latest plugin version. Still I am not able to build my app. If I remove plugin then my app is not functioning properly as I have used both file and file transfer plugin in my app. So can you please suggest what shall I do in that case?
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
Well, as I have written below, there MIGHT be a dependency version conflict, now. Not sure, though.

The file-transfer plugin includes the file plugin, so if you are using both, you should only include the file-transfer plugin in your config. However, I suspect that the current file-transfer plugin doesn't pull the latest version (several days old, now) of the file plugin.

PGB Support should (please) check if this is the case. Perhaps the file-transfer plugin needs an update as well, so it will again use the latest file plugin version.
Photo of Koh Ren Chien

Koh Ren Chien

  • 11 Posts
  • 0 Reply Likes
Petra V,

Thanks for your help.
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
You're welcome

I have done some experiments. If i remove source="npm" from the filetransfer plugin tag Android apk is builded successfully. If i add in the source="npm" Andoird build will fail.
Well, yes. But if you remove the source=npm part from the gap:plugin line, the plugin will most likely not be found. In such case, the Builder shrugs and continues, while errors will only occur in the app itself.
Photo of Benoit

Benoit

  • 2 Posts
  • 0 Reply Likes
Any news on this. I have the same issue. Is there a way to go back to an old version while we wait ?
Photo of Brett

Brett, OFFICIAL REP

  • 547 Posts
  • 54 Reply Likes
you can lock your plugin to a previous version using the spec or version attribute.
Photo of jcesarmobile

jcesarmobile

  • 283 Posts
  • 40 Reply Likes
cordova team released plugins today
http://cordova.apache.org/news/2015/1...

The following plugins now require cordova-android@5.0.0.
cordova-plugin-camera
cordova-plugin-contacts
cordova-plugin-file
cordova-plugin-geolocation
cordova-plugin-media

and as far as I know, phonegap doesn't support cordova android 5.0.0 yet, so you have to set the old version of the plugins

The old versions are
cordova-plugin-camera 1.2.0
cordova-plugin-contacts 1.1.0
cordova-plugin-file 3.0.0
cordova-plugin-geolocation 1.0.1
cordova-plugin-media 1.0.1

It's going to be reverted soon so it doesn't break phonegap build and other tools, but for now, pin that versions on your config.xml to use them.
If you use the file transfer, it has the file plugin as dependency, so pin the file plugin to this version
Photo of JesseMonroy650 (Volunteer)

JesseMonroy650 (Volunteer), Champion

  • 3325 Posts
  • 122 Reply Likes
Yes correct. Cordova Android 5.0 not supported. I posted the links for Petra on another thread. Phonegap Build cli-5.2.0 is pinned to Cordova Android 4.1.0. It's on the Phonegap Build blog. (dated Sept 2015)
Photo of jcesarmobile

jcesarmobile

  • 283 Posts
  • 40 Reply Likes
Thanks Jesse.
BTW, the plugins has been reverted to make "latest" point to the old version of these 5 plugins, so this shouldn't be an issue anymore. But once phonegap build supports cordova android 5 the users who want to configure their project to use cordova android 5 will have to select the new version number of the plugins on the config.xml
Photo of Benoit

Benoit

  • 2 Posts
  • 0 Reply Likes
Thank you, it seems that specifying an older version worked.
Photo of GreenDome

GreenDome

  • 1 Post
  • 0 Reply Likes
Anyone know the old version for apache.cordova.file-transfer and can it now be used with source="npm"?

Thanks,
GD
Photo of GreenDome

GreenDome

  • 3 Posts
  • 0 Reply Likes
Anyone know the old version for apache.cordova.file-transfer and can it now be used with source="npm"?

Thanks,
GD
Photo of jcesarmobile

jcesarmobile

  • 283 Posts
  • 40 Reply Likes
no, the old version isn't on npm, you have to use the new version on npm

gap:plugin name="cordova-plugin-file-transfer" source="npm"
Photo of GreenDome

GreenDome

  • 3 Posts
  • 0 Reply Likes
When I use the new version the app doesn't compile but it does if I leave out source="npm" part. Where does PGB load the plugin from when source="npm" is left out?

Thanks
Photo of Brett

Brett, OFFICIAL REP

  • 547 Posts
  • 54 Reply Likes
<plugin /> defaults to npm and <gap:plugin /> (not recommended) defaults to pgb
Photo of GreenDome

GreenDome

  • 3 Posts
  • 0 Reply Likes
Many thanks Brett. All sorted now....ended up using spec="3.0.0" solution.