CentOS 7下ionic build android 出错 Execution failed for task ':processDebugResources'.

执行ionic build android:

[zhangjiayuan@localhost moodlemobile2-old]$ ionic build android


错误如下:

:CordovaLib:processDebugResources FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':CordovaLib:processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/opt/android-sdk-linux/build-tools/23.0.3/aapt'' finished with non-zero exit value 127

* 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: 3.532 secs
Error: Error code 1 for command: /home/zhangjiayuan/moodlemobile2-old/platforms/android/gradlew with args: cdvBuildDebug,-b,/home/zhangjiayuan/moodlemobile2-old/platforms/android/build.gradle,-Dorg.gradle.daemon=true,-Pandroid.useDeprecatedNdk=true

仔细看问题:Process 'command '/opt/android-sdk-linux/build-tools/23.0.3/aapt''

原因是aapt这个命令找不到,

那么尝试在终端执行:

[zhangjiayuan@localhost 下载]$ /opt/android-sdk-linux/build-tools/23.0.3/aapt
/opt/android-sdk-linux/build-tools/23.0.3/aapt: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory

果然,发现aapt这个命令找不到libz.so.1这个依赖,所以接下来解决问题:

(1)查看libz.so.1依赖由谁提供:

[zhangjiayuan@localhost 下载]$ sudo yum whatprovides libz.so.1
[sudo] password for zhangjiayuan:
已加载插件:fastestmirror, langpacks
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * extras: mirrors.163.com
 * updates: mirrors.163.com
zlib-1.2.7-15.el7.i686 : The compression and decompression library
源    :base
匹配来源:
提供    :libz.so.1

(2)然后安装zlib-1.2.7-15.el7.i686

[zhangjiayuan@localhost 下载]$ sudo yum install zlib-1.2.7-15.el7.i686
已加载插件:fastestmirror, langpacks
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
adobe-linux-x86_64                                       |  951 B     00:00     
base                                                     | 3.6 kB     00:00     
extras                                                   | 3.4 kB     00:00     
google-chrome                                            |  951 B     00:00     
updates                                                  | 3.4 kB     00:00     
(1/2): extras/7/x86_64/primary_db                          | 132 kB   00:01     
(2/2): updates/7/x86_64/primary_db                         | 4.9 MB   00:07     
(1/2): google-chrome/primary                               | 1.8 kB   00:00     
(2/2): adobe-linux-x86_64/primary                          | 1.2 kB   00:03     
Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * extras: mirrors.163.com
 * updates: mirrors.163.com
adobe-linux-x86_64                                                          2/2
google-chrome                                                               3/3
正在解决依赖关系
--> 正在检查事务
---> 软件包 zlib.i686.0.1.2.7-15.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

================================================================================
 Package         架构            版本                     源               大小
================================================================================
正在安装:
 zlib            i686            1.2.7-15.el7             base             90 k

事务概要
================================================================================
安装  1 软件包

总下载量:90 k
安装大小:180 k
Is this ok [y/d/N]: y
Downloading packages:
zlib-1.2.7-15.el7.i686.rpm                                 |  90 kB   00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : zlib-1.2.7-15.el7.i686                                      1/1
  验证中      : zlib-1.2.7-15.el7.i686                                      1/1

已安装:
  zlib.i686 0:1.2.7-15.el7                                                      

完毕!


(3)查看aapt这个命令是否已经解决

[zhangjiayuan@localhost 下载]$ /opt/android-sdk-linux/build-tools/23.0.3/aapt
Android Asset Packaging Tool

Usage:
 aapt l[ist] [-v] [-a] file.{zip,jar,apk}
   List contents of Zip-compatible archive.
......



aapt这个命令已经解决,接下来,重新ionic build android

[zhangjiayuan@localhost moodlemobile2-old]$ ionic build android

FAILURE: Build failed with an exception.


* What went wrong:
Execution failed for task ':processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/opt/android-sdk-linux/build-tools/23.0.3/aapt'' finished with non-zero exit value 1

* 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: 12.562 secs

Error: Error code 1 for command: /home/zhangjiayuan/moodlemobile2-old/platforms/android/gradlew with args: cdvBuildDebug,-b,/home/zhangjiayuan/moodlemobile2-old/platforms/android/build.gradle,-Dorg.gradle.daemon=true,-Pandroid.useDeprecatedNdk=true


发现了新的问题processDebugResources问题,原因是项目的www/addons/menuDemo/路径下出现了中文文件“说明.txt”,

所以只要更改文件名为英文文件名“readme.txt”即可,

因为修改了代码,所以需要gulp重新构建 并 重新打包:

[zhangjiayuan@localhost moodlemobile2-old]$ gulp

[15:23:39] Using gulpfile ~/moodlemobile2-old/gulpfile.js
[15:23:39] Starting 'build'...
[15:23:39] Starting 'sass-build'...
[15:23:39] Starting 'lang'...
[15:23:39] Finished 'lang' after 58 ms
[15:23:44] Finished 'sass-build' after 4.71 s
[15:23:44] Starting 'sass'...
[15:23:46] Finished 'sass' after 1.72 s
[15:23:46] Finished 'build' after 6.59 s
[15:23:46] Starting 'config'...
[15:23:46] Finished 'config' after 14 ms
[15:23:46] Starting 'default'...
[15:23:46] Finished 'default' after 7.16 μs


[zhangjiayuan@localhost moodlemobile2-old]$ ionic build android

.....

:cdvBuildDebug

BUILD SUCCESSFUL

Total time: 17.24 secs
Built the following apk(s):
    /home/zhangjiayuan/moodlemobile2-old/platforms/android/build/outputs/apk/android-debug.apk


到此,问题解决。



你可能感兴趣的:(ionic,cordova)