com.android.ide.common.process.ProcessException: aapt执行失败!我能做什么?

com.android.ide.common.process.ProcessException: Failed to execute aapt! What can I do?

我在 Android 设备上尝试 运行 时遇到错误!我不知道发生了什么!

我该如何解决?

失败:构建失败,出现异常。

构建失败

Total time: 7.791 secs

* What went wrong:
Execution failed for task ':processDebugResources'.
> com.android.ide.common.process.ProcessException: Failed to execute aapt

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Error: cmd: Command failed with exit code 1 Error output:
C:\tmp\myproj\platforms\android\build\intermediates\res\merged\debug\values\values.xml:373: AAPT: Attribute "theme" already defined with incompatible format.

C:\tmp\myproj\platforms\android\build\intermediates\res\merged\debug\values\values.xml:359: AAPT: Original attribute defined here.

C:\tmp\myproj\platforms\android\build\intermediates\res\merged\debug\values-v26\values-v26.xml:15:21-54: AAPT: No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.

C:\tmp\myproj\platforms\android\build\intermediates\res\merged\debug\values\values.xml:373: error: Attribute "theme" already defined with incompatible format.
C:\tmp\myproj\platforms\android\build\intermediates\res\merged\debug\values\values.xml:359: Original attribute defined here.
C:\tmp\myproj\platforms\android\build\intermediates\res\merged\debug\values-v26\values-v26.xml:15: error: Error: No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.



FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':processDebugResources'.
> com.android.ide.common.process.ProcessException: Failed to execute aapt

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

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

已解决

已解决:重新创建项目并再次添加功能!

如果将v4 v7版本更新到26.0.0, 您还应该更改 CompileSdkVersion 和 BuildToolsVersion 到 26.0.0

把这段代码放在最后一部分build.gradle里面

configurations.all {
    resolutionStrategy {
        force 'com.android.support:support-v4:27.1.0'
    }
}

对我来说,这个错误的奇怪原因是我缺少布局中的可绘制对象。我从另一个项目复制了布局,忘记在 运行 我的项目之前复制可绘制对象。 另外,检查布局中的 activity 名称是否没有空格。

这个问题是由于项目环境和执行平台环境不匹配造成的。 尝试在相同的平台环境中创建一个新项目和运行。 如果它 运行,复制粘贴旧项目 src 文件。

$ ionic start 
$ cd "project_name"
$ ionic cordova platform add android
$ ionic cordova run android
copy-paste old project src files