Android Studio : unmappable character for encoding UTF-8
I had the same problem because there was files with windows-1251 encoding and Cyrillic comments. In Android Studio which is based on IntelliJ IDEA you can solve it in two ways:
a) convert file encoding to UTF-8 or
b) set the right file encoding in your build.gradle script:
android {
...
compileOptions.encoding = 'windows-1251' // write your encoding here
...
To convert file encoding use the menu at the bottom right corner of IDE. Select right file encoding first -> press Reload -> select UTF-8 -> press Convert.
Also read this Use the UTF-8, Luke! File Encodings in IntelliJ IDEA
Android Studio - Unmappable character for encoding UTF-8
Adding the following to build.gradle
solves the problem :
android {
...
compileOptions.encoding = 'ISO-8859-1'
How to fix Unmappable character for encoding windows-1252 error displayed by Gradle build?
You probably have a config for encoding in the android compileOptions in your build.gradle
Look for encoding = 'Cp1252' and remove it.
android
{
compileOptions {
encoding = 'Cp1252'
}
}
Android studio gradle build compile error
Looks like a problem related to BOM (Byte Order Mark)
Method 1
Use an advanced text-editor (for example Notepad++) and set the encoding to "UTF without BOM", for your files.
You can find this option in Notepad++ under Enconding > Encode in UTF-8 without BOM
Method 2
Use Android Studio. Changed file Encoding option to UTF-16 and back to UTF-8. Then there should a popup appear, choose the option Convert
.
Thai script seems to lose UTF-8 encoding in java for-each loop
As several in the comments pointed out the problem had to be within my environment. After a bit more searching I found I should have rebuilt the project after changing the encodings (so merely switching to UTF8 and clicking 'Apply'/'OK' wasn't enough). I should note here that my File Encoding settings look like this, for reference:
Once I rebuilt, I started getting the compiler error "unmappable character for encoding cp1252" on the String array containing the Thai (side note: Some of the Thai characters were fine, others rendered as � and friends. I would have thought either all of the Thai would work or none of it, but was surprised to see even common Thai letters such as ก cause the compiler to choke).
That error led to this post in which I tried a few things to set the compiler options to UTF8. Since my application happens to be a sort of 'pre-process' for an android app, and is therefore separate from the app itself (if that makes any sense), I didn't have the luxury of using the compilerOptions attribute as the answers in the aforementioned SO post recommended (though I have since added it to the gradle on the android app side). This led me to setting the environment variable JAVA_TOOLS_OPTIONS via powershell:
setx JAVA_TOOLS_OPTIONS "-Dfile.encoding=UTF8"
Which fixed the issue!
Related Topics
Firebase Auth Using Phone Number and Password
How to Send File Using Bluetooth on Android Programatically
Android How to Create Runtime Thumbnail
Using Disklrucache in Android 4.0 Does Not Provide for Opencache Method
Android View Not Attached to Window Manager
How to Send JSON Object to Server Using Volley in Android
How to Get the Fragment Instance from the Fragmentactivity
Android Path to Asset Txt File
Android: Determine Active Input Method from Code
Not Able Disable Home Button on Specific Android Devices
Adb Server Is Out of Date. Killing
Starting Frame-By-Frame Animation
Recyclerview Gridlayoutmanager: How to Auto-Detect Span Count
How to Set Text Size of Textview Dynamically for Different Screens
Cannot Resolve Method Setlatesteventinfo
Findclass from Any Thread in Android Jni