开发者问题收集

离子构建后出错

2016-02-22
922

系统 - Ubuntu

我已完成以下操作:

.bashrc

export ANDROID_HOME=/root/Android/Sdk

export PATH=$PATH:/root/Android/Sdk/tools

尝试执行上述操作后,我尝试在控制台中运行 sudo ionic build android

控制台输出:

sudo ionic build android

Running command: /home/aiduryagin/Desktop/androidDev/test/hooks/after_prepare/010_add_platform_class.js /home/aiduryagin/Desktop/androidDev/test
add to body class: platform-android
ANDROID_HOME=/root/Android/Sdk
JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':classpath'.
   > Could not resolve com.android.tools.build:gradle:1.5.0.
     Required by:
         :android:unspecified
      > Could not GET 'https://repo1.maven.org/maven2/com/android/tools/build/gradle/1.5.0/gradle-1.5.0.pom'.
         > peer not authenticated

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

BUILD FAILED

Total time: 1.615 secs
ERROR building one of the platforms: Error code 1 for command: /home/aiduryagin/Desktop/androidDev/test/platforms/android/gradlew with args: cdvBuildDebug,-b,/home/aiduryagin/Desktop/androidDev/test/platforms/android/build.gradle,-Dorg.gradle.daemon=true,-Pandroid.useDeprecatedNdk=true
You may not have the required environment or OS to build this project
Error: Error code 1 for command: /home/aiduryagin/Desktop/androidDev/test/platforms/android/gradlew with args: cdvBuildDebug,-b,/home/aiduryagin/Desktop/androidDev/test/platforms/android/build.gradle,-Dorg.gradle.daemon=true,-Pandroid.useDeprecatedNdk=true
1个回答

首先,您不应该使用 sudo 运行 cordova CLI 命令,这会导致错误,因为用于运行 sudo 命令的用户与您的用户不同,因此如果您为您的用户配置路径,则它不会为 sudo 用户更改。

您只需要 sudo 来运行 npm install -g ... 命令,但不需要运行 cordova 或 ionic 命令。

也就是说,它似乎不是导致您出现问题的原因。

Could not GET ' https://repo1.maven.org/maven2/com/android/tools/build/gradle/1.5.0/gradle-1.5.0.pom '. peer not authenticated

此消息似乎表明您在尝试下载依赖项时遇到 SSL 问题。您是否使用了代理或其他什么?

QuickFix
2016-02-23