简体   繁体   English

命令“离子cordova模拟android”不起作用

[英]command “ionic cordova emulate android” does not work

I have problem running my project to android emulator: When I run this command "ionic cordova emulate android", it goes to errors. 我在将项目运行到android模拟器时遇到问题:当我运行此命令“ ionic cordova emulator android”时,它将出错。 I am running putty with dynamic ssh and socks tunnel. 我正在使用动态ssh和socks隧道运行腻子。 Complete log of my terminal is shown below. 我的终端的完整日志如下所示。

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 run android Android Studio project detected 科尔多瓦运行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?

It says: 它说:

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

Where is the bug? 错误在哪里?

I disabled the putty (that acts as a proxy) and run my command again: "cordova emulate android" 我禁用了腻子(充当代理),然后再次运行命令:“ cordova模拟android”

but it felts to new errors this time: 但是这次感觉到了新的错误:

A problem occurred configuring root project 'android'.

Could not resolve all files for configuration ':classpath'. 无法解析配置':classpath'的所有文件。 Could not resolve com.android.tools.build:gradle:3.0.0. 无法解析com.android.tools.build:gradle:3.0.0。 Required by: project : Could not resolve com.android.tools.build:gradle:3.0.0. 必填项:project:无法解析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 '. 无法获取资源' 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 '. 无法获取' https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.pom '。 Connect to 127.0.0.1:8085 [/127.0.0.1] failed: Connection refused: connect 连接到127.0.0.1:8085 [/127.0.0.1]失败:连接被拒绝:连接

The 127.0.0.1:8085 is the address and port that I set to puty ssh tunnels. 127.0.0.1:8085是我设置为puty ssh隧道的地址和端口。 But I could not find where is the setting to remove this proxy from my project. 但是我找不到从我的项目中删除此代理的设置在哪里。 Finally and fortunately I found it in this file (gradle.properties): 最后,幸运的是我在此文件(gradle.properties)中找到了它:

C:\\Users\\USERNAME.gradle\\gradle.properties C:\\用户\\ USERNAME.gradle \\ gradle.properties

In this file I removed this lines: 在此文件中,我删除了以下几行:

systemProp.https.proxyPort=8085
systemProp.http.proxyHost=127.0.0.1
systemProp.https.proxyHost=127.0.0.1
systemProp.http.proxyPort=8085

and the problem goes away . 问题消失了 But I don't know yet how gradle gets and sets this proxy settings! 但是我还不知道gradle如何获得和设置代理设置! anyone know it? 有人知道吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM