I am really newbie on Android and I am facing some problems in Android Studio but I could not find any solution on the net. If you help I will be appreciated. Can I find which lines create errors below?
Thanks
Gradle Build:
Error:(7, 11) error: unmappable character for encoding UTF-8
Error:(7, 12) error: unmappable character for encoding UTF-8
Error:(1, 1) error: class, interface, or enum expected
Error:(1, 2) error: class, interface, or enum expected
Error:(1, 3) error: class, interface, or enum expected
Error:(7, 11) error: illegal character: '\ufffd'
Error:(7, 12) error: illegal character: '\ufffd'
Gradle Console:
:app:compileDebugJavaWithJavac
D:\Projects\ABCApp_v3\app\build\generated\source\buildConfig\debug\com\company\abcapp\BuildConfig.java:7: error: unmappable character for encoding UTF-8
��R
D:\Projects\ABCApp_v3\app\build\generated\source\buildConfig\debug\com\company\abcapp\BuildConfig.java:7: error: unmappable character for encoding UTF-8
��R
D:\Projects\ABCApp_v3\app\build\generated\source\buildConfig\debug\com\company\abcapp\BuildConfig.java:1: error: class, interface, or enum expected
<?xml version="1.0" encoding="utf-8"?>
D:\Projects\ABCApp_v3\app\build\generated\source\buildConfig\debug\com\company\abcapp\BuildConfig.java:1: error: class, interface, or enum expected
<?xml version="1.0" encoding="utf-8"?>
D:\Projects\ABCApp_v3\app\build\generated\source\buildConfig\debug\com\company\abcapp\BuildConfig.java:1: error: class, interface, or enum expected
<?xml version="1.0" encoding="utf-8"?>
D:\Projects\ABCApp_v3\app\build\generated\source\buildConfig\debug\com\company\abcapp\BuildConfig.java:7: error: illegal character: '\ufffd'
??R
D:\Projects\ABCApp_v3\app\build\generated\source\buildConfig\debug\com\company\abcapp\BuildConfig.java:7: error: illegal character: '\ufffd'
??R
5 errors
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Update: build.gradle file in app folder
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
compileOptions.encoding = "utf-8"
defaultConfig {
applicationId "com.company.abcapp"
minSdkVersion 14
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
debuggable true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile files('libs/ksoap2-android-assembly-2.5.5-jar-with-dependencies.jar')
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.google.guava:guava:18.0'
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.android.support:support-v4:22.1.1'
compile files('libs/ksoap2-android-assembly-3.4.0-jar-with-dependencies.jar')
}
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
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.