16

I got this error while trying to build an Android app:

> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > AAPT2 aapt2-4.1.0-6503028-windows Daemon #0: Unexpected error during link, attempting to stop daemon.
     This should not happen under normal circumstances, please file an issue if it does.

Most other solutions I found were related to an image in the project being too large however, that didn't work for me as all my images had sizes below 50kb.

Schnelldev
  • 823
  • 1
  • 6
  • 15

3 Answers3

61

I found that this error occurs when additional modules are created in the project and linked to other app modules (using implementation project) but the plugin in the module's build.gradle file is set to 'com.android.application' instead of 'com.android.library'.

I found this solution in an answer to a different issue here.

Schnelldev
  • 823
  • 1
  • 6
  • 15
  • I have submitted a bug report for this https://issuetracker.google.com/issues/188096932 – dewijones92 May 15 '21 at 16:42
  • 1
    Glad it helped! – Schnelldev May 18 '21 at 16:02
  • But that makes it a library not a module, right? From what I understand here: https://developer.android.com/studio/projects this makes a difference. – Tobias Reich Jul 21 '21 at 08:34
  • According to that article, it's still a module, just now a _library_ module. However, considering that you can't really use code from an Android app module in another app module without running into the above error, I think it's right for it to be a library module. – Schnelldev Aug 04 '21 at 15:03
1

This started happening to me with Gradle 6.3 when I tried to upgrade compileSdkVersion from 33 to 34.

I don't want to upgrade Gradle at this stage. So:

  1. Am I now stuck with compileSdkVersion 33 until I upgrade Gradle?
  2. Which problems should I expect if I targetSdkVersion 34 while compiling with 33?

(in my case it's a case of using com.android.library)

grebulon
  • 7,697
  • 5
  • 42
  • 66
0

The answer from user "Schnelldev" can be shortened: for the application, the plugin 'com.android.application' should be used, and for each individual module 'com.android.library'