Android studio gradle build编译错误

时间:2016-05-11 13:38:03

标签: android android-studio android-gradle

我是Android上的新手,我在Android Studio中遇到了一些问题,但我在网上找不到任何解决方案。 如果你帮助我将不胜感激。 我可以在下面找到哪些行创建错误吗?

由于

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控制台:

: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

更新: app文件夹中的build.gradle文件

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')
}

1 个答案:

答案 0 :(得分:2)

  

看起来与BOM(Byte Order Mark

相关的问题

方法1

使用高级文本编辑器(例如Notepad ++)并将编码设置为&#34; UTF,不带BOM&#34;,用于您的文件。 您可以在Enconding > Encode in UTF-8 without BOM

下的Notepad ++中找到此选项

enter image description here

方法2

使用Android Studio。将文件编码选项更改为UTF-16并返回UTF-8。然后应该出现一个弹出窗口,选择Convert选项。

enter image description here