I have a problem with libraries with Android Studio. I added the .jar file to the libs folder in my project and clicked on RMB to add it as libary. In build.gradle, I added this with dependencies:
compile files('libs/epublib-core-latest.jar')
This works, but when I start the application, I get this error:
Could not find class 'nl.siegmann.epublib.epub.EpubReader', referenced from method com.MJV.Reader.MainActivity.onCreate
And this is the code that can call it:
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();
}
} ...
I think libary is not turned on when the application is sent to my phone, but I could be wrong. Any help would be appreciated!
Edit: file build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
} apply the plugin: 'android'
repositories {
mavenCentral()
}
android {compileSdkVersion 17 buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
}
dependencies {
compile files('libs/epublib-core-latest.jar')
}
source
share