NativeScript / nativescript-background-http

Background Upload plugin for the NativeScript framework
Apache License 2.0
102 stars 50 forks source link

Android build fails after adding the nativescript-background-http plugin #154

Closed NickIliev closed 6 years ago

NickIliev commented 6 years ago

From @manikjain on May 28, 2018 2:21

Did you verify this is a real problem by searching the [NativeScript Forum]

Yes. (I'm not sure if this issue must be created inside nativescript-background-http repo instead).

Tell us about the problem

I'm running a project with https://github.com/NativeScript/template-drawer-navigation-ng as the template and as soon as I install the nativescript-background-http plugin via tns plugin add nativescript-background-http or npm i nativescript-background-http --save, the android builds starts to fail.

Which platform(s) does your issue occur on?

Android

Please provide the following version numbers that your issue occurs with:

$ tns --version
4.0.1

Please tell us how to recreate the issue in as much detail as possible.

Is there code involved? If so, please share the minimal amount of code needed to recreate the problem.

$ tns plugin add nativescript-background-http
npm WARN extract-text-webpack-plugin@3.0.2 requires a peer of webpack@^3.1.0 but none is installed. You must install peer dependencies yourself.
npm WARN ajv-keywords@3.2.0 requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN schema-utils@0.4.3 requires a peer of webpack@^2.0.0 || ^3.0.0 but none is installed. You must install peer dependencies yourself.

+ nativescript-background-http@3.2.7
added 1 package in 23.004s
Successfully installed plugin nativescript-background-http.
$ tns run android --emulator
Searching for devices...
Executing before-liveSync hook from /Users/manik.jain/Documents/nodejs/NMM-2/hooks/before-liveSync/nativescript-angular-sync.js
Executing before-shouldPrepare hook from /Users/manik.jain/Documents/nodejs/NMM-2/hooks/before-shouldPrepare/nativescript-dev-webpack.js
Executing before-prepare hook from /Users/manik.jain/Documents/nodejs/NMM-2/hooks/before-prepare/nativescript-dev-sass.js
Found peer node-sass
Executing before-prepare hook from /Users/manik.jain/Documents/nodejs/NMM-2/hooks/before-prepare/nativescript-dev-typescript.js
Found peer TypeScript 2.7.2
Preparing project...
Executing before-prepareJSApp hook from /Users/manik.jain/Documents/nodejs/NMM-2/hooks/before-prepareJSApp/nativescript-dev-webpack.js
Successfully prepared plugin nativescript-angular for android.
Successfully prepared plugin nativescript-background-http for android.
Successfully prepared plugin nativescript-imagepicker for android.
Successfully prepared plugin nativescript-theme-core for android.
Successfully prepared plugin nativescript-ui-sidedrawer for android.
Successfully prepared plugin tns-core-modules for android.
Successfully prepared plugin nativescript-intl for android.
Successfully prepared plugin nativescript-permissions for android.
Successfully prepared plugin nativescript-ui-core for android.
Successfully prepared plugin tns-core-modules-widgets for android.
Project successfully prepared (Android)
Executing after-prepare hook from /Users/manik.jain/Documents/nodejs/NMM-2/hooks/after-prepare/nativescript-dev-sass.js
All SASS source files removed from app package
Executing after-prepare hook from /Users/manik.jain/Documents/nodejs/NMM-2/hooks/after-prepare/nativescript-dev-webpack.js
Building project...
Gradle build...
         + applying user-defined configuration from /Users/manik.jain/Documents/nodejs/NMM-2/app/App_Resources/Android/app.gradle
Configuration 'compile' in project ':app' is deprecated. Use 'implementation' instead.
Configuration 'debugCompile' in project ':app' is deprecated. Use 'debugImplementation' instead.
         + adding nativescript runtime package dependency: nativescript-optimized
         + adding aar plugin dependency: /Users/manik.jain/Documents/nodejs/NMM-2/node_modules/nativescript-background-http/platforms/android/nativescript_background_http.aar
         + adding aar plugin dependency: /Users/manik.jain/Documents/nodejs/NMM-2/node_modules/nativescript-imagepicker/platforms/android/nativescript_imagepicker.aar
         + adding aar plugin dependency: /Users/manik.jain/Documents/nodejs/NMM-2/node_modules/nativescript-ui-sidedrawer/platforms/android/TNSSideDrawer-release.aar
         + adding aar plugin dependency: /Users/manik.jain/Documents/nodejs/NMM-2/node_modules/nativescript-ui-core/platforms/android/TNSCore-release.aar
         + adding aar plugin dependency: /Users/manik.jain/Documents/nodejs/NMM-2/node_modules/tns-core-modules-widgets/platforms/android/widgets-release.aar
/Users/manik.jain/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.0.2.aar/6c1b8ac89565868917b47f1df795dca3/res/values-v26/values-v26.xml:9:5-12:13: AAPT: error: resource android:attr/colorError not found.

/Users/manik.jain/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.0.2.aar/6c1b8ac89565868917b47f1df795dca3/res/values-v26/values-v26.xml:13:5-16:13: AAPT: error: resource android:attr/colorError not found.

/Users/manik.jain/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.0.2.aar/6c1b8ac89565868917b47f1df795dca3/res/values-v26/values-v26.xml:17:5-93: AAPT: error: style attribute 'android:attr/keyboardNavigationCluster' not found.

/Users/manik.jain/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.0.2.aar/6c1b8ac89565868917b47f1df795dca3/res/values/values.xml:252:5-69: AAPT: error: resource android:attr/fontStyle not found.

/Users/manik.jain/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.0.2.aar/6c1b8ac89565868917b47f1df795dca3/res/values/values.xml:252:5-69: AAPT: error: resource android:attr/font not found.

/Users/manik.jain/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.0.2.aar/6c1b8ac89565868917b47f1df795dca3/res/values/values.xml:252:5-69: AAPT: error: resource android:attr/fontWeight not found.

/Users/manik.jain/Documents/nodejs/NMM-2/platforms/android/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values-v26/values-v26.xml:7: error: resource android:attr/colorError not found.
/Users/manik.jain/Documents/nodejs/NMM-2/platforms/android/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values-v26/values-v26.xml:11: error: resource android:attr/colorError not found.
/Users/manik.jain/Documents/nodejs/NMM-2/platforms/android/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values-v26/values-v26.xml:15: error: style attribute 'android:attr/keyboardNavigationCluster' not found.
/Users/manik.jain/Documents/nodejs/NMM-2/platforms/android/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:326: error: resource android:attr/fontStyle not found.
/Users/manik.jain/Documents/nodejs/NMM-2/platforms/android/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:326: error: resource android:attr/font not found.
/Users/manik.jain/Documents/nodejs/NMM-2/platforms/android/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:326: error: resource android:attr/fontWeight 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.GeneratedMethodAccessor193.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        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:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
        at java.lang.Thread.run(Thread.java:748)
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 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        ... 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:463)
        at com.android.builder.png.AaptProcess$NotifierProcessOutput.err(AaptProcess.java:415)
        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:processDebugResources'.
> 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 11s
Unable to apply changes on device: 192.168.57.101:5555. Error is: Command ./gradlew failed with exit code 1.
Executing after-watch hook from /Users/manik.jain/Documents/nodejs/NMM-2/hooks/after-watch/nativescript-dev-sass.js
Executing after-watch hook from /Users/manik.jain/Documents/nodejs/NMM-2/hooks/after-watch/nativescript-dev-typescript.js
Executing after-watch hook from /Users/manik.jain/Documents/nodejs/NMM-2/hooks/after-watch/nativescript-dev-webpack.js

Copied from original issue: NativeScript/NativeScript#5872

NickIliev commented 6 years ago

@manikjain I've used this test project but the issue is not reproducible on my side. Try updating your NatriveScript to latest version (4.0.2)

manikjain-zz commented 6 years ago

@NickIliev I'm running a genymotion custom android phone as an emulator for this - Custom Phone 7.1.0 - API 25. Could you confirm if you tested on a similar API version?

I tried the following after updating NS to 4.0.2, but it still failed with the same build errors:

I also cloned https://github.com/NickIliev/NS-Issues-2018-II where you created a similar project and that's failing as well.

Also tried building the project on an actual android device and it failed with the same error after I install nativescript-background-http.

@NickIliev I've cloned my project here: https://github.com/manikjain/issues/tree/master/NativeScript/nativescript-background-http/issue_154

Could you please try running the above on your end and let me know if it fails?

manikjain-zz commented 6 years ago

Thanks to @fthuin, the issue got resolved once I installed additional SDK tools from Android Studio's SDK manager. I also did ./gradlew cleanBuildCache to clean the cache prior to rebuilding and running the project. :)

/Users/manik.jain/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.0.2.aar/6c1b8ac89565868917b47f1df795dca3/res/values-v26/values-v26.xml:9:5-12:13: AAPT: error: resource android:attr/colorError not found. suggested that it probably wasn't able to find some associated packages for API ver. 27.0.2.

mhsattarian commented 6 years ago

@manikjain thanks for sharing this, can you mention which additional SDK tools you installed?

rohanrichards commented 6 years ago

EDIT: I fixed this by doing the following: https://github.com/NativeScript/nativescript-background-http/issues/169#issuecomment-416468258

I think this should be opened again, there is currently no solution provided. I have this bug now, and have tried to find "additional SDK tools" in the studio SDK manager with no luck. Project is failing to build as per the original issue.

For reference, I've installed SDK 25,26,27. SDK Tools: Android SDK Build-Tools, Android SDK Platform-Tools, Android SDK Tools.

I have rebuilt my project (complete node_module reinstall, platform add/remove) and I have tried running ./gradew CleanBuildCache

I really need this plugin for my project so it would be fantastic to get some help here.

fthuin commented 6 years ago

@rohanrichards In Android Studio, go in the preferences/settings, Appearance & Behavior > System Settings > Android SDK. Go in SDK Tools tab, click on the checkbox "Show Package Details" (bottom right of the modal), then go in the dropdown for Android SDK Build-Tools and select the missing version.

You'll see all available versions, not only the default proposed by Android Studio.

How to know the missing version ?

In the error path previously mentioned

/Users/manik.jain/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.0.2.aar/6c1b8ac89565868917b47f1df795dca3/res/values-v26/values-v26.xml:9:5-12:13: AAPT: error: resource android:attr/colorError not found.

You can clearly find 27.0.2 is missing. It might be different for you