apache / cordova-android

Apache Cordova Android
https://cordova.apache.org/
Apache License 2.0
3.59k stars 1.52k forks source link

Source and destination must not be the same. #693

Closed Domvel closed 2 years ago

Domvel commented 5 years ago

Bug Report

Problem

Since cordova-android 8.0.0 we have build problems. In most of cases we got the error "An error occurred while running subprocess cordova." and the last line "Source and destination must not be the same". Sometimes, the build is ok. - We always check out the git repository of the app. (hard clean)

What is expected to happen?

Build successfully.

What does actually happen?

Build failed.

Information

This error is not 100% reprocable. But about 80%. I just updated Cordova-Android. I expecting the node plugin fa-extra. Maybe Cordova-Android uses this with wrong attributes?

Command or Code

ionic cordova build android --release --prod --generateSourceMap false But also ionic cordova build or cordova build.

Environment, Platform, Device / Version information

Ionic:
   ionic (Ionic CLI)  : 4.10.1
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.1.11

Cordova:
   cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
   Cordova Platforms     : Cordova-Android 8.0.0

System:
   Android SDK Tools : 26.1.1 (C:\Users\jenkins\AppData\Local\Android\sdk)
   NodeJS            : v10.15.3 (C:\Program Files\nodejs\node.exe)
   npm               : 6.4.1
   OS                : Windows 10

Log

Console log
------------------------------------------------------------------------------------
...
[INFO] Discovered plugin "cordova-plugin-email-composer" in config.xml. Adding it to the project
[INFO] Installing "cordova-plugin-email-composer" for android
[INFO] Subproject Path: CordovaLib
[INFO] Subproject Path: app
[INFO] Adding cordova-plugin-email-composer to package.json
[INFO] Saved plugin info for "cordova-plugin-email-composer" to config.xml
[INFO] Source and destination must not be the same.
[ERROR] [ERROR] An error occurred while running subprocess cordova.
[ERROR]
[ERROR]         cordova platform add android --save exited with exit code 1.
[ERROR]
[ERROR]         Re-running this command with the --verbose flag may provide more information.
[ERROR] npm ERR! code ELIFECYCLE
[ERROR] npm ERR! errno 1
[ERROR] npm ERR! testapp@1.2.3 build:release: `ionic cordova build android --release --prod --generateSourceMap false`
[ERROR] npm ERR! Exit status 1
[ERROR] npm ERR!
[ERROR] npm ERR! Failed at the testapp@1.2.3 build:release script.
[ERROR] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
[ERROR]
[ERROR] npm ERR! A complete log of this run can be found in:
[ERROR] npm ERR!     C:\Users\jenkins\AppData\Roaming\npm-cache\_logs\2019-03-18T08_17_34_817Z-debug.log
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  39:57 min
[INFO] Finished at: 2019-03-18T09:17:35+01:00
[INFO] ------------------------------------------------------------------------
Wait until Jenkins completes the data collection...
[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.6:npm (npm build) on project my-project:
  Failed to run task: 'npm run build:release' failed. org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[JENKINS] Archiving C:\Jenkins\workspace\MYPROJECT\MYAPP\pom.xml to de.me.testapp.webclient/my-project/1.2.3/my-project-1.2.3.pom
Set build name.
New build name is '#317 1.2.3'
channel stopped
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
WARN: Unable to locate 'report-task.txt' in the workspace. Did the SonarScanner succedeed?
Finished: FAILURE
[END]

NPM Scripts
------------------------------------------------------------------------------------
"npm run build:release": "ionic cordova build android --release --prod --generateSourceMap false"

C:\Users\jenkins\AppData\Roaming\npm-cache\_logs\2019-03-18T08_17_34_817Z-debug.log
------------------------------------------------------------------------------------
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Jenkins\\workspace\\MYPROJECT\\MYAPP\\target\\node\\node.exe',
1 verbose cli   'C:\\Jenkins\\workspace\\MYPROJECT\\MYAPP\\target\\node\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'build:release' ]
2 info using npm@6.4.1
3 info using node@v10.15.3
4 verbose run-script [ 'prebuild:release', 'build:release', 'postbuild:release' ]
5 info lifecycle testapp@1.2.3~prebuild:release: testapp@1.2.3
6 info lifecycle testapp@1.2.3~build:release: testapp@1.2.3
7 verbose lifecycle testapp@1.2.3~build:release: unsafe-perm in lifecycle true
8 verbose lifecycle testapp@1.2.3~build:release: PATH:
  C:\Jenkins\workspace\MYPROJECT\MYAPP\target\node\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;
  C:\Jenkins\workspace\MYPROJECT\MYAPP\node_modules\.bin;
  C:\Jenkins\workspace\MYPROJECT\MYAPP\target\node;
  C:\Program Files (x86)\dev_tools\apache-maven-3.6.0/bin;
  C:\Program Files\Java\jdk1.8.0_192/bin;
  C:\Program Files (x86)\Common Files\Oracle\Java\javapath;
  C:\ProgramData\Oracle\Java\javapath;
  C:\WINDOWS\system32;
  C:\WINDOWS;
  C:\WINDOWS\System32\Wbem;
  C:\WINDOWS\System32\WindowsPowerShell\v1.0\;
  C:\Program Files\dotnet\;
  C:\TDM-GCC-64\bin;
  C:\PhantomJs\bin;
  C:\WINDOWS\System32\OpenSSH\;
  C:\Program Files\Git\cmd;
  C:\Program Files (x86)\WiX Toolset v3.11\bin\;
  C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\;
  C:\Program Files\nodejs\;
  C:\Users\jenkins\AppData\Local\Microsoft\WindowsApps;
  C:\Users\jenkins\AppData\Roaming\npm;
  C:\Users\jenkins\AppData\Local\Programs\Microsoft VS Code\bin;
  C:\Python27;
9 verbose lifecycle testapp@1.2.3~build:release: CWD: C:\Jenkins\workspace\MYPROJECT\MYAPP
10 silly lifecycle testapp@1.2.3~build:release: Args: [ '/d /s /c',
10 silly lifecycle   'ionic cordova build android --release --prod --generateSourceMap false' ]
11 silly lifecycle testapp@1.2.3~build:release: Returned: code: 1  signal: null
12 info lifecycle testapp@1.2.3~build:release: Failed to exec build:release script
13 verbose stack Error: testapp@1.2.3 build:release: `ionic cordova build android --release --prod --generateSourceMap false`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (C:\Jenkins\workspace\MYPROJECT\MYAPP\target\node\node_modules\npm\node_modules\npm-lifecycle\index.js:301:16)
13 verbose stack     at EventEmitter.emit (events.js:189:13)
13 verbose stack     at ChildProcess.<anonymous> (C:\Jenkins\workspace\MYPROJECT\MYAPP\target\node\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:189:13)
13 verbose stack     at maybeClose (internal/child_process.js:970:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
14 verbose pkgid testapp@1.2.3
15 verbose cwd C:\Jenkins\workspace\MYPROJECT\MYAPP
16 verbose Windows_NT 10.0.17134
17 verbose argv
  "C:\\Jenkins\\workspace\\MYPROJECT\\MYAPP\\target\\node\\node.exe"
  "C:\\Jenkins\\workspace\\MYPROJECT\\MYAPP\\target\\node\\node_modules\\npm\\bin\\npm-cli.js"
  "run"
  "build:release"
18 verbose node v10.15.3
19 verbose npm  v6.4.1
20 error code ELIFECYCLE
21 error errno 1
22 error testapp@1.2.3 build:release: `ionic cordova build android --release --prod --generateSourceMap false`
22 error Exit status 1
23 error Failed at the testapp@1.2.3 build:release script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
Domvel commented 5 years ago

Late discovered. Related to https://github.com/apache/cordova-android/issues/692 and https://github.com/apache/cordova-common/issues/64.

Domvel commented 5 years ago

https://github.com/apache/cordova-common/blob/master/RELEASENOTES.md https://issues.apache.org/jira/browse/CB-14140 https://github.com/jprichardson/node-fs-extra/issues/657

cambooo commented 4 years ago

Hey, we are facing a similar error. Have you found a way how to fix it? Thanks a lot in advance!

ksibod commented 4 years ago

For me, the issue was that I was using the <edit-config> tag in my config.xml file that contained a <uses-permission> tag that was already included in the manifest file. I figured since the mode was in "merge", this wouldn't be a problem, but removing that fixed the issue. This was using 8.0.0 (might not be exactly the same problem but just in case for anyone else that stumbles along here).

breautek commented 4 years ago

cordova-android doesn't use fs-extra yet. Is the issue reproducible using Cordova 9?

cambooo commented 4 years ago

For me, the issue was that I was using the <edit-config> tag in my config.xml file that contained a <uses-permission> tag that was already included in the manifest file.

Thanks for your help, but I do not have this line in the config.xml

cambooo commented 4 years ago

cordova-android doesn't use fs-extra yet. Is the issue reproducible using Cordova 9?

Oh, frankly, I am not a developer. Guy why started the project got sick and I am trying to fix this issue by myself.

I am using Cordoba 9 version.

breautek commented 4 years ago

Running the command that produces the error with the --verbose flag should produce a stacktrace that lead to that error. Please provide that information, so that we can track down where the fault is. Thanks.

PeterHdd commented 4 years ago

Im also getting this error, I'm executing the following command :

ionic cordova platform add android@8

breautek commented 4 years ago

Im also getting this error, I'm executing the following command :

ionic cordova platform add android@8

Does ionic support passing down the --verbose flag to the cordova command?

PeterHdd commented 4 years ago

Yes I added verbose now and I will tell you the result

PeterHdd commented 4 years ago

This is part of the log:

  copy  platforms\android\platform_www\cordova.js platforms\android\app\src\main\assets\www\cordova.js (updated file)
  copy  platforms\android\platform_www\cordova_plugins.js platforms\android\app\src\main\assets\www\cordova_plugins.js (updated file)
  copy  platforms\android\platform_www\plugins\cordova-plugin-actionsheet\www\ActionSheet.js platforms\android\app\src\main\assets\www\plugins\cordova-plugin-actionsheet\www\ActionSheet.js (updated file)
  copy  platforms\android\platform_www\plugins\cordova-plugin-android-permissions\www\permissions.js platforms\android\app\src\main\assets\www\plugins\cordova-plugin-android-permissions\www\permissions.js (updated file)
  copy  platforms\android\platform_www\plugins\cordova-plugin-app-version\www\AppVersionPlugin.js platforms\android\app\src\main\assets\www\plugins\cordova-plugin-app-version\www\AppVersionPlugin.js (updated file)
  copy  platforms\android\platform_www\plugins\cordova-plugin-background-mode\www\background-mode.js platforms\android\app\src\main\assets\www\plugins\cordova-plugin-background-mode\www\background-mode.js (updated file)
  copy  platforms\android\platform_www\plugins\cordova-plugin-device\www\device.js platforms\android\app\src\main\assets\www\plugins\cordova-plugin-device\www\device.js (updated file)
  copy  platforms\android\platform_www\plugins\cordova-plugin-dialogs\www\android\notification.js platforms\android\app\src\main\assets\www\plugins\cordova-plugin-dialogs\www\android\notification.js (updated file)
  copy  platforms\android\platform_www\plugins\cordova-plugin-dialogs\www\notification.js platforms\android\app\src\main\assets\www\plugins\cordova-plugin-dialogs\www\notification.js (updated file)
  copy  platforms\android\platform_www\plugins\cordova-plugin-ezbiosdk\www\EzBioSDKPlugin.js platforms\android\app\src\main\assets\www\plugins\cordova-plugin-ezbiosdk\www\EzBioSDKPlugin.js (updated file)
  copy  platforms\android\platform_www\plugins\cordova-plugin-eztokensdk\www\EzTokenSDKPlugin.js platforms\android\app\src\main\assets\www\plugins\cordova-plugin-eztokensdk\www\EzTokenSDKPlugin.js (updated file)
  copy  platforms\android\platform_www\plugins\cordova-plugin-geolocation\www\PositionError.js platforms\android\app\src\main\assets\www\plugins\cordova-plugin-geolocation\www\PositionError.js (updated file)
(node:11892) UnhandledPromiseRejectionWarning: Error: Source and destination must not be the same.
 at Object.checkPathsSync (D:\Peter\<project>\<project-path>\node_modules\fs-extra\lib\util\stat.js:92:11)
breautek commented 4 years ago

(node:11892) UnhandledPromiseRejectionWarning: Error: Source and destination must not be the same. at Object.checkPathsSync (D:\Peter\\\node_modules\fs-extra\lib\util\stat.js:92:11)

Is this the entire stacktrace? Seems strange there is only one item in the trace.

PeterHdd commented 4 years ago

No but didnt wanna add it because this is a company's project, not mine personal. But here is the rest:

(node:11892) UnhandledPromiseRejectionWarning: Error: Source and destination must not be the same.
    at Object.checkPathsSync (D:\Peter\<project>\<project>\node_modules\fs-extra\lib\util\stat.js:92:11)
    at Object.copySync (D:\Peter\<project>\<project>\node_modules\fs-extra\lib\copy-sync\copy-sync.js:24:38)
    at updatePathWithStats (D:\Peter\<project>\<project>\node_modules\cordova-common\src\FileUpdater.js:103:24)
    at D:\Peter\<project>\<project>\node_modules\cordova-common\src\FileUpdater.js:298:19
    at Array.forEach (<anonymous>)
    at Object.mergeAndUpdateDir (D:\Peter\<project>\<project>\node_modules\cordova-common\src\FileUpdater.js:296:33)
    at updateWww (D:\Peter\<project>\<project>\platforms\android\cordova\lib\prepare.js:161:17)
    at Api.module.exports.prepare (D:\Peter\<project>\<project>\platforms\android\cordova\lib\prepare.js:60:19)
    at Api.prepare (D:\Peter\<project>\<project>\platforms\android\cordova\Api.js:175:45)
    at C:\Users\Peter\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\cordova\prepare.js:106:36
PeterHdd commented 4 years ago

It worked, I removed the plugin cordova-plugin-android-permissions .

Great. But now I need to figure out why it is not working with cordova-plugin-android-permissions.

I dont wanna stay till night here :p Do you know any other cordova plugin for android permissions?

breautek commented 4 years ago

Thank you, I think this is enough information to at least investigate where the error is coming from.

I dont wanna stay till night here :p Do you know any other cordova plugin for android permissions?

I use https://github.com/dpa99c/cordova-diagnostic-plugin personally.

PeterHdd commented 4 years ago

It worked with cordova-android-permission, I added the following in the config.xml:

        <config-file parent="/*" target="AndroidManifest.xml">
            <uses-permission android:name="android.permission.READ_PHONE_STATE" />
        </config-file>

Then added the plugin again, then I added the android platform and it worked.

Now for the build.

Im not sure what the problem is, but it seems its all related to this plugin and <config-file> as @cambooo commented before

PeterHdd commented 4 years ago

Btw the build succeeded

PeterHdd commented 4 years ago

Now I got this error again when building, even though I didnt change anything

breautek commented 4 years ago

I just received this error at work, it was trying to copy a file that was a symlink.

Modifying the following line:

https://github.com/apache/cordova-common/blob/cfa7b3e5f809bc046d109f0b1f98666058e46cd1/src/FileUpdater.js#L103

To add the options parameter:

{
    "dereference": true
}

Fixed the problem for me.

The deference option does:

dereference : dereference symlinks, default is false.

Sagar-rr commented 4 years ago

Hey, I was having same error "Source and destination must not be the same" My error was solved by Following Command

cordova clean android

scofield-hello commented 4 years ago

I got the same error.

ionic cordova run android --release --verbose

微信截图_20200313174254

erisu commented 2 years ago

I am closing out this ticket as we beleive it has been resolved since.

Since then, I have not be able to reproduced it anymore.

If anyone is still see this issue, please try and reinstall with the latest versions of:

Reinstall Cordova w/ Latest Version

npm uninstall -g cordova
npm install -g cordova@latest

Reinstall Platform w/ Latest Version (in the project directory)

cordova platform remove android
cordova platform add android@10.0.1

If problem persists please make a new ticket with updated information, such as: