2016-11-24 122 views
0

我正在嘗試使用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)  

以下是我已經嘗試過的事情:

  1. 清理並生成項目
  2. gradlew乾淨
  3. 通過不同的方法
  4. 添加庫

我看到相同的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') 
} 
+0

[Android的Java庫中的代碼的NoClassDefFoundError可能重複](http://stackoverflow.com/questions/8678630/noclassdeffounderror-for-code-in-an-java-library-on-android) – sushildlh

+0

I對android工作室有類似的方法,但它沒有工作。 – user3125971

回答

0

看來你使用的是一些混淆,它重命名爲其他字符,這給錯誤?

+0

我不認爲我使用任何「混淆器」。我第一次聽說這個詞。 – user3125971

+0

obfuscator用於縮小android例子proguard中的代碼/資源,你能確認BoilerpipeHTMLParser是否在正確的pakage中? – SaravInfern

+0

是BoilerpipeHTMLParser在包中。 – user3125971

相關問題