I Clone a project using Android studio 2.2.2 on windows, when I run the project there is an error
illegal escape character on the BuildConfing.java file
The original development might be used IntelliJ IDEA on linux ubutu. I did clean the project and rebuild it, no changes.
The error is on the following line
public static final String[] TRANSLATION_ARRAY = new String[] {"G:\Developer\AndroidStudioProjects\gpslogger\gpslogger\src\main\res\values","G:\Developer.......,....,....};
BuildConfig.java is an Auto generated file and should not be edited.
Why is this happen? how BuildConfig.java is generated ?
UPDATE
@Vijai, Thanks a lot. the problem is on the build.gradle file. following task returns a string with illegal escape character.
task buildTranslationArray << {
def foundLocales = new StringBuilder()
foundLocales.append("new String[]{")
fileTree("src/main/res").visit { FileVisitDetails details ->
if(details.file.path.endsWith("strings.xml")){
def languageCode = details.file.parent.tokenize('/').last().replaceAll('values-','').replaceAll('-r','-')
languageCode = (languageCode == "values") ? "en" : languageCode;
foundLocales.append("\"").append(languageCode).append("\"").append(",")
}
}
foundLocales.append("}")
//Don't forget to remove the trailing comma
def foundLocalesString = foundLocales.toString().replaceAll(',}','}')
android.defaultConfig.buildConfigField "String[]", "TRANSLATION_ARRAY", foundLocalesString
}
preBuild.dependsOn buildTranslationArray
How can I fix this issue?