I'm trying to integrate the PDFNet library into my Android App, and if you download the SDK you can see that there is a project CompleteReader (PDFNetAndroid-6.7.0.42960\PDFNetAndroid\samples\PDFViewCtrlProjects\CompleteReader) I want to use this project as a module in my app so I changed in build.gradle "com.android.application" to "com.android.library"
Here the original build.gradle:
description = 'This is a more complete demo app that showcases PDFViewCtrl and the Tools library and its controls.'
apply plugin: 'com.android.application'
repositories {
mavenCentral()
}
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.trello:victor:0.1.4'
}
}
apply plugin: 'com.android.application'
apply plugin: 'com.trello.victor'
dependencies {
compile fileTree(include: '*.jar', dir: 'libs')
compile project(':PDFViewCtrlTools')
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.tonicartos:superslim:0.4.13'
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0.0"
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
res.srcDirs = ['res']
jniLibs.srcDirs = ['libs']
svg.srcDir 'src/main/svg'
}
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
}
debug {
// Set package name to <app package>.debug to be able to install both debug and release apk on the same device
applicationIdSuffix ".debug"
}
}
lintOptions {
// If true, stop the gradle build if errors are found
abortOnError false
//ignore 'ValidFragment'
}
productFlavors {
armv7a {
ndk {
abiFilters "armeabi-v7a"
}
}
arm {
ndk {
abiFilters "armeabi"
}
}
x86 {
ndk {
abiFilters "x86"
}
}
armv8 {
ndk {
abiFilters "arm64-v8a"
}
}
x86_64 {
ndk {
abiFilters "x86_64"
}
}
fat {
ndk {
abiFilters "armeabi-v7a", "armeabi", "arm64-v8a", "x86", "x86_64"
}
}
}
}
task copyLibsToSamples << {
['libs'
].each { dest ->
copy {
from ('../../../lib/full') {
include '**/*.so'
}
into dest
}
}
}
task copyJarToSamples(type: Copy) {
['../../../lib/src/PDFViewCtrlTools/libs'
].each { dest ->
copy {
from ('../../../lib') {
include 'PDFNet.jar'
}
into dest
}
}
}
task copyResources << {
['res/raw'].each { dest ->
copy {
from ('../../../resource') {
include '*.plugin'
}
into dest
}
}
}
task setupSample(dependsOn: [copyLibsToSamples, copyJarToSamples, copyResources])
preBuild.dependsOn setupSample
This original file compiles without problem, but with the change to library it won't build, so I removed following that I read somewhere could be the problem:
repositories {
mavenCentral()
}
Ok, with this change it seems that the build can continue, the next errors I got was with following two references that could not be resolved (this all works when the original file is not modified!!!):
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.tonicartos:superslim:0.4.13'
I tried so many things in this file already a few days without luck, I removed all parts that could not be needed, moved jcenter and mavencentral around, added them, removed them, etc. This is my current build.gradle that also does not work:
description = 'This is a more complete demo app that showcases PDFViewCtrl and the Tools library and its controls.'
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.trello:victor:0.1.4'
}
}
apply plugin: 'com.android.library'
apply plugin: 'com.trello.victor'
dependencies {
repositories {
mavenCentral()
jcenter()
}
compile fileTree(include: '*.jar', dir: 'libs')
compile project(':PDFViewCtrlTools')
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile project(':superslim-0.4.13')
compile 'com.jakewharton:butterknife:7.0.1'
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
res.srcDirs = ['res']
jniLibs.srcDirs = ['libs']
svg.srcDir 'src/main/svg'
}
}
lintOptions {
// If true, stop the gradle build if errors are found
abortOnError false
//ignore 'ValidFragment'
}
}
task wrapper(type: Wrapper) {
gradleVersion = '2.2'
}
It does not matter what I change, the module can't be compiled, I get Execution failed for task CompleteReader:compileDebugJavaWithJavac and R is not being generated so I get a lot of "constant expression required". I repeat, before changing "application" to "library" all work fine, I can install the project on my phone, etc.
Do you have any ideas what's wrong? I am already working 3 days on this without luck!