Android Studio:添加样板库后生成错误

Android Studio: Build error after adding boilerpipe library

我正在尝试使用 [boilerpipe][1] 来解析文本。我将 boilerpipe-1.2.0.jarnekohtml-1.9.13.jarxerces-2.9.1.jar 复制到 lib 文件夹并将它们添加为库。但是当我尝试 运行 项目时,我得到了一个巨大的错误。这是它的结尾部分-

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Return code 1 for dex process

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

这是我的应用程序 build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.0"
    defaultConfig {
        applicationId "com.example.pushpankar.reader"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner  "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
    compile 'com.android.support:appcompat-v7:25.0.0'
    compile 'com.android.support:support-v4:25.0.0'
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:multidex:1.0.1'
    compile files('libs/boilerpipe-1.2.0/lib/xerces-2.9.1.jar')
    compile files('libs/boilerpipe-1.2.0/lib/nekohtml-1.9.13.jar')
    compile files('libs/boilerpipe-1.2.0/boilerpipe-1.2.0.jar')
}

这是带有 --debug 选项的输出

Caused by: com.android.dx.cf.iface.ParseException: bad utf-8 byte a0 at offset 00000004\n\tat com.android.dx.cf.cst.ConstantPoolParser.parseUtf8(ConstantPoolParser.java:374)\n\tat com.android.dx.cf.cst.ConstantPoolParser.parse0(ConstantPoolParser.java:262)\n\tat com.android.dx.cf.cst.ConstantPoolParser.parse0(ConstantPoolParser.java:294)\n\tat com.android.dx.cf.cst.ConstantPoolParser.parse(ConstantPoolParser.java:150)\n\tat com.android.dx.cf.cst.ConstantPoolParser.parseIfNecessary(ConstantPoolParser.java:124)\n\tat com.android.dx.cf.cst.ConstantPoolParser.getPool(ConstantPoolParser.java:115)\n\tat com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:482)\n\tat com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)\n\tat com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)\n\tat com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)\n\tat com.android.dx.command.dexer.Main.parseClass(Main.java:787)\n\tat com.android.dx.command.dexer.Main.access00(Main.java:88)\n\tat com.android.dx.command.dexer.Main$ClassParserTask.call(Main.java:1722)\n\tat com.android.dx.command.dexer.Main.processClass(Main.java:773)\n\t... 16 more\nCaused by: java.lang.IllegalArgumentException: bad utf-8 byte a0 at offset 00000004\n\tat com.android.dx.rop.cst.CstString.throwBadUtf8(CstString.java:172)\n\tat com.android.dx.rop.cst.CstString.utf8BytesToString(CstString.java:143)\n\tat com.android.dx.rop.cst.CstString.\u003cinit\u003e(CstString.java:200)\n\tat com.android.dx.cf.cst.ConstantPoolParser.parseUtf8(ConstantPoolParser.java:371)\n\t... 29 more\n","tool":"Dex"}
    13:53:36.360 [ERROR] [org.gradle.api.Project] AGPBI: {"kind":"error","text":"1 error; aborting","sources":[{}]}
    13:53:36.374 [ERROR] [org.gradle.BuildExceptionReporter] 
    13:53:36.374 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
    13:53:36.374 [ERROR] [org.gradle.BuildExceptionReporter] 
    13:53:36.374 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
    13:53:36.374 [ERROR] [org.gradle.BuildExceptionReporter] Execution failed for task ':app:transformClassesWithDexForDebug'.
    13:53:36.374 [ERROR] [org.gradle.BuildExceptionReporter] > com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Return code 1 for dex process
    13:53:36.374 [ERROR] [org.gradle.BuildExceptionReporter] 
    13:53:36.374 [ERROR] [org.gradle.BuildExceptionReporter] * Try:
    13:53:36.374 [ERROR] [org.gradle.BuildExceptionReporter] Run with --stacktrace option to get the stack trace.

您使用的 JDK 版本是什么?

您必须使用相同的 Java 版本或高于用于编译外部 jar(锅炉管道)的版本。

更新:

从您发布的错误日志来看,错误似乎是:

java.lang.IllegalArgumentException: bad utf-8 byte

并且这个错误已经在锅炉项目的 github 问题跟踪中被填补:https://github.com/matanster/boilerpipe/issues/74