New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem Isolated - Need Solution. Failed Build: ':app:processArm64DebugResources' attr/ttcIndex attr/fontVariationSettings #205

Open
GBoll opened this Issue Mar 8, 2018 · 57 comments

Comments

Projects
None yet
@GBoll
Copy link

GBoll commented Mar 8, 2018

Today with no change to my dev environment I can no longer build. I found that 2 attributes are duplicated in an intermediate values.xml file as seen below. The problem resource seems to be item xwalk.pak

Besides being duplicated in the same tag, the attr fontVariationSettings and ttcIndex do not even appear in my historical project files until today. Wha??

name="fontVariationSettings"

name="ttcIndex"

build error

/private/var/root/.gradle/caches/transforms-1/files-1.1/xwalk_core_library-23.53.589.4.aar/279cc92185b8b46cd39a2d369762150e/res/values/dimens_03.xml:14:5-51: AAPT: error: resource android:attr/':app:processArm64DebugResources' not found.

/private/var/root/.gradle/caches/transforms-1/files-1.1/xwalk_core_library-23.53.589.4.aar/279cc92185b8b46cd39a2d369762150e/res/values/dimens_03.xml:14:5-51: AAPT: error: resource android:attr/ttcIndex not found.

/Users/harddrive/projects/ffin/platforms/android/app/build/intermediates/incremental/mergeArm64DebugResources/merged.dir/values/values.xml:99: error: resource android:attr/fontVariationSettings not found.
/Users/harddrive/projects/ffin/platforms/android/app/build/intermediates/incremental/mergeArm64DebugResources/merged.dir/values/values.xml:99: error: resource android:attr/ttcIndex not found.
error: failed linking references.

values.xml
line 99
<declare-styleable name="FontFamilyFont"><attr name="fontStyle"> <enum name="normal" value="0"/> <enum name="italic" value="1"/> </attr><attr format="reference" name="font"/><attr format="integer" name="fontWeight"/><attr format="string" name="fontVariationSettings"/><attr format="integer" name="ttcIndex"/><attr name="android:fontStyle"/><attr name="android:font"/><attr name="android:fontWeight"/><attr name="android:fontVariationSettings"/><attr name="android:ttcIndex"/></declare-styleable>

Howsoever that comes into being, it's definitely above my pay grade to fix.

@pablowskyTres

This comment has been minimized.

Copy link

pablowskyTres commented Mar 8, 2018

Same problem here, trying to solve it since yesterday

@remeddy

This comment has been minimized.

Copy link

remeddy commented Mar 8, 2018

Same here

@Scuttman

This comment has been minimized.

Copy link

Scuttman commented Mar 9, 2018

This is caused by an incompatibility with the android support library that changed to version 28 in the last day or so. I solved the problem by forcing the build to use a lower support library globally based on @UNUMObile's suggestion as follows:

// build.gradle

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

My project built successfully immediately after I changed this. Hope this might help you too. I lost a day of development because of this!

@senson2018

This comment has been minimized.

Copy link

senson2018 commented Mar 9, 2018

Same here

@GBoll

This comment has been minimized.

Copy link

GBoll commented Mar 9, 2018

Drop by Apache Jira to vote for this in the sidebar. It was listed yesterday as a major bug.

@kenneth-g-flux

This comment has been minimized.

Copy link

kenneth-g-flux commented Mar 9, 2018

This solution didn't work for me, but this one did, so here's to hoping it can help someone else:

I had to replace every instance of com.android.support:support-v4:+ with com.android.support:support-v4:27.1.0 in platforms/android/project.properties and in all plugin.xml files of plugins I am using (do a search).

@CookieCookson

This comment has been minimized.

Copy link

CookieCookson commented Mar 9, 2018

Thanks for the solution @Scuttman! It works perfectly here. I have come up with an extended solution so it works without having to modify build artifacts using hooks. To hot fix any project:

  1. Create a ./build-extras.gradle file in the root of your project with the fix mentioned above:
configurations.all {
    resolutionStrategy {
        force 'com.android.support:support-v4:27.1.0'
    }
}
  1. Create a ./hooks/copy-build-extras-gradle.js hook with the following code to copy the file into the android project
var fs = require('fs');
var path = require('path');
var rootdir = process.env.PWD;
var platformAndroidPath = '/platforms/android/';
var srcFile = path.join(rootdir, 'build-extras.gradle');
var destFile = path.join(rootdir, platformAndroidPath, 'build-extras.gradle');
var destDir = path.dirname(destFile);
if (fs.existsSync(srcFile) && fs.existsSync(destDir)) {
  fs.createReadStream(srcFile).pipe(fs.createWriteStream(destFile));
} else {
  throw new Error('Unable to copy build-extras.gradle');
}
  1. Add the hook to config.xml within the <platform name="android"> tag:
...
<platform name="android">
    <hook src="hooks/copy-build-extras-gradle.js" type="before_build" />
</platform>
  1. Build your project like normal!
@fribace

This comment has been minimized.

Copy link

fribace commented Mar 9, 2018

for those like me that only use phonegap build i made a fork with CookieCookson's modification
https://github.com/fribace/cordova-plugin-crosswalk-webview

@Marchhill

This comment has been minimized.

Copy link

Marchhill commented Mar 9, 2018

@Scuttman I tried this but I still get the same error. I also tried running "cordova clean" and moving the configurations part around in the build.gradle file but no luck.

Am I missing something?

buildscript {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
    dependencies {

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.android.tools.build:gradle:3.0.0'
    }
	configurations.all {
		resolutionStrategy {
			force 'com.android.support:support-v4:27.1.0'
		}
	}
}
@cdcharlebois

This comment has been minimized.

Copy link

cdcharlebois commented Mar 9, 2018

@fribace your fork did not work for me. I had to make the changes in the project root, like @CookieCookson suggested.

@Scuttman

This comment has been minimized.

Copy link

Scuttman commented Mar 9, 2018

@Marchhill

This comment has been minimized.

Copy link

Marchhill commented Mar 9, 2018

@Scuttman thanks for the quick reply, but unfortunately it hasnt changed the error :(
Here is the full error message I get:

$ cordova run android --device
Android Studio project detected
ANDROID_HOME=C:\Users\user\AppData\Local\Android\Sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_45
studio
Subproject Path: CordovaLib
Subproject Path: app
publishNonDefault is deprecated and has no effect anymore. All variants are now published.
Configuration 'compile' in project ':app' is deprecated. Use 'implementation' instead.
null
The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.
        at build_c29bnu6ebta03cjhtpc9mt2gp.run(C:\Users\user\Documents\Coding\Project Grid\grid\platforms\android\app\build.gradle:145)
org.xwalk:xwalk_core_library:23+
:CordovaLib:preBuild UP-TO-DATE
:CordovaLib:preDebugBuild UP-TO-DATE
:CordovaLib:compileDebugAidl UP-TO-DATE
:CordovaLib:compileDebugRenderscript UP-TO-DATE
:CordovaLib:checkDebugManifest UP-TO-DATE
:CordovaLib:generateDebugBuildConfig UP-TO-DATE
:CordovaLib:prepareLintJar UP-TO-DATE
:CordovaLib:generateDebugResValues UP-TO-DATE
:CordovaLib:generateDebugResources UP-TO-DATE
:CordovaLib:packageDebugResources UP-TO-DATE
:CordovaLib:platformAttrExtractor UP-TO-DATE
:CordovaLib:processDebugManifest UP-TO-DATE
:CordovaLib:processDebugResources UP-TO-DATE
:CordovaLib:generateDebugSources UP-TO-DATE
:CordovaLib:javaPreCompileDebug UP-TO-DATE
:CordovaLib:compileDebugJavaWithJavac UP-TO-DATE
:CordovaLib:processDebugJavaRes NO-SOURCE
:CordovaLib:transformClassesAndResourcesWithPrepareIntermediateJarsForDebug UP-TO-DATE
:app:preBuild UP-TO-DATE
:app:preArm64DebugBuild UP-TO-DATE
:app:compileArm64DebugAidl UP-TO-DATE
:CordovaLib:packageDebugRenderscript NO-SOURCE
:app:compileArm64DebugRenderscript UP-TO-DATE
:app:checkArm64DebugManifest UP-TO-DATE
:app:generateArm64DebugBuildConfig UP-TO-DATE
:app:prepareLintJar UP-TO-DATE
:CordovaLib:mergeDebugShaders UP-TO-DATE
:CordovaLib:compileDebugShaders UP-TO-DATE
:CordovaLib:generateDebugAssets UP-TO-DATE
:CordovaLib:mergeDebugAssets UP-TO-DATE
:app:mergeArm64DebugShaders UP-TO-DATE
:app:compileArm64DebugShaders UP-TO-DATE
:app:generateArm64DebugAssets UP-TO-DATE
:app:mergeArm64DebugAssets UP-TO-DATE
:app:createXwalkCommandLineFileArm64Debug
:app:generateArm64DebugResValues UP-TO-DATE
:app:generateArm64DebugResources UP-TO-DATE
:app:mergeArm64DebugResources
:app:createArm64DebugCompatibleScreenManifests UP-TO-DATE
:app:processArm64DebugManifest UP-TO-DATE
:app:splitsDiscoveryTaskArm64Debug UP-TO-DATE
:app:processArm64DebugResourcesC:\Users\user\Documents\Coding\Project Grid\grid\platforms\android\app\build\intermediates\incremental\mergeArm64DebugResources\merged.dir\values\values.xml:100: error: resource android:attr/fontVariationSettings not found.
C:\Users\user\Documents\Coding\Project Grid\grid\platforms\android\app\build\intermediates\incremental\mergeArm64DebugResources\merged.dir\values\values.xml:100: error: resource android:attr/ttcIndex not found.
error: failed linking references.

Failed to execute aapt
com.android.ide.common.process.ProcessException: Failed to execute aapt
        at com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:796)
        at com.android.build.gradle.tasks.ProcessAndroidResources.invokeAaptForSplit(ProcessAndroidResources.java:551)
        at com.android.build.gradle.tasks.ProcessAndroidResources.doFullTaskAction(ProcessAndroidResources.java:285)
        at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:109)
        at sun.reflect.GeneratedMethodAccessor390.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
        at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:173)
        at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
        at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:121)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:122)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:111)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
        at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:63)
        at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
        at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
        at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
        at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
        at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:124)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:80)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:105)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:99)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:625)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:580)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:99)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
        at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:503)
        at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:482)
        at com.google.common.util.concurrent.AbstractFuture$TrustedFuture.get(AbstractFuture.java:79)
        at com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:794)
        ... 47 more
Caused by: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
        at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:503)
        at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:462)
        at com.google.common.util.concurrent.AbstractFuture$TrustedFuture.get(AbstractFuture.java:79)
        at com.android.builder.internal.aapt.v2.QueueableAapt2.lambda$makeValidatedPackage$1(QueueableAapt2.java:179)
        at com.android.builder.internal.aapt.v2.QueueableAapt2$$Lambda$307/2131030769.run(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) FAILED

        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        ... 1 more
Caused by: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
        at com.android.builder.png.AaptProcess$NotifierProcessOutput.handleOutput(AaptProcess.java:454)
        at com.android.builder.png.AaptProcess$NotifierProcessOutput.err(AaptProcess.java:411)
        at com.android.builder.png.AaptProcess$ProcessOutputFacade.err(AaptProcess.java:332)
        at com.android.utils.GrabProcessOutput$1.run(GrabProcessOutput.java:104)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processArm64DebugResources'.
> Failed to execute aapt

* Try:
Run with 32 actionable tasks: 3 executed, 29 up-to-date
--stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

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

BUILD FAILED in 19s
(node:10880) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: cmd: Command failed with exit code 1 Error output:
C:\Users\user\Documents\Coding\Project Grid\grid\platforms\android\app\build\intermediates\incremental\mergeArm64DebugResources\merged.dir\values\values.xml:100: error: resource android:attr/fontVariationSettings not found.
C:\Users\user\Documents\Coding\Project Grid\grid\platforms\android\app\build\intermediates\incremental\mergeArm64DebugResources\merged.dir\values\values.xml:100: error: resource android:attr/ttcIndex not found.
error: failed linking references.

Failed to execute aapt
com.android.ide.common.process.ProcessException: Failed to execute aapt
        at com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:796)
        at com.android.build.gradle.tasks.ProcessAndroidResources.invokeAaptForSplit(ProcessAndroidResources.java:551)
        at com.android.build.gradle.tasks.ProcessAndroidResources.doFullTaskAction(ProcessAndroidResources.java:285)
        at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:109)
        at sun.reflect.GeneratedMethodAccessor390.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
        at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:173)
        at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
        at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:121)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:122)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:111)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
        at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:63)
        at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
        at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
        at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
        at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
        at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:124)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:80)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:105)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:99)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:625)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:580)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:99)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
        at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:503)
        at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:482)
        at com.google.common.util.concurrent.AbstractFuture$TrustedFuture.get(AbstractFuture.java:79)
        at com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:794)
        ... 47 more
Caused by: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
        at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:503)
        at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:462)
        at com.google.common.util.concurrent.AbstractFuture$TrustedFuture.get(AbstractFuture.java:79)
        at com.android.builder.internal.aapt.v2.QueueableAapt2.lambda$makeValidatedPackage$1(QueueableAapt2.java:179)
        at com.android.builder.internal.aapt.v2.QueueableAapt2$$Lambda$307/2131030769.run(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        ... 1 more
Caused by: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
        at com.android.builder.png.AaptProcess$NotifierProcessOutput.handleOutput(AaptProcess.java:454)
        at com.android.builder.png.AaptProcess$NotifierProcessOutput.err(AaptProcess.java:411)
        at com.android.builder.png.AaptProcess$ProcessOutputFacade.err(AaptProcess.java:332)
        at com.android.utils.GrabProcessOutput$1.run(GrabProcessOutput.java:104)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processArm64DebugResources'.
> 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.

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

BUILD FAILED in 19s
@Scuttman

This comment has been minimized.

Copy link

Scuttman commented Mar 9, 2018

I notice you are using build tools com.android.tools.build:gradle:2.2.3

I am using v2.2.3. Don't know if that helps you. I also downgraded to cordova 7.1.0 rather than 8.
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
}

Here is my build.gradle file to compare:

apply plugin: 'com.android.application'

buildscript {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }

    // Switch the Android Gradle plugin version requirement depending on the
    // installed version of Gradle. This dependency is documented at
    // http://tools.android.com/tech-docs/new-build-system/version-compatibility
    // and https://issues.apache.org/jira/browse/CB-8143
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'
    }
}

configurations.all {
resolutionStrategy.force 'com.android.support:support-v4:24.0.0'
}
// Allow plugins to declare Maven dependencies via build-extras.gradle.
allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}

task wrapper(type: Wrapper) {
    gradleVersion = '2.14.1'
}

// Configuration properties. Set these via environment variables, build-extras.gradle, or gradle.properties.
// Refer to: http://www.gradle.org/docs/current/userguide/tutorial_this_and_that.html
ext {
    apply from: 'CordovaLib/cordova.gradle'
    // The value for android.compileSdkVersion.
    if (!project.hasProperty('cdvCompileSdkVersion')) {
        cdvCompileSdkVersion = null;
    }
    // The value for android.buildToolsVersion.
    if (!project.hasProperty('cdvBuildToolsVersion')) {
        cdvBuildToolsVersion = null;
    }
    // Sets the versionCode to the given value.
    if (!project.hasProperty('cdvVersionCode')) {
        cdvVersionCode = null
    }
    // Sets the minSdkVersion to the given value.
    if (!project.hasProperty('cdvMinSdkVersion')) {
        cdvMinSdkVersion = null
    }
    // Whether to build architecture-specific APKs.
    if (!project.hasProperty('cdvBuildMultipleApks')) {
        cdvBuildMultipleApks = null
    }
    // .properties files to use for release signing.
    if (!project.hasProperty('cdvReleaseSigningPropertiesFile')) {
        cdvReleaseSigningPropertiesFile = null
    }
    // .properties files to use for debug signing.
    if (!project.hasProperty('cdvDebugSigningPropertiesFile')) {
        cdvDebugSigningPropertiesFile = null
    }
    // Set by build.js script.
    if (!project.hasProperty('cdvBuildArch')) {
        cdvBuildArch = null
    }

    // Plugin gradle extensions can append to this to have code run at the end.
    cdvPluginPostBuildExtras = []
}

// PLUGIN GRADLE EXTENSIONS START
apply from: "cordova-plugin-crosswalk-webview/customers-xwalk.gradle"
apply from: "cordova-plugin-googlemaps/customers-build-extras.gradle"
apply from: "cordova-plugin-googlemaps/customers-tbxml-android.gradle"
// PLUGIN GRADLE EXTENSIONS END

def hasBuildExtras = file('build-extras.gradle').exists()
if (hasBuildExtras) {
    apply from: 'build-extras.gradle'
}

// Set property defaults after extension .gradle files.
if (ext.cdvCompileSdkVersion == null) {
    ext.cdvCompileSdkVersion = privateHelpers.getProjectTarget()
}
if (ext.cdvBuildToolsVersion == null) {
    ext.cdvBuildToolsVersion = privateHelpers.findLatestInstalledBuildTools()
}
if (ext.cdvDebugSigningPropertiesFile == null && file('debug-signing.properties').exists()) {
    ext.cdvDebugSigningPropertiesFile = 'debug-signing.properties'
}
if (ext.cdvReleaseSigningPropertiesFile == null && file('release-signing.properties').exists()) {
    ext.cdvReleaseSigningPropertiesFile = 'release-signing.properties'
}

// Cast to appropriate types.
ext.cdvBuildMultipleApks = cdvBuildMultipleApks == null ? false : cdvBuildMultipleApks.toBoolean();
ext.cdvMinSdkVersion = cdvMinSdkVersion == null ? null : Integer.parseInt('' + cdvMinSdkVersion)
ext.cdvVersionCode = cdvVersionCode == null ? null : Integer.parseInt('' + cdvVersionCode)

def computeBuildTargetName(debugBuild) {
    def ret = 'assemble'
    if (cdvBuildMultipleApks && cdvBuildArch) {
        def arch = cdvBuildArch == 'arm' ? 'armv7' : cdvBuildArch
        ret += '' + arch.toUpperCase().charAt(0) + arch.substring(1);
    }
    return ret + (debugBuild ? 'Debug' : 'Release')
}

// Make cdvBuild a task that depends on the debug/arch-sepecific task.
task cdvBuildDebug
cdvBuildDebug.dependsOn {
    return computeBuildTargetName(true)
}

task cdvBuildRelease
cdvBuildRelease.dependsOn {
    return computeBuildTargetName(false)
}

task cdvPrintProps << {
    println('cdvCompileSdkVersion=' + cdvCompileSdkVersion)
    println('cdvBuildToolsVersion=' + cdvBuildToolsVersion)
    println('cdvVersionCode=' + cdvVersionCode)
    println('cdvMinSdkVersion=' + cdvMinSdkVersion)
    println('cdvBuildMultipleApks=' + cdvBuildMultipleApks)
    println('cdvReleaseSigningPropertiesFile=' + cdvReleaseSigningPropertiesFile)
    println('cdvDebugSigningPropertiesFile=' + cdvDebugSigningPropertiesFile)
    println('cdvBuildArch=' + cdvBuildArch)
    println('computedVersionCode=' + android.defaultConfig.versionCode)
    android.productFlavors.each { flavor ->
        println('computed' + flavor.name.capitalize() + 'VersionCode=' + flavor.versionCode)
    }
}

android {
    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
            jniLibs.srcDirs = ['libs']
        }
    }

    defaultConfig {
        versionCode cdvVersionCode ?: new BigInteger("" + privateHelpers.extractIntFromManifest("versionCode"))
        applicationId privateHelpers.extractStringFromManifest("package")

        if (cdvMinSdkVersion != null) {
            minSdkVersion cdvMinSdkVersion
        }
    }

    lintOptions {
      abortOnError false;
    }

    compileSdkVersion cdvCompileSdkVersion
    buildToolsVersion cdvBuildToolsVersion

    if (Boolean.valueOf(cdvBuildMultipleApks)) {
        productFlavors {
            armv7 {
                versionCode defaultConfig.versionCode*10 + 2
                ndk {
                    abiFilters "armeabi-v7a", ""
                }
            }
            x86 {
                versionCode defaultConfig.versionCode*10 + 4
                ndk {
                    abiFilters "x86", ""
                }
            }
            all {
                ndk {
                    abiFilters "all", ""
                }
            }
        }
    }
    /*

    ELSE NOTHING! DON'T MESS WITH THE VERSION CODE IF YOU DON'T HAVE TO!

    else if (!cdvVersionCode) {
      def minSdkVersion = cdvMinSdkVersion ?: privateHelpers.extractIntFromManifest("minSdkVersion")
      // Vary versionCode by the two most common API levels:
      // 14 is ICS, which is the lowest API level for many apps.
      // 20 is Lollipop, which is the lowest API level for the updatable system webview.
      if (minSdkVersion >= 20) {
        defaultConfig.versionCode += 9
      } else if (minSdkVersion >= 14) {
        defaultConfig.versionCode += 8
      }
    }
    */

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_6
        targetCompatibility JavaVersion.VERSION_1_6
    }

    if (cdvReleaseSigningPropertiesFile) {
        signingConfigs {
            release {
                // These must be set or Gradle will complain (even if they are overridden).
                keyAlias = ""
                keyPassword = "__unset" // And these must be set to non-empty in order to have the signing step added to the task graph.
                storeFile = null
                storePassword = "__unset"
            }
        }
        buildTypes {
            release {
                signingConfig signingConfigs.release
            }
        }
        addSigningProps(cdvReleaseSigningPropertiesFile, signingConfigs.release)
    }
    if (cdvDebugSigningPropertiesFile) {
        addSigningProps(cdvDebugSigningPropertiesFile, signingConfigs.debug)
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    // SUB-PROJECT DEPENDENCIES START
    debugCompile(project(path: "CordovaLib", configuration: "debug"))
    releaseCompile(project(path: "CordovaLib", configuration: "release"))
    compile "com.google.android.gms:play-services-maps:11.8.0"
    compile "com.google.android.gms:play-services-location:11.8.0"
    compile "com.android.support:support-v4:27.1.0"
    // SUB-PROJECT DEPENDENCIES END
}

def promptForReleaseKeyPassword() {
    if (!cdvReleaseSigningPropertiesFile) {
        return;
    }
    if ('__unset'.equals(android.signingConfigs.release.storePassword)) {
        android.signingConfigs.release.storePassword = privateHelpers.promptForPassword('Enter key store password: ')
    }
    if ('__unset'.equals(android.signingConfigs.release.keyPassword)) {
        android.signingConfigs.release.keyPassword = privateHelpers.promptForPassword('Enter key password: ');
    }
}

gradle.taskGraph.whenReady { taskGraph ->
    taskGraph.getAllTasks().each() { task ->
        if (task.name == 'validateReleaseSigning' || task.name == 'validateSigningRelease') {
            promptForReleaseKeyPassword()
        }
    }
}

def addSigningProps(propsFilePath, signingConfig) {
    def propsFile = file(propsFilePath)
    def props = new Properties()
    propsFile.withReader { reader ->
        props.load(reader)
    }

    def storeFile = new File(props.get('key.store') ?: privateHelpers.ensureValueExists(propsFilePath, props, 'storeFile'))
    if (!storeFile.isAbsolute()) {
        storeFile = RelativePath.parse(true, storeFile.toString()).getFile(propsFile.getParentFile())
    }
    if (!storeFile.exists()) {
        throw new FileNotFoundException('Keystore file does not exist: ' + storeFile.getAbsolutePath())
    }
    signingConfig.keyAlias = props.get('key.alias') ?: privateHelpers.ensureValueExists(propsFilePath, props, 'keyAlias')
    signingConfig.keyPassword = props.get('keyPassword', props.get('key.alias.password', signingConfig.keyPassword))
    signingConfig.storeFile = storeFile
    signingConfig.storePassword = props.get('storePassword', props.get('key.store.password', signingConfig.storePassword))
    def storeType = props.get('storeType', props.get('key.store.type', ''))
    if (!storeType) {
        def filename = storeFile.getName().toLowerCase();
        if (filename.endsWith('.p12') || filename.endsWith('.pfx')) {
            storeType = 'pkcs12'
        } else {
            storeType = signingConfig.storeType // "jks"
        }
    }
    signingConfig.storeType = storeType
}

for (def func : cdvPluginPostBuildExtras) {
    func()
}

// This can be defined within build-extras.gradle as:
//     ext.postBuildExtras = { ... code here ... }
if (hasProperty('postBuildExtras')) {
    postBuildExtras()
}
@Marchhill

This comment has been minimized.

Copy link

Marchhill commented Mar 9, 2018

@Scuttman Ok so I tried downgrading cordova, no change. But when I set gradle to your version in my build.gradle I get a different error:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':CordovaLib'.
> Failed to notify project evaluation listener.
   > com.android.build.gradle.tasks.factory.AndroidJavaCompile.setDependencyCacheDir(Ljava/io/File;)V

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

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

BUILD FAILED in 28s
Error: cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':CordovaLib'.
> Failed to notify project evaluation listener.
   > com.android.build.gradle.tasks.factory.AndroidJavaCompile.setDependencyCacheDir(Ljava/io/File;)V

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

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

BUILD FAILED in 28s
@allannienhuis

This comment has been minimized.

Copy link

allannienhuis commented Mar 9, 2018

@fribace your fork worked perfectly for me - Thanks! I needed to first remove all traces of the previous plugin install (rm -fr plugins/cordova-plugin-crosswalk-webview, edit config.xml to remove the reference), then added it back in with cordova plugin add https://github.com/fribace/cordova-plugin-crosswalk-webview

@luzeeker

This comment has been minimized.

Copy link

luzeeker commented Mar 10, 2018

Thanks a lot @Scuttman, it finally works.

@Marchhill

This comment has been minimized.

Copy link

Marchhill commented Mar 10, 2018

Phew finally after slamming my head on my desk for three days it finally works! The problem was I was changing platforms/android/build.gradle, for any other beginners the file you have to change is platforms/android/app/build.gradle. Now everything works perfectly

@eddOrnelas

This comment has been minimized.

Copy link

eddOrnelas commented Mar 11, 2018

@Marchhill dude!!! thanks a lot, now i can compile without problems 👍

@GBoll

This comment has been minimized.

Copy link

GBoll commented Mar 12, 2018

I second @Marchhill. That took a while to figure out.

Further, for general info in troubleshooting I found the following bit o' honey ... a comment in a deep file, which explains why I could not search for the string that everyone else is just changing the ending of. Since Crosswalk is the only plugin in a barebones Cordova CLI setup, the relevant bit gets mentioned only this way:

xwalk_core_library-23.53.589.4.pom ‘aar’ package
“<!-- Crosswalk itself does not depend on external libraries, but it inherits
some dependencies from Chromium itself. —>”
<dependencies> <dependency> <groupId>com.android.support</groupId> <artifactId>support-v4</artifactId> <version>[13.0.0,)</version> <!-- >= 13.0.0 --> <scope>runtime</scope> </dependency> </dependencies>

My solution was to change the gradle files in 5 places. Overkill? Dunno. I lost my patience. I added this to every one of the 5 files below dependencies:
configurations.all { resolutionStrategy { force 'com.android.support:support-v4:27.+' } }

Notes: The two files named build.gradle are NOT the same. #5 directly references the en-xwalk.gradle. These will be removed from your project if you remove android from the project.

Mac

  1. /Users/harddrive/projects/ifin/node_modules/cordova-plugin-crosswalk-webview/platforms/android/xwalk.gradle
  2. /Users/harddrive/projects/ifin/plugins/cordova-plugin-crosswalk-webview/platforms/android/xwalk.gradle
  3. /Users/harddrive/projects/ifin/platforms/android/cordova-plugin-crosswalk-webview/en-xwalk.gradle
  4. /Users/harddrive/projects/ifin/platforms/android/build.gradle
  5. /Users/harddrive/projects/ifin/platforms/android/app/build.gradle

REGARDING THE ORIGIN OF THE PROBLEM
Android released a new version of the support library Revision 28.0.0 Alpha 1 as a replacement for 27.1.0. This version is getting picked up as the default support library under the covers. This Android note is not comforting:

(March 2018)
Note: 28.0.0-alpha1 is a pre-release version to support the Android P developer preview. Its API surface is subject to change, and it does not necessarily include features or bug fixes from the latest stable versions of Support Library. For details on the P developer preview, see the release notes.

You will see that the newer support library creates duplicated attributes in the tag <declare-stylable> in values.xml. Although the attr/fontVariationSettings and attr/ttcIndex never before appeared in my project, suddenly I had them twice in one tag. I suspect the problem really comes the second time the build hits the attribute.

///
Thanks to all the people who know more than I do, for posting what you know.

@peakcool

This comment has been minimized.

Copy link

peakcool commented Mar 13, 2018

@Marchhill THANKS!! IT'S WORK

@matrixreal

This comment has been minimized.

Copy link

matrixreal commented Mar 21, 2018

hello guys
i get Failed Build: ':app:processArm64DebugResources'
but i can't find where i put the force 'com.android.support:support-v4:27.1.0'
here is my build.gradle from app folder
thanks for help

`/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing,
   software distributed under the License is distributed on an
   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   KIND, either express or implied.  See the License for the
   specific language governing permissions and limitations
   under the License.

*/

apply plugin: 'com.android.application'

buildscript {
repositories {
mavenCentral()
jcenter()
maven {
url "https://maven.google.com"
}
}

dependencies {
    classpath 'com.android.tools.build:gradle:3.0.0'
}

}

// Allow plugins to declare Maven dependencies via build-extras.gradle.
allprojects {
repositories {
mavenCentral();
jcenter()
}
}

task wrapper(type: Wrapper) {
gradleVersion = '4.1.0'
}

// Configuration properties. Set these via environment variables, build-extras.gradle, or gradle.properties.
// Refer to: http://www.gradle.org/docs/current/userguide/tutorial_this_and_that.html
ext {
apply from: '../CordovaLib/cordova.gradle'
// The value for android.compileSdkVersion.
if (!project.hasProperty('cdvCompileSdkVersion')) {
cdvCompileSdkVersion = null;
}
// The value for android.buildToolsVersion.
if (!project.hasProperty('cdvBuildToolsVersion')) {
cdvBuildToolsVersion = null;
}
// Sets the versionCode to the given value.
if (!project.hasProperty('cdvVersionCode')) {
cdvVersionCode = null
}
// Sets the minSdkVersion to the given value.
if (!project.hasProperty('cdvMinSdkVersion')) {
cdvMinSdkVersion = null
}
// Whether to build architecture-specific APKs.
if (!project.hasProperty('cdvBuildMultipleApks')) {
cdvBuildMultipleApks = null
}
// Whether to append a 0 "abi digit" to versionCode when only a single APK is build
if (!project.hasProperty('cdvVersionCodeForceAbiDigit')) {
cdvVersionCodeForceAbiDigit = null
}
// .properties files to use for release signing.
if (!project.hasProperty('cdvReleaseSigningPropertiesFile')) {
cdvReleaseSigningPropertiesFile = null
}
// .properties files to use for debug signing.
if (!project.hasProperty('cdvDebugSigningPropertiesFile')) {
cdvDebugSigningPropertiesFile = null
}
// Set by build.js script.
if (!project.hasProperty('cdvBuildArch')) {
cdvBuildArch = null
}

// Plugin gradle extensions can append to this to have code run at the end.
cdvPluginPostBuildExtras = []

}

// PLUGIN GRADLE EXTENSIONS START
apply from: "../cordova-plugin-crosswalk-webview/com-xwalk.gradle"
// PLUGIN GRADLE EXTENSIONS END

def hasBuildExtras = file('build-extras.gradle').exists()
if (hasBuildExtras) {
apply from: 'build-extras.gradle'
}

// Set property defaults after extension .gradle files.
if (ext.cdvCompileSdkVersion == null) {
ext.cdvCompileSdkVersion = privateHelpers.getProjectTarget()
//ext.cdvCompileSdkVersion = project.ext.defaultCompileSdkVersion
}
if (ext.cdvBuildToolsVersion == null) {
ext.cdvBuildToolsVersion = privateHelpers.findLatestInstalledBuildTools()
//ext.cdvBuildToolsVersion = project.ext.defaultBuildToolsVersion
}
if (ext.cdvDebugSigningPropertiesFile == null && file('../debug-signing.properties').exists()) {
ext.cdvDebugSigningPropertiesFile = '../debug-signing.properties'
}
if (ext.cdvReleaseSigningPropertiesFile == null && file('../release-signing.properties').exists()) {
ext.cdvReleaseSigningPropertiesFile = '../release-signing.properties'
}

// Cast to appropriate types.
ext.cdvBuildMultipleApks = cdvBuildMultipleApks == null ? false : cdvBuildMultipleApks.toBoolean();
ext.cdvVersionCodeForceAbiDigit = cdvVersionCodeForceAbiDigit == null ? false : cdvVersionCodeForceAbiDigit.toBoolean();
ext.cdvMinSdkVersion = cdvMinSdkVersion == null ? null : defaultMinSdkVersion
ext.cdvVersionCode = cdvVersionCode == null ? null : Integer.parseInt('' + cdvVersionCode)

def computeBuildTargetName(debugBuild) {
def ret = 'assemble'
if (cdvBuildMultipleApks && cdvBuildArch) {
def arch = cdvBuildArch == 'arm' ? 'armv7' : cdvBuildArch
ret += '' + arch.toUpperCase().charAt(0) + arch.substring(1);
}
return ret + (debugBuild ? 'Debug' : 'Release')
}

// Make cdvBuild a task that depends on the debug/arch-sepecific task.
task cdvBuildDebug
cdvBuildDebug.dependsOn {
return computeBuildTargetName(true)
}

task cdvBuildRelease
cdvBuildRelease.dependsOn {
return computeBuildTargetName(false)
}

task cdvPrintProps << {
println('cdvCompileSdkVersion=' + cdvCompileSdkVersion)
println('cdvBuildToolsVersion=' + cdvBuildToolsVersion)
println('cdvVersionCode=' + cdvVersionCode)
println('cdvVersionCodeForceAbiDigit=' + cdvVersionCodeForceAbiDigit)
println('cdvMinSdkVersion=' + cdvMinSdkVersion)
println('cdvBuildMultipleApks=' + cdvBuildMultipleApks)
println('cdvReleaseSigningPropertiesFile=' + cdvReleaseSigningPropertiesFile)
println('cdvDebugSigningPropertiesFile=' + cdvDebugSigningPropertiesFile)
println('cdvBuildArch=' + cdvBuildArch)
println('computedVersionCode=' + android.defaultConfig.versionCode)
android.productFlavors.each { flavor ->
println('computed' + flavor.name.capitalize() + 'VersionCode=' + flavor.versionCode)
}
}

android {

defaultConfig {
    versionCode cdvVersionCode ?: new BigInteger("" + privateHelpers.extractIntFromManifest("versionCode"))
    applicationId privateHelpers.extractStringFromManifest("package")

    if (cdvMinSdkVersion != null) {
        minSdkVersion cdvMinSdkVersion
    }
}

lintOptions {
  abortOnError false;
}

compileSdkVersion cdvCompileSdkVersion
buildToolsVersion cdvBuildToolsVersion

//This code exists for Crosswalk and other Native APIs.
//By default, we multiply the existing version code in the Android Manifest by 10 and 
//add a number for each architecture.  If you are not using Crosswalk or SQLite, you can
//ignore this chunk of code, and your version codes will be respected.

if (Boolean.valueOf(cdvBuildMultipleApks)) {
    flavorDimensions "default"

    productFlavors {
        armeabi {
            versionCode defaultConfig.versionCode*10 + 1
            ndk {
                abiFilters = ["armeabi"]
            }
        }
        armv7 {
            versionCode defaultConfig.versionCode*10 + 2
            ndk {
                abiFilters = ["armeabi-v7a"]
            }
        }
        arm64 {
            versionCode defaultConfig.versionCode*10 + 3
            ndk {
                abiFilters = ["arm64-v8a"]
            }
        }
        x86 {
            versionCode defaultConfig.versionCode*10 + 4
            ndk {
                abiFilters = ["x86"]
            }
        }
        x86_64 {
            versionCode defaultConfig.versionCode*10 + 5
            ndk {
                abiFilters = ["x86_64"]
            }
        }
    }
} else if (Boolean.valueOf(cdvVersionCodeForceAbiDigit)) {
    // This provides compatibility to the default logic for versionCode before cordova-android 5.2.0
    defaultConfig {
        versionCode defaultConfig.versionCode*10
    }
}

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

if (cdvReleaseSigningPropertiesFile) {
    signingConfigs {
        release {
            // These must be set or Gradle will complain (even if they are overridden).
            keyAlias = ""
            keyPassword = "__unset" // And these must be set to non-empty in order to have the signing step added to the task graph.
            storeFile = null
            storePassword = "__unset"
        }
    }
    buildTypes {
        release {
            signingConfig signingConfigs.release
        }
    }
    addSigningProps(cdvReleaseSigningPropertiesFile, signingConfigs.release)
}
if (cdvDebugSigningPropertiesFile) {
    addSigningProps(cdvDebugSigningPropertiesFile, signingConfigs.debug)
}

}

/*

  • WARNING: Cordova Lib and platform scripts do management inside of this code here,
  • if you are adding the dependencies manually, do so outside the comments, otherwise
  • the Cordova tools will overwrite them
    */

dependencies {
implementation fileTree(dir: 'libs', include: '*.jar')
// SUB-PROJECT DEPENDENCIES START
implementation(project(path: ":CordovaLib"))
// SUB-PROJECT DEPENDENCIES END
}

def promptForReleaseKeyPassword() {
if (!cdvReleaseSigningPropertiesFile) {
return;
}
if ('__unset'.equals(android.signingConfigs.release.storePassword)) {
android.signingConfigs.release.storePassword = privateHelpers.promptForPassword('Enter key store password: ')
}
if ('__unset'.equals(android.signingConfigs.release.keyPassword)) {
android.signingConfigs.release.keyPassword = privateHelpers.promptForPassword('Enter key password: ');
}
}

gradle.taskGraph.whenReady { taskGraph ->
taskGraph.getAllTasks().each() { task ->
if(['validateReleaseSigning', 'validateSigningRelease', 'validateSigningArmv7Release', 'validateSigningX76Release'].contains(task.name)) {
promptForReleaseKeyPassword()
}
}
}

def addSigningProps(propsFilePath, signingConfig) {
def propsFile = file(propsFilePath)
def props = new Properties()
propsFile.withReader { reader ->
props.load(reader)
}

def storeFile = new File(props.get('key.store') ?: privateHelpers.ensureValueExists(propsFilePath, props, 'storeFile'))
if (!storeFile.isAbsolute()) {
    storeFile = RelativePath.parse(true, storeFile.toString()).getFile(propsFile.getParentFile())
}
if (!storeFile.exists()) {
    throw new FileNotFoundException('Keystore file does not exist: ' + storeFile.getAbsolutePath())
}
signingConfig.keyAlias = props.get('key.alias') ?: privateHelpers.ensureValueExists(propsFilePath, props, 'keyAlias')
signingConfig.keyPassword = props.get('keyPassword', props.get('key.alias.password', signingConfig.keyPassword))
signingConfig.storeFile = storeFile
signingConfig.storePassword = props.get('storePassword', props.get('key.store.password', signingConfig.storePassword))
def storeType = props.get('storeType', props.get('key.store.type', ''))
if (!storeType) {
    def filename = storeFile.getName().toLowerCase();
    if (filename.endsWith('.p12') || filename.endsWith('.pfx')) {
        storeType = 'pkcs12'
    } else {
        storeType = signingConfig.storeType // "jks"
    }
}
signingConfig.storeType = storeType

}

for (def func : cdvPluginPostBuildExtras) {
func()
}

// This can be defined within build-extras.gradle as:
// ext.postBuildExtras = { ... code here ... }
if (hasProperty('postBuildExtras')) {
postBuildExtras()
}`

@tisdall

This comment has been minimized.

Copy link

tisdall commented Mar 23, 2018

I was able to fix it by installing cordova-android-support-gradle-release. It's especially helpful for me since I'm using PhoneGap Build and can't modify the gradle files.

@dragermrb

This comment has been minimized.

Copy link

dragermrb commented May 7, 2018

Same here, no apks

BUILD SUCCESSFUL in 1s
72 actionable tasks: 6 executed, 66 up-to-date
Built the following apk(s):

Crosswalk info:
After much discussion and analysis of the market,
we have decided to discontinue support for Android 4.0 (ICS) in Crosswalk starting with version 20,
so the minSdkVersion of Cordova project is configured to 16 by default.

@dragermrb

This comment has been minimized.

Copy link

dragermrb commented May 15, 2018

After I remove android platform and crosswalk plugin I'm able to build again

cordova plugin rm cordova-plugin-crosswalk-webview
cordova platform rm android
cordova platform add android
cordova plugin add cordova-plugin-crosswalk-webview
@nicolasgrolleau

This comment has been minimized.

Copy link

nicolasgrolleau commented May 28, 2018

I used @CookieCookson 's hook but I had to use v4:24.0.0 instead of v4:27.1.0 to be able to compile again.

@jetma

This comment has been minimized.

Copy link

jetma commented May 30, 2018

Success with build-extras.gradle files's content below:

configurations.all {
    resolutionStrategy {
        force 'com.android.support:support-v4:26+'
    }
}
@shadeeka

This comment has been minimized.

Copy link

shadeeka commented May 31, 2018

@jetma can you please tell where did you put build-extras.gradle and what is your cordova version. I also have the same problem and trying to fix in ionic project. Thank you

@chipbell4

This comment has been minimized.

Copy link

chipbell4 commented Jun 4, 2018

Adding my two cents here! For me, that particular version of android support still failed for me. I used an older version:

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

I then wrote a bash script to do the work as an after_prepare hook:

#!/bin/bash

echo "configurations.all { resolutionStrategy { force 'com.android.support:support-v4:24.+' } }" >> platforms/android/build-extras.gradle

@shadeeka That path (platforms/android/build-extras.gradle) I think is the path that @jetma used (at least it worked for me).

As a note, I'm using cordova-android 6.1.2 which I think explains why I had to use an older android support version. So, for the lonely souls that make it this far down the thread, try fiddling with that android support version :)

@yushaUzumo

This comment has been minimized.

Copy link

yushaUzumo commented Jun 5, 2018

It solves the issue for me as well (thanks) but no one explains what the lines

resolutionStrategy.force 'com.android.support:support-v4:24.0.0'

resolutionStrategy.force 'com.android.support:support-v4:26+'

resolutionStrategy.force 'com.android..support:support-v4:27.1.0'

mean. What do they mean? and which one to use when? Please teach us to fish rather than giving us a fish.

@chipbell4

This comment has been minimized.

Copy link

chipbell4 commented Jun 5, 2018

@shadeeka

This comment has been minimized.

Copy link

shadeeka commented Jun 6, 2018

@chipbell4 got it and the android build is working fine. agreeing with you because still breaks in newer version of cordova and the android platform newer version. but later adding platform and crosswalk plugin into ionic app was simple thing and worked well. But now I have to specifically consider on versions

  • cordova 7.0.0
  • ionic 3.8.1
  • android platform 6.3.0
    Thank you all
@dzun91

This comment has been minimized.

Copy link

dzun91 commented Jun 11, 2018

Thanks for all your information. I also get this problem.

I think that problem is by version of library so Id downgraded my library like to @shadeeka

  • cordova 7.0.0
  • ionic 3.8.1
  • android platform 6.3.0
  • Install: cordova plugin add cordova-android-support-gradle-release
    But I still can not build, can anyone post the information of success build ? (ionic info, android version, etc) ?.

=> OK, now I can build successful. I will write what I did for someone go here later ;)

  • Still use the newest version of ionic and android@7.0.0 because crosswalk@2.4.0 supports it
  • Do not install cordova-android-support-gradle-release I do not know why but it break my build
  • Add code below to platform/android/app/build.grade
    configurations.all { resolutionStrategy.force 'com.android.support:support-v4:24.0.0' }

Thank you all a lot

@inyourhands

This comment has been minimized.

Copy link

inyourhands commented Jun 19, 2018

Fixed @CookieCookson's comment to Cordova Version 8.0.0.

  1. Create a ./build-extras.gradle file in the root of your project with the fix mentioned above:
configurations.all {
    resolutionStrategy {
        force 'com.android.support:support-v4:27.1.0'
    }
}
  1. Create a ./hooks/copy-build-extras-gradle.js hook with the following code to copy the file into the android project ==> Modified the path to copy the 'build-extras.gradle' file to the '/platforms/android/app/' directory
var fs = require('fs');
var path = require('path');
var rootdir = process.env.PWD;
var platformAndroidPath = '/platforms/android/app/';
var srcFile = path.join(rootdir, 'build-extras.gradle');
var destFile = path.join(rootdir, platformAndroidPath, 'build-extras.gradle');
var destDir = path.dirname(destFile);
if (fs.existsSync(srcFile) && fs.existsSync(destDir)) {
  fs.createReadStream(srcFile).pipe(fs.createWriteStream(destFile));
} else {
  throw new Error('Unable to copy build-extras.gradle');
}
  1. Add the hook to config.xml within the tag:
...
<platform name="android">
    <hook src="hooks/copy-build-extras-gradle.js" type="before_build" />
</platform>

Build your project like normal!

Thanks @CookieCookson.

@zabir

This comment has been minimized.

Copy link

zabir commented Jun 22, 2018

Using following plugin solved my issue--

cordova plugin add cordova-android-support-gradle-release

@Riyaz0001

This comment has been minimized.

Copy link

Riyaz0001 commented Jul 14, 2018

@zabir is Right. I have used this plugin and solve my problem.

simply add this
cordova plugin add cordova-android-support-gradle-release --variable ANDROID_SUPPORT_VERSION=27.+
and run/build again.

@maxmaxmaximus2

This comment has been minimized.

Copy link

maxmaxmaximus2 commented Jul 16, 2018

@zabir omg you god!

@thusithawijethunga

This comment has been minimized.

Copy link

thusithawijethunga commented Aug 25, 2018

@Riyaz0001 is Right, it's work for me.

  1. cordova plugin add cordova-android-support-gradle-release --variable ANDROID_SUPPORT_VERSION=27.+

  2. ionic build

Done

@uddsoft

This comment has been minimized.

Copy link

uddsoft commented Sep 5, 2018

@Riyaz0001 感谢。此方法可以解决问题。

@HarelM

This comment has been minimized.

Copy link

HarelM commented Sep 9, 2018

Is there a simpler way to fix this issue?
I was hoping to use crosswalk to allow the user, when clicking a file input to take picture from the camera, much like chrome does now.
But I was unable to build this in release out of the box...

@fongfuse

This comment has been minimized.

Copy link

fongfuse commented Sep 24, 2018

Try to change the compileSdkVersion to: compileSdkVersion 28

@HarelM

This comment has been minimized.

Copy link

HarelM commented Sep 24, 2018

Thanks, got it to work using the plugin explained above: cordova-android-support-gradle-release but after using it my app freezes on my app for some reason, so I removed it. If anyone is interested I can open a separate issue here...

@4046616

This comment has been minimized.

Copy link

4046616 commented Oct 17, 2018

I fixed the issue by removing multiple libraries in ./android/project.properties "com.android.support:support-v4" and putting this "com.android.support:support-v4:27+"

@gtnasser

This comment has been minimized.

Copy link

gtnasser commented Nov 7, 2018

@Marchhill you are the one!!! your tip to change the correct file (platforms\android\app\build.gradle) save my day.Thanks

@mpacary

This comment has been minimized.

Copy link

mpacary commented Nov 12, 2018

Faced the same problem on a Quasar project (0.17) using Cordova building in dev mode (quasar dev -m cordova -T android) right after installing Cordova plugin cordova-plugin-file-opener2.
I had to modify file src-cordova/platforms/android/build.gradle

And in allprojects { ... } section, I've added the "directive" suggested by @Scuttman

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

This comment has been minimized.

Copy link

austincraig09 commented Dec 18, 2018

If anyone is still seeing the problem, I fixed it with:
cordova plugin remove cordova-android-support-gradle-release
Then:
cordova platform remove android
cordova platform add android
cordova build android

Hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment