'Error showing while I did nothing : Execution failed for task ':app:mergeDebugResources'. ; Caused by: java.lang.NullPointerException

I'm currently creating an application with Android Studio and Kotlin.

This morning, when I tried to run the app on the emulator and my phone, I got an error but what I don't understand it's I barely change the code : I just added a textview (tried to delete it but I still got the error. I tried to investigate and do think but none of them worked. I still don't really understand the error, could you help me fix it ?

Here the error :

Caused by: org.gradle.workers.internal.DefaultWorkerExecutor$WorkExecutionException: A failure occurred while executing com.android.build.gradle.internal.res.ResourceCompilerRunnable
Caused by: com.android.aaptcompiler.ResourceCompilationException: Resource compilation failed. Check logs for details.
    at com.android.aaptcompiler.ResourceCompiler.compileResource(ResourceCompiler.kt:126)
    at com.android.build.gradle.internal.res.ResourceCompilerRunnable$Companion.compileSingleResource(ResourceCompilerRunnable.kt:34)
    at com.android.build.gradle.internal.res.ResourceCompilerRunnable.run(ResourceCompilerRunnable.kt:15)
    at com.android.build.gradle.internal.profile.ProfileAwareWorkAction.execute(ProfileAwareWorkAction.kt:74)
... 3 more
Caused by: java.lang.NullPointerException
    at com.android.aaptcompiler.TableExtractor.flattenXmlSubTree(TableExtractor.kt:851)
    at com.android.aaptcompiler.TableExtractor.parseXml(TableExtractor.kt:516)
    at com.android.aaptcompiler.TableExtractor.parseArrayImpl(TableExtractor.kt:1300)
    at com.android.aaptcompiler.TableExtractor.parseStringArray(TableExtractor.kt:1243)
    at com.android.aaptcompiler.TableExtractor.access$parseStringArray(TableExtractor.kt:146)
    at com.android.aaptcompiler.TableExtractor$extractResource$parseBagMethod$13.invoke(TableExtractor.kt:437)
    at com.android.aaptcompiler.TableExtractor$extractResource$parseBagMethod$13.invoke(TableExtractor.kt:437)
    at com.android.aaptcompiler.TableExtractor.extractResource(TableExtractor.kt:458)
    at com.android.aaptcompiler.TableExtractor.extractResourceValues(TableExtractor.kt:267)
    at com.android.aaptcompiler.TableExtractor.extract(TableExtractor.kt:182)
    at com.android.aaptcompiler.ResourceCompiler.compileTable(ResourceCompiler.kt:186)
    at com.android.aaptcompiler.ResourceCompiler.access$compileTable(ResourceCompiler.kt:1)
    at com.android.aaptcompiler.ResourceCompiler$getCompileMethod$1.invoke(ResourceCompiler.kt:137)
    at com.android.aaptcompiler.ResourceCompiler$getCompileMethod$1.invoke(ResourceCompiler.kt:137)
    at com.android.aaptcompiler.ResourceCompiler.compileResource(ResourceCompiler.kt:123)
    ... 29 more


Thanks a lot

EDIT :

So, I've searched a lot, tried many things but none of them worked. Because my project is still small, I created a new project and copy/paste all my code and I this new project everything work and I don't have any error anymore.

Good luck if you encounter the same error.



Solution 1:[1]

Just had this error myself and after awhile managed to find the issue, I had strings within array-lists located in my strings.xml, some of my strings included apostrophes, for instance in don't won't can't.

Removing these allowed me to build my project again.

Solution 2:[2]

The solution that worked for me is locate the String.xml file. Delete the unused Strings I meant the strings that didnt had any reference in arrayList file.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Matt
Solution 2 AbirZayn