离子cordova构建android:错误:产生EACCES

时间:2017-12-11 23:35:13

标签: android cordova build ionic3 macos-high-sierra

我已经看到许多引用通过chmod更改gradle的执行属性,(+ x或755)...这些似乎都没有任何区别。 即使我跑,我仍然得到消息: sudo ionic cordova build android

我有这些设置:

我能想到的唯一一件事是由于插件的钩子中没有执行属性的东西可能...

Plugins - no custom hooks folder entries

sudo ionic cordova build android

....
> cordova build android
ANDROID_HOME=/Users/jgf/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home
Subproject Path: CordovaLib
Error: spawn EACCES

[ERROR] An error occurred while running cordova build android (exit code 1).

关于这个错误最烦人的事情之一就是它没有给你足够的细节而且隐藏了问题的根本原因...... 我尝试添加 - 详细 - 发布标记之类的内容,但在解决问题方面没有任何改变。

运行Mac OS X High Sierra 10.13.2

离子信息

cli packages: (/Users/jgf/.nvm/versions/node/v8.9.3/lib/node_modules)

    @ionic/cli-utils  : 1.18.0
    ionic (Ionic CLI) : 3.18.0

global packages:

    cordova (Cordova CLI) : 7.0.1

local packages:

    @ionic/app-scripts : 3.1.5
    Cordova Platforms  : android 6.4.0 browser 4.1.0 ios 4.4.0
    Ionic Framework    : ionic-angular 3.9.2

System:

    Android SDK Tools : 26.1.1
    Node              : v8.9.3
    npm               : 5.6.0
    OS                : macOS High Sierra
    Xcode             : Xcode 9.2 Build version 9C40b

Environment Variables:

    ANDROID_HOME : /Users/jgf/Library/Android/sdk

Misc:

    backend : legacy

cordova平台版

Installed platforms:
  android 6.4.0
  browser 4.1.0
  ios 4.4.0
Available platforms:
  blackberry10 ~3.8.0 (deprecated)
  osx ~4.0.1
  webos ~3.7.0

cordova build android --verbose

No scripts found for hook "before_build".
No scripts found for hook "before_prepare".
Checking config.xml and package.json for saved platforms that haven't been added to the project
Config.xml and package.json platforms are the same. No pkg.json modification.
Package.json and config.xml platforms are different. Updating config.xml with most current list of platforms.
PlatformApi successfully found for platform android
Checking config.xml for saved plugins that haven't been added to the project
Checking for any plugins added to the project that have not been installed in android platform
No differences found between plugins added to project and installed in android platform. Continuing...
Generating platform-specific config.xml from defaults for android at /opt/IonicProjects/aews_official_rc_1.2.09/platforms/android/res/xml/config.xml
Merging project's config.xml into platform-specific android config.xml
Merging and updating files from [www, platforms/android/platform_www] to platforms/android/assets/www
Wrote out android application name "ET-Mobile" to /opt/IonicProjects/aews_official_rc_1.2.09/platforms/android/res/values/strings.xml
android-versionCode not found in config.xml. Generating a code based on version in config.xml (0.0.1): 1
Wrote out Android package name "com.extratechnology.etmobile" to /opt/IonicProjects/aews_official_rc_1.2.09/platforms/android/src/com/extratechnology/etmobile/MainActivity.java
Updating icons at platforms/android/res
Updating splash screens at platforms/android/res
This app does not have additional resource files defined
Prepared android project successfully
No scripts found for hook "after_prepare".
No scripts found for hook "before_compile".
ANDROID_HOME=/Users/jgf/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home
Subproject Path: CordovaLib
Running command: /opt/IonicProjects/aews_official_rc_1.2.09/platforms/android/gradlew cdvBuildDebug -b /opt/IonicProjects/aews_official_rc_1.2.09/platforms/android/build.gradle -Dorg.gradle.daemon=true -Dorg.gradle.jvmargs=-Xmx2048m -Pandroid.useDeprecatedNdk=true
Error: spawn EACCES

build.gradle in platorms/android gradlew in platforns/android

拥有Android Studio 3.0.1 Android Studio 3.0.1 SDK Platforms (SDK Location shown for .profile) SDK Tools SDK Update Sites Path to Gradle inside Android Studio package contents

我的 .profile (基于this)包含:

export JAVA_HOME=$(/usr/libexec/java_home)
export ANDROID_HOME=~/Library/Android/sdk
#ANDROID_HOME=/opt/android-sdk
export NVM_DIR="$HOME/.nvm"
export PATH=${JAVA_HOME}/bin:${PATH}
export PATH=${ANDROID_HOME}/platform-tools:${PATH}
export PATH=${ANDROID_HOME}/tools:${PATH}
export PATH=${ANDROID_HOME}/tools/bin:${PATH}
#${ANDROID_HOME}/tools/bin:${HOME}/bin:.
export GRADLE_HOME="/Applications/Android Studio.app/Contents/gradle/gradle-4.1"
export PATH=${PATH}:${GRADLE_HOME}/bin

这是我此时唯一的另一个想法..Android Studio中的空间。 这可能会弄乱路径,所以我倾向于将其复制出来。

哪个gradle 会产生正确的路径......

/Applications/Android Studio.app/Contents/gradle/gradle-4.1/bin/gradle

(之前有一个旧的brew版本我已经卸载了,但指向带有路径的Android Studio版本似乎没有任何区别。)

最后一个脚注......当时android是一个可以同时用于sdk和apk管理器功能的命令,你曾经不得不做一些像接受许可条款或类似性质的东西。 没有什么比这更像我在这里也不知道了吗? 只是,我正在寻找选项。

在SurajRao的提示之后,运行 cordova build android --verbose

我现在正在解决最初的问题。

这是通过这样做完成的:

cd <project folder>/platform/android/
chmod +x build.gradle 
chmod +x gradlew

现在产生:

Error: /opt/IonicProjects/aews_official_rc_1.2.09/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':CordovaLib'.
> Could not resolve all files for configuration ':CordovaLib:classpath'.
   > Could not resolve org.bouncycastle:bcprov-jdk15on:1.48.
     Required by:
         project :CordovaLib > com.android.tools.build:gradle:2.2.3 > com.android.tools.build:gradle-core:2.2.3 > com.android.tools.build:builder:2.2.3
         project :CordovaLib > com.android.tools.build:gradle:2.2.3 > com.android.tools.build:gradle-core:2.2.3 > com.android.tools.build:builder:2.2.3 > com.android.tools:sdk-common:25.2.3
         project :CordovaLib > com.android.tools.build:gradle:2.2.3 > com.android.tools.build:gradle-core:2.2.3 > com.android.tools.build:builder:2.2.3 > org.bouncycastle:bcpkix-jdk15on:1.48
      > Could not resolve org.bouncycastle:bcprov-jdk15on:1.48.
         > Could not get resource 'https://jcenter.bintray.com/org/bouncycastle/bcprov-jdk15on/1.48/bcprov-jdk15on-1.48.pom'.
            > Could not HEAD 'https://jcenter.bintray.com/org/bouncycastle/bcprov-jdk15on/1.48/bcprov-jdk15on-1.48.pom'. Received status code 502 from server: Bad Gateway

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

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

将根据建议here尝试 gradle init ......这似乎解决了这个问题。

2 个答案:

答案 0 :(得分:8)

我发现使用--verbose标志直接使用cordova命令而不是ionic命令在cordova的构建过程中提供调试信息。

 cordova build android --verbose

编辑 - &gt;我提出了一个关于verbose的离子here的Github请求,并且应该为Ionic Cli 4修复它。

根据您的日志,

Running command: /opt/IonicProjects/aews_official_rc_1.2.09/platforms/android/gradlew cdvBuildDebug -b /opt/IonicProjects/aews_official_rc_1.2.09/platforms/android/build.gradle -Dorg.gradle.daemon=true -Dorg.gradle.jvmargs=-Xmx2048m -Pandroid.useDeprecatedNdk=true

是你的问题。

您必须向

提供可执行权限
/opt/IonicProjects/aews_official_rc_1.2.09/platforms/android/build.gradle

/opt/IonicProjects/aews_official_rc_1.2.09/platforms/android/gradlew 

使用chmod +x

答案 1 :(得分:0)

如果您使用的是Ubuntu,则需要在终端中添加 sudo cordova build android --verbose 。这基本上是一个许可问题。