Android gradle disable removing resources without default value

Viewed 4678

Since upgrading to Android Gradle Plugin 3.2, resources without required default values are removed. Causing the build to fail.

Execution failed for task ':app:processDebugResources'.
> Android resource linking failed
  warn: removing resource my.package.name:string/my_string_resource without required default value.
  /path/to/layout.xml: AAPT: error: resource string/my_string_resource (aka my.package.name:string/my_string_resource) not found

Can this be disabled? I'm currently using the latest Android Gradle Plugin: 3.4.0

We need that because our customer's translation process requires us to deliver test-builds of the app in another language than the default language. Default values have to be omitted so that translators can easily see what still needs to be translated.

3 Answers

I'm not sure whether this will resolve your problem. But for me, after upgrading the Android Studio from 3.2 to 3.3, I got several warnings saying that

Android resource linking failed
Output:  warn: removing resource com.myproject:string/menu_item_copy 
without required default value.

For this I've changed the

compileSdkVersion 28

on app level build.gradle. After updating compiledSdkVersion those warning errors got disappeared. Try this if this works for you.

I dont know the reason for this error but in my case was because I had this wrong xml value in one of my layouts

android:foreground="null"

Exist the posibility that you had a wrong xml value

I faced with similar problem few weeks ago after we've bump our build tools version to 28.0.3. And we also have some limitations which don't allow put strings in default values folder.

So, after week of struggling with this problem and googling, I wrote the gradle script for generating missing resources. This script generates only strings, styles, integers etc (everything from "values" folders). Feel free to open PR for generating other resource types :)

https://github.com/gerra/MissingResources

Everything you need is in missing_res_generator.gradle file.

Related