Android Studio のライブラリに問題があります。プロジェクトの libs フォルダーに .jar を追加し、RMB をクリックしてライブラリとして追加しました。build.gradle で、これを依存関係とともに追加しました。
compile files('libs/epublib-core-latest.jar')
これは機能していますが、アプリケーションを実行しているときに次のエラーが発生します。
Could not find class 'nl.siegmann.epublib.epub.EpubReader', referenced from method com.MJV.Reader.MainActivity.onCreate
そして、これはそれを引き起こしている可能性のあるコードです:
import nl.siegmann.epublib.domain.Book;
import nl.siegmann.epublib.epub.EpubReader;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
System.out.println("hoi");
AssetManager assetManager = getAssets();
try {
InputStream epubInputStream = assetManager
.open("books/testbook.epub");
Book book = (new EpubReader()).readEpub(epubInputStream);
System.out.println("Hier komt het...");
System.out.println(book.getTitle());
} catch (IOException e) {
e.printStackTrace();
}
} ...
アプリケーションが携帯電話に送信されたときにライブラリが含まれていないと思いますが、間違っている可能性があります。どんな助けでも大歓迎です!
編集: build.gradle ファイル:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
プラグインを適用: 'android'
repositories {
mavenCentral()
}
Android { compileSdkVersion 17 buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
}
dependencies {
// You must install or update the Support Repository through the SDK manager to use this dependency.
// The Support Repository (separate from the corresponding library) can be found in the Extras category.
// compile 'com.android.support:appcompat-v7:18.0.0'
compile files('libs/epublib-core-latest.jar')
}