我在将项目运行到android模拟器时遇到问题:当我运行此命令“ ionic cordova emulator android”时,它将出错。 我正在使用动态ssh和socks隧道运行腻子。 我的终端的完整日志如下所示。
PS D:\Hamid\wooionic2> ionic cordova run android
...
[12:06:30] 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.
...
cordova运行android 检测到Android Studio项目
ANDROID_HOME=C:\Users\Hamid\AppData\Local\Android\sdk
JAVA_HOME=C:\Program Files\java\jdk1.8.0_172
studio
Subproject Path: CordovaLib
Subproject Path: app
...
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all files for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:3.0.0.
Required by:
project :
> Could not resolve com.android.tools.build:gradle:3.0.0.
> Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.pom'.
> Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.pom'.
> dl.google.com:443 failed to respond
> Could not resolve com.android.tools.build:gradle:3.0.0.
> Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.pom'.
> Could not GET 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.pom'.
> jcenter.bintray.com:443 failed to respond
>
Could not resolve com.android.tools.build:gradle:3.0.0.
> Could not get resource 'https://maven.google.com/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.pom'.
> Could not GET 'https://maven.google.com/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.pom'.
> maven.google.com:443 failed to respond
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
(node:7272) UnhandledPromiseRejectionWarning: Error: cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
BUILD FAILED in 1s
at ChildProcess.whenDone (D:\Hamid\wooionic2\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:7272) 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:7272) [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?
它说:
Could not resolve com.android.tools.build:gradle:3.0.0.
> Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.pom'.
> Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.pom'.
> dl.google.com:443 failed to respond
错误在哪里?
答案 0 :(得分:0)
我禁用了腻子(充当代理),然后再次运行命令:“ cordova仿真android”
但是这次感觉到了新的错误:
A problem occurred configuring root project 'android'.
无法解析配置':classpath'的所有文件。 无法解析com.android.tools.build:gradle:3.0.0。 要求: 项目: 无法解析com.android.tools.build:gradle:3.0.0。 无法获取资源“ https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.pom”。 无法获取'https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.pom'。 连接到 127.0.0.1:8085 [/127.0.0.1]失败:连接被拒绝:连接
127.0.0.1:8085是我设置为puty ssh隧道的地址和端口。 但是我找不到从我的项目中删除此代理的设置在哪里。 最后,幸运的是我在此文件(gradle.properties)中找到了它:
C:\ Users \ USERNAME.gradle \ gradle.properties
在此文件中,我删除了以下行:
systemProp.https.proxyPort=8085
systemProp.http.proxyHost=127.0.0.1
systemProp.https.proxyHost=127.0.0.1
systemProp.http.proxyPort=8085
,问题消失。但是我还不知道gradle如何获得和设置代理设置!有人知道吗?