Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cordova build error on cordova-android@7.0.0 #337

Merged
merged 1 commit into from
Dec 25, 2017

Conversation

deton
Copy link
Contributor

@deton deton commented Dec 24, 2017

This pull request fixes cordova build error on cordova-android@7.0.0.

Because the project directory structure has been changed by cordova-android 7.0.0,
if platforms/android/libs/ exists,
the directory structure is not recognized as new style(*1) and an error occurs.

altbeacon.jar should be copied to platforms/android/app/libs/
instead of platforms/android/libs/.

By using <lib-file> in plugin.xml, altbeacon.jar is copied to the appropriate directory.
(on cordova-android 7.0.0 and <=6.x)

(*1)
https://github.com/apache/cordova-android/blob/a7304b9a19a7b7f760d1bba240648a35130b295a/bin/templates/cordova/lib/AndroidStudio.js

Other approach

get altbeacon library from maven repository
deton@d3488b6

Steps to reproduce the error
>cordova create foo com.example.foo foo
>cd foo
>cordova platform add android@7.0.0
>cordova plugin add cordova-plugin-ibeacon
>cordova build
cp: copyFileSync: could not write to dest file (code=ENOENT):C:\tmp\foo\platforms\android\res\xml\config.xml

Parsing C:\tmp\foo\platforms\android\res\xml\config.xml failed
(node:10160) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: ENOENT: no such file or directory, open 'C:\tmp\foo\platforms\android\res\xml\config.xml'
(node:10160) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Or add other plugin after cordova plugin add cordova-plugin-ibeacon.

>cordova create foo com.example.foo foo
>cd foo
>cordova platform add android@7.0.0
>cordova plugin add cordova-plugin-ibeacon
>cordova plugin add cordova-plugin-device
...
Installing "cordova-plugin-device" for android
Failed to install 'cordova-plugin-device': Error: ENOENT: no such file or directory, open 'C:\tmp\foo\platforms\android\AndroidManifest.xml'
    at Object.fs.openSync (fs.js:646:18)
    at Object.fs.readFileSync (fs.js:551:33)
    at Object.parseElementtreeSync (C:\tmp\foo\platforms\android\cordova\node_modules\cordova-common\src\util\xml-helpers.js:180:27)
    at new AndroidManifest (C:\tmp\foo\platforms\android\cordova\lib\AndroidManifest.js:29:20)
    at AndroidProject.getPackageName (C:\tmp\foo\platforms\android\cordova\lib\AndroidProject.js:99:12)
    at Api.addPlugin (C:\tmp\foo\platforms\android\cordova\Api.js:223:57)
    at handleInstall (C:\Users\deton\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\plugman\install.js:594:10)
    at C:\Users\deton\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\plugman\install.js:357:28
    at _fulfilled (C:\Users\deton\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:787:54)
    at self.promiseDispatch.done (C:\Users\deton\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:816:30)
(node:8416) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: ENOENT: no such file or directory, open 'C:\tmp\foo\platforms\android\AndroidManifest.xml'
(node:8416) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

(no problem on cordova-android@6.4.0)

System info
  • cordova-android 7.0.0
  • cordova 8.0.0
  • node.js v8.9.3
  • Windows 10

@petermetz petermetz self-assigned this Dec 25, 2017
@petermetz petermetz merged commit 0239309 into petermetz:v3.x Dec 25, 2017
@petermetz
Copy link
Owner

Thank you very much @deton

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants