首页 > 解决方案 > ionic3 android构建错误:超时等待锁定

问题描述

我将 macOS 从 EL Capitan 更新到 High Sierra 并安装了 ionic3。 ionic serve成功了,但我在ionic cordova run android --device.

我遇到以下错误

我一次又一次地删除锁定文件并杀死进程,但我无法解决这个问题。

我尝试删除平台并添加,更改 gradle 版本,重新安装 AndroidStudio,重新安装 npm,重新安装 ionic 和 cordova,但这些都不起作用。请帮我。

我的第一个构建中的日志如下

Running app-scripts build: --platform android --target cordova
[18:18:19]  build dev started ...
[18:18:19]  clean started ...
[18:18:19]  clean finished in 3 ms
[18:18:19]  copy started ...
[18:18:20]  deeplinks started ...
[18:18:20]  deeplinks finished in 20 ms
[18:18:20]  transpile started ...
[18:18:25]  transpile finished in 4.88 s
[18:18:25]  preprocess started ...
[18:18:25]  preprocess finished in 1 ms
[18:18:25]  webpack started ...
[18:18:25]  copy finished in 5.88 s
[18:18:33]  webpack finished in 7.82 s
[18:18:33]  sass started ...
Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning.
[18:18:34]  sass finished in 1.54 s
[18:18:34]  postprocess started ...
[18:18:34]  postprocess finished in 160 ms
[18:18:34]  lint started ...
[18:18:34]  build dev finished in 15.05 s
> cordova run android --device
Android Studio project detected

ANDROID_HOME=/Users/myAccount/Library/Android/sdk
JAVA_HOME=/Users/myAccount/.jenv/versions/1.8.0.172
studio
:wrapper


BUILD SUCCESSFUL
 in 2s

1 actionable task: 1 executed

Subproject Path: CordovaLib
Subproject Path: app
Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details

[18:18:46]  lint finished in 11.83 s
publishNonDefault is deprecated and has no effect anymore. All variants are now published.

Observed package id 'tools' in inconsistent location '/Users/myAccount/Library/Android/sdk/tools_back' (Expected '/Users/myAccount/Library/Android/sdk/tools')

Already observed package id 'tools' in '/Users/myAccount/Library/Android/sdk/tools'. Skipping duplicate at '/Users/myAccount/Library/Android/sdk/tools_back'

Observed package id 'tools' in inconsistent location '/Users/myAccount/Library/Android/sdk/tools_back' (Expected '/Users/myAccount/Library/Android/sdk/tools')

Already observed package id 'tools' in '/Users/myAccount/Library/Android/sdk/tools'. Skipping duplicate at '/Users/myAccount/Library/Android/sdk/tools_back'
The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.

    at build_cdomysz0j2rea5ksz26ej40t2.run(/Path/to/myapp/platforms/android/app/build.gradle:143)

:CordovaLib:preBuild
 UP-TO-DATE
:CordovaLib:preDebugBuild
 UP-TO-DATE
:CordovaLib:compileDebugAidl

:CordovaLib:compileDebugRenderscript

:CordovaLib:checkDebugManifest
:CordovaLib:generateDebugBuildConfig

:CordovaLib:prepareLintJar
:CordovaLib:generateDebugResValues

:CordovaLib:generateDebugResources
:CordovaLib:packageDebugResources

:CordovaLib:platformAttrExtractor

:CordovaLib:processDebugManifest

:CordovaLib:javaPreCompileDebug

:CordovaLib:processDebugJavaRes
 NO-SOURCE
:app:preBuild UP-TO-DATE
:app:preDebugBuild

:app:compileDebugAidl

:CordovaLib:packageDebugRenderscript NO-SOURCE
:app:compileDebugRenderscript

:app:checkDebugManifest

:app:generateDebugBuildConfig

:app:prepareLintJar

:app:generateDebugResValues
:app:generateDebugResources
:app:mergeDebugResources

:app:createDebugCompatibleScreenManifests

:app:processDebugManifest

:app:splitsDiscoveryTaskDebug

:CordovaLib:processDebugResources

:CordovaLib:generateDebugSources
:CordovaLib:compileDebugJavaWithJavac
 FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':CordovaLib:compileDebugJavaWithJavac'.
> Could not create service of type GeneralCompileCaches using GradleScopeCompileServices.createGeneralCompileCaches().

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 1m 42s
23 actionable tasks: 23 executed
(node:93755) UnhandledPromiseRejectionWarning: Error: /Path/to/myapp/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':CordovaLib:compileDebugJavaWithJavac'.
> Could not create service of type GeneralCompileCaches using GradleScopeCompileServices.createGeneralCompileCaches().

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 1m 42s
    at ChildProcess.whenDone (/Path/to/myapp/platforms/android/cordova/node_modules/cordova-common/src/superspawn.js:169:23)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
(node:93755) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:93755) [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.

[OK] Your app has been deployed.
     Did you know you can live-reload changes from your app with --livereload?

我的第二个构建中的日志如下

Running app-scripts build: --platform android --target cordova
[18:21:20]  build dev started ...
[18:21:20]  clean started ...
[18:21:20]  clean finished in 3 ms
[18:21:20]  copy started ...
[18:21:20]  deeplinks started ...
[18:21:20]  deeplinks finished in 18 ms
[18:21:20]  transpile started ...
[18:21:25]  transpile finished in 4.95 s
[18:21:25]  preprocess started ...
[18:21:25]  preprocess finished in 1 ms
[18:21:25]  webpack started ...
[18:21:26]  copy finished in 6.23 s
[18:21:34]  webpack finished in 9.34 s
[18:21:34]  sass started ...
Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning.
[18:21:36]  sass finished in 1.41 s
[18:21:36]  postprocess started ...
[18:21:36]  postprocess finished in 21 ms
[18:21:36]  lint started ...
[18:21:36]  build dev finished in 16.26 s
> cordova run android --device
Android Studio project detected

ANDROID_HOME=/Users/myAccount/Library/Android/sdk
JAVA_HOME=/Users/myAccount/.jenv/versions/1.8.0.172
studio
Subproject Path: CordovaLib
Subproject Path: app
publishNonDefault is deprecated and has no effect anymore. All variants are now published.
The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.

    at build_cdomysz0j2rea5ksz26ej40t2.run(/Path/to/myapp/platforms/android/app/build.gradle:143)

[18:21:47]  lint finished in 11.03 s

FAILURE: Build failed with an exception.

* What went wrong:
Timeout waiting to lock Build Output Cleanup Cache (/Path/to/myapp/platforms/android/.gradle/buildOutputCleanup). It is currently in use by another Gradle instance.
Owner PID: unknown
Our PID: 93843
Owner Operation: unknown
Our operation:
Lock file: /Path/to/myapp/platforms/android/.gradle/buildOutputCleanup/cache.properties.lock

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 1m 15s
(node:94025) UnhandledPromiseRejectionWarning: Error: /Path/to/myapp/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* What went wrong:
Timeout waiting to lock Build Output Cleanup Cache (/Path/to/myapp/platforms/android/.gradle/buildOutputCleanup). It is currently in use by another Gradle instance.
Owner PID: unknown
Our PID: 93843
Owner Operation: unknown
Our operation:
Lock file: /Path/to/myapp/platforms/android/.gradle/buildOutputCleanup/cache.properties.lock

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 1m 15s
    at ChildProcess.whenDone (/Path/to/myapp/platforms/android/cordova/node_modules/cordova-common/src/superspawn.js:169:23)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Socket.stream.socket.on (internal/child_process.js:346:11)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at Pipe._handle.close [as _onclose] (net.js:567:12)
(node:94025) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:94025) [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.

[OK] Your app has been deployed.
     Did you know you can live-reload changes from your app with --livereload?

我删除了 /Path/to/myapp/platforms/android/.gradle/buildOutputCleanup/cache.properties.lock 并终止了进程 93843。

我的第三个构建中的日志如下

Starting app-scripts server: --address 0.0.0.0 --port 8100 --livereload-port 35729 --dev-logger-port 53703 --consolelogs
--nobrowser --iscordovaserve --platform android --target cordova - Ctrl+C to cancel
[18:25:24]  watch started ...
[18:25:24]  build dev started ...
[18:25:24]  clean started ...
[18:25:24]  clean finished in 2 ms
[18:25:24]  copy started ...
[18:25:25]  deeplinks started ...
[18:25:25]  deeplinks finished in 15 ms
[18:25:25]  transpile started ...
[18:25:30]  transpile finished in 5.46 s
[18:25:30]  preprocess started ...
[18:25:30]  preprocess finished in 1 ms
[18:25:30]  webpack started ...
[18:25:31]  copy finished in 6.55 s
[18:25:39]  webpack finished in 8.63 s
[18:25:39]  sass started ...
Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning.
[18:25:41]  sass finished in 1.71 s
[18:25:41]  postprocess started ...
[18:25:41]  postprocess finished in 89 ms
[18:25:41]  lint started ...
[18:25:41]  build dev finished in 16.36 s
[18:25:41]  watch ready in 16.58 s
[18:25:41]  dev server running: http://localhost:8100/

[OK] Development server running!
     Local: http://localhost:8100
     External: http://192.168.11.16:8100


> cordova run android --device
Android Studio project detected

ANDROID_HOME=/Users/myAccount/Library/Android/sdk
JAVA_HOME=/Users/myAccount/.jenv/versions/1.8.0.172
studio
Subproject Path: CordovaLib
Subproject Path: app
Starting a Gradle Daemon, 2 incompatible and 2 stopped Daemons could not be reused, use --status for details

[18:25:53]  lint finished in 12.58 s
publishNonDefault is deprecated and has no effect anymore. All variants are now published.

Observed package id 'tools' in inconsistent location '/Users/myAccount/Library/Android/sdk/tools_back' (Expected '/Users/myAccount/Library/Android/sdk/tools')

Already observed package id 'tools' in '/Users/myAccount/Library/Android/sdk/tools'. Skipping duplicate at '/Users/myAccount/Library/Android/sdk/tools_back'
Observed package id 'tools' in inconsistent location '/Users/myAccount/Library/Android/sdk/tools_back' (Expected '/Users/myAccount/Library/Android/sdk/tools')

Already observed package id 'tools' in '/Users/myAccount/Library/Android/sdk/tools'. Skipping duplicate at '/Users/myAccount/Library/Android/sdk/tools_back'
The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.
    at build_cdomysz0j2rea5ksz26ej40t2.run(/Path/to/myapp/platforms/android/app/build.gradle:143)

FAILURE: Build failed with an exception.

* What went wrong:
Could not create service of type TaskArtifactStateRepository using TaskExecutionServices.createTaskArtifactStateRepository().
> Timeout waiting to lock task history cache (/Path/to/myapp/platforms/android/.gradle/4.1/taskHistory). It is currently in use by another Gradle instance.
  Owner PID: unknown
  Our PID: 94601
  Owner Operation: unknown
  Our operation:
  Lock file: /Path/to/myapp/platforms/android/.gradle/4.1/taskHistory/taskHistory.lock

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 1m 12s
(node:94546) UnhandledPromiseRejectionWarning: Error: /Path/to/myapp/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* What went wrong:
Could not create service of type TaskArtifactStateRepository using TaskExecutionServices.createTaskArtifactStateRepository().
> Timeout waiting to lock task history cache (/Path/to/myapp/platforms/android/.gradle/4.1/taskHistory). It is currently in use by another Gradle instance.
  Owner PID: unknown
  Our PID: 94601
  Owner Operation: unknown
  Our operation:
  Lock file: /Path/to/myapp/platforms/android/.gradle/4.1/taskHistory/taskHistory.lock

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 1m 12s
    at ChildProcess.whenDone (/Path/to/myapp/platforms/android/cordova/node_modules/cordova-common/src/superspawn.js:169:23)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
(node:94546) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:94546) [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.

离子信息

cli packages: (/Users/myAccount/.nodebrew/node/v8.10.0/lib/node_modules)

    @ionic/cli-utils  : 1.19.2
    ionic (Ionic CLI) : 3.20.0

global packages:

    cordova (Cordova CLI) : 8.0.0

local packages:

    @ionic/app-scripts : 3.1.9
    Cordova Platforms  : android 7.0.0
    Ionic Framework    : ionic-angular 3.9.2

System:

    Android SDK Tools : 25.2.5
    Node              : v8.10.0
    npm               : 5.6.0
    OS                : macOS High Sierra
    Xcode             : Xcode 9.3 Build version 9E145

Environment Variables:

    ANDROID_HOME : /Users/myAccount/Library/Android/sdk

Misc:

    backend : pro

标签: ionic3

解决方案


我自己解决了这个问题。这是由我的项目路径引起的。

我把它放在sd卡上时遇到了这个问题。我将它复制到家里并尝试构建,并且进展顺利。


推荐阅读