我正在嘗試使用boilerpipe來獲取文本文章,如口袋應用程序。應用程序編譯正確,但給運行時異常:Android Studio:來自boilerpipe的java.lang.NoClassDefFoundError
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:309)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.NoClassDefFoundError: de.l3s.boilerpipe.sax.BoilerpipeHTMLParser
at de.l3s.boilerpipe.sax.BoilerpipeSAXInput.getTextDocument(BoilerpipeSAXInput.java:51)
at de.l3s.boilerpipe.extractors.ExtractorBase.getText(ExtractorBase.java:69)
at de.l3s.boilerpipe.extractors.ExtractorBase.getText(ExtractorBase.java:87)
at com.example.pushpankar.fastreader.ReadView$fetchUrlTxt.doInBackground(ReadView.java:154)
at com.example.pushpankar.fastreader.ReadView$fetchUrlTxt.doInBackground(ReadView.java:147)
at android.os.AsyncTask$2.call(AsyncTask.java:295)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
以下是我已經嘗試過的事情:
- 清理並生成項目
- gradlew乾淨
- 通過不同的方法 添加庫
我看到相同的bug已發佈在github上。
這裏是我的build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.example.pushpankar.fastreader"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
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 project(':boilerpipe-1.2.0-android')
compile project(':xerces-for-android')
compile project(':nekohtml')
compile 'com.android.support:appcompat-v7:25.0.1'
compile 'com.android.support:support-v4:25.0.1'
testCompile 'junit:junit:4.12'
compile files('libs/slf4j-android-1.6.1-RC1.jar')
}
[Android的Java庫中的代碼的NoClassDefFoundError可能重複](http://stackoverflow.com/questions/8678630/noclassdeffounderror-for-code-in-an-java-library-on-android) – sushildlh
I對android工作室有類似的方法,但它沒有工作。 – user3125971