localization - Android string resources not working with $


Keywords:android 


Question: 

After upgrading to android studio 3.0.1 the string resources with $ in their name like: <string name="$KEY$">value</string>

throw an error

Error:(615, 3) error: resource 'string/$KEY$' has invalid entry name '$KEY$'. Invalid character '$KEY$'.

trace is:

AGPBI: {"kind":"error","text":"error: resource \u0027string/$KEY$\u0027 has invalid entry name \u0027$KEY$\u0027. Invalid character \u0027$KEY$\u0027.","sources":[{"file":"../src/main/res/values-es/strings.xml","position":{"startLine":559,"startColumn":2,"startOffset":60748,"endColumn":54,"endOffset":60800}}],"original":"","tool":"AAPT"}


1 Answer: 

Aapt2 is enabled by default when you use android plugin for gradle 3.0. You can fix your issue by setting android.enableAapt2=false in your gradle.properties