diff --git a/SDKLauncher-Android/app/build.gradle b/SDKLauncher-Android/app/build.gradle index 076e2b23..3ef81dec 100644 --- a/SDKLauncher-Android/app/build.gradle +++ b/SDKLauncher-Android/app/build.gradle @@ -1,21 +1,26 @@ def ndk_experimental = (rootProject.hasProperty("readium_ndk_experimental") && rootProject.readium_ndk_experimental) +println "[[${project.name}]] (APP) Gradle Experimental: ${ndk_experimental}" + if (ndk_experimental) { - println "${project.name}: Using Gradle EXPERIMENTAL to build application" apply from: 'build_experimental.gradle' } else { - println "${project.name}: Using Gradle STABLE to build application" apply from: 'build_stable.gradle' } - repositories { + if (!ndk_experimental) { + google() + } + maven { + url "https://maven.google.com" + } mavenCentral() jcenter() + maven { url 'https://maven.fabric.io/public' } flatDir { dirs '../libs' } - maven { url 'https://maven.fabric.io/public' } } dependencies { @@ -56,18 +61,22 @@ buildAssets.dependsOn "buildCssAssets", apply from: 'build_epubReadingSystem.gradle' tasks.whenTaskAdded { task -> - def taskName = task.name + println "[[${project.name}]] (APP) TaskAdded: ${task.name}" + + if (task.name.startsWith("compile")) { + def isDebug = task.name.toLowerCase().contains("debug") - if (taskName.startsWith("compile")) { if (ndk_experimental) { task.dependsOn "buildAssets", - ":lcp:build", - "buildEpubReadingSystem" + isDebug ? ":lcp:assembleDebug" : ":lcp:assembleRelease", + "buildEpubReadingSystem" } else { - println("Task: ${taskName}") task.dependsOn "buildAssets", - ":epub3:buildMk", - "buildEpubReadingSystem" + isDebug ? ":lcp:assembleDebug" : ":lcp:assembleRelease", + "buildEpubReadingSystem" } } -} \ No newline at end of file +} +gradle.buildFinished { buildResult -> + println "[[${project.name}]] (APP) buildFinished" +} diff --git a/SDKLauncher-Android/app/build_experimental.gradle b/SDKLauncher-Android/app/build_experimental.gradle index a3edd4fb..d2c19491 100644 --- a/SDKLauncher-Android/app/build_experimental.gradle +++ b/SDKLauncher-Android/app/build_experimental.gradle @@ -11,7 +11,11 @@ def store_password = (rootProject.hasProperty("readium_sign_store_password") ? def lcpDir = project(':lcp').projectDir def epub3Dir = project(':epub3').projectDir +def rsdkDir = project(':rsdk').projectDir +def _buildTypes = [] +def _productFlavors = [] +def currentBuildType model { android.lintOptions { checkReleaseBuilds = false @@ -35,8 +39,8 @@ model { } android { - compileSdkVersion = 26 - buildToolsVersion = "27.0.3" + compileSdkVersion = 28 + buildToolsVersion = "28.0.3" defaultConfig { @@ -47,7 +51,7 @@ model { minSdkVersion.apiLevel = 19 // manifest/uses-sdk@android:targetSdkVersion attribute in src/main/AndroidManifest.xml - targetSdkVersion.apiLevel = 26 + targetSdkVersion.apiLevel = 28 // manifest@android:versionCode attribute in src/main/AndroidManifest.xml versionCode 31 @@ -101,19 +105,105 @@ model { } //buildTypes productFlavors { - if (!ndk_skipARM) - create("arm") { + if (!ndk_skipARM && !ndk_skipX86) { + create('armeabi-v7a--arm64-v8a--x86--x86_64') { ndk.with { - abiFilters.add("armeabi-v7a") + abiFilters.add('armeabi-v7a') + abiFilters.add('arm64-v8a') + abiFilters.add('x86') + abiFilters.add('x86_64') } } - - if (!ndk_skipX86) - create("x86") { - ndk.with { - abiFilters.add("x86") + } else { + if (!ndk_skipARM) { + create('armeabi-v7a--arm64-v8a') { + ndk.with { + abiFilters.add('armeabi-v7a') + abiFilters.add('arm64-v8a') + } + } + } + if (!ndk_skipX86) { + create('x86--x86_64') { + ndk.with { + abiFilters.add('x86') + abiFilters.add('x86_64') + } } } + } } //productFlavors } //android -} //model \ No newline at end of file + + components.android { + binaries.afterEach { binary -> + println "[[${project.name}]] (APP) components.android.binaries buildType: ${binary.getBuildType().name}" + if (!_buildTypes.contains(binary.getBuildType().name)) { + println "[[${project.name}]] (APP) components.android.binaries buildType ADDED" + _buildTypes += binary.getBuildType().name + } + + binary.getProductFlavors().each { flavor -> + println " [[${project.name}]] (APP) components.android.binaries productFlavor: ${flavor.name}" + if (!_productFlavors.contains(flavor)) { + println " [[${project.name}]] (APP) components.android.binaries productFlavor ADDED" + _productFlavors += flavor + } + + flavor.ndk.abiFilters.each { abiFilter -> + println " [[${project.name}]] (APP) components.android.binaries abiFilter (${abiFilter})" + } + } + // binary.mergedNdkConfig.cppFlags.add("-DVARIANT=\"" + binary.name + "\"") + } + } +} //model + +gradle.taskGraph.whenReady { taskGraph -> + println "[[${project.name}]] (APP) taskGraph ready" + + // taskGraph.getAllTasks().last().finalizedBy("copyLibs") + // taskGraph.getAllTasks().last().doLast "copyLibs" + taskGraph.getAllTasks().last().doLast { + println "[[${project.name}]] (APP) last TASK (${currentBuildType})" + } // .dependsOn "copyLibs" + + if (taskGraph.hasTask(buildRelease)) { + println "[[${project.name}]] (APP) taskGraph RELEASE (build)" + + currentBuildType = "release" + } else if (taskGraph.hasTask(buildDebug)) { + println "[[${project.name}]] (APP) taskGraph DEBUG (build)" + + currentBuildType = "debug" + } else { + if (taskGraph.hasTask(assembleRelease)) { + println "[[${project.name}]] (APP) taskGraph RELEASE (assemble)" + + currentBuildType = "release" + } + if (taskGraph.hasTask(assembleDebug)) { + println "[[${project.name}]] (APP) taskGraph DEBUG (assemble)" + + currentBuildType = "debug" + } + } +} + +task buildRelease(type: GradleBuild, dependsOn: build) { +} + +task buildDebug(type: GradleBuild, dependsOn: build) { +} + +// task assembleRelease(type: GradleBuild, dependsOn: assemble) { +// } + +// task assembleDebug(type: GradleBuild, dependsOn: assemble) { +// } + +// tasks.all { task -> +// if (task.name.startsWith('compile') && task.name.endsWith('Ndk')) { +// task.enabled = false +// } +// } diff --git a/SDKLauncher-Android/app/build_stable.gradle b/SDKLauncher-Android/app/build_stable.gradle index c1a8819f..460153dd 100644 --- a/SDKLauncher-Android/app/build_stable.gradle +++ b/SDKLauncher-Android/app/build_stable.gradle @@ -9,10 +9,21 @@ def store_password = (rootProject.hasProperty("readium_sign_store_password") ? def lcpDir = project(':lcp').projectDir def epub3Dir = project(':epub3').projectDir +def rsdkDir = project(':rsdk').projectDir +println "[[${project.name}]] (APP) Skip ARM: ${ndk_skipARM}" +println "[[${project.name}]] (APP) Skip x86: ${ndk_skipX86}" + +def currentBuildType android { - compileSdkVersion = 26 - buildToolsVersion = "27.0.3" + applicationVariants.all { variant -> + println "[[${project.name}]] (APP) libraryVariant buildType: ${variant.buildType.name}" + + // currentBuildType = variant.buildType.name + } + + compileSdkVersion = 28 + buildToolsVersion = "28.0.3" lintOptions { checkReleaseBuilds = false @@ -40,7 +51,7 @@ android { minSdkVersion 19 // manifest/uses-sdk@android:targetSdkVersion attribute in src/main/AndroidManifest.xml - targetSdkVersion 26 + targetSdkVersion 28 // manifest@android:versionCode attribute in src/main/AndroidManifest.xml versionCode 31 @@ -62,24 +73,54 @@ android { jniLibs { dependencies { - project ":epub3" + // project ":rsdk" project ":lcp" } + // srcDirs = [ + // "${epub3Dir}/jniLibs/RELEASE", + // "${lcpDir}/jniLibs/RELEASE", + // "${epub3Dir}/jniLibs/DEBUG", + // "${lcpDir}/jniLibs/DEBUG" + // ] + } //jniLibs + } //main + + debug { + jniLibs { srcDirs = [ - "${epub3Dir}/libs", - "${lcpDir}/libs" + // "${epub3Dir}/jniLibs/DEBUG", + "${lcpDir}/jniLibs/DEBUG" ] } //jniLibs - } //main + } //debug + + release { + jniLibs { + srcDirs = [ + // "${epub3Dir}/jniLibs/RELEASE", + "${lcpDir}/jniLibs/RELEASE" + ] + } //jniLibs + } //release } //sourceSets buildTypes { debug { +// sourceSets.main.jniLibs.srcDirs = [ +// // "${epub3Dir}/jniLibs/DEBUG", +// "${lcpDir}/jniLibs/DEBUG" +// ] + ext.enableCrashlytics = false minifyEnabled = false } release { +// sourceSets.main.jniLibs.srcDirs = [ +// // "${epub3Dir}/jniLibs/RELEASE", +// "${lcpDir}/jniLibs/RELEASE" +// ] + ext.enableCrashlytics = false minifyEnabled = false @@ -92,27 +133,96 @@ android { } } //buildTypes + flavorDimensions "version" productFlavors { - if (!ndk_skipARM) - "arm" { - /*dependencies { - compile('org.readium.sdk.lcp:liblcp-armeabi-v7a@aar') - }*/ - + if (!ndk_skipARM && !ndk_skipX86) { + 'armeabi-v7a--arm64-v8a--x86--x86_64' { + dimension "version" ndk.with { - abiFilters = ["armeabi-v7a"] + abiFilters = ['armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'] } } - - if (!ndk_skipX86) - "x86" { - /*dependencies { - compile('org.readium.sdk.lcp:liblcp-x86@aar') - }*/ - - ndk.with { - abiFilters = ["x86"] + } else { + if (!ndk_skipARM) { + 'armeabi-v7a--arm64-v8a' { + dimension "version" + ndk.with { + abiFilters = ['armeabi-v7a', 'arm64-v8a'] + } } } + if (!ndk_skipX86) { + 'x86--x86_64' { + dimension "version" + ndk.with { + abiFilters = ['x86', 'x86_64'] + } + } + } + } } //productFlavors } //android + +// task sourceSetJniLibsSrcDirs { +// doFirst { +// println ("sourceSetJniLibsSrcDirs: ${currentBuildType}") +// android.sourceSets.jniLibs.srcDirs = [ +// "${epub3Dir}/libs/${currentBuildType.toUpperCase()}", +// "${lcpDir}/libs/${currentBuildType.toUpperCase()}" +// ] +// } +// } + +// tasks.whenTaskAdded { task -> +// def taskName = task.name + +// if (taskName.startsWith("compile")) { +// task.dependsOn "sourceSetJniLibsSrcDirs" +// } +// } + +// dependencies { +// compile project(":lcp") +// } + +gradle.taskGraph.whenReady { taskGraph -> + println "[[${project.name}]] (APP) taskGraph ready" + + // taskGraph.getAllTasks().last().finalizedBy copyLibs + taskGraph.getAllTasks().last().doLast { + println "[[${project.name}]] (APP) last TASK (${currentBuildType})" + } // .dependsOn copyLibs + + if (taskGraph.hasTask(buildRelease)) { + println "[[${project.name}]] (APP) taskGraph RELEASE (build)" + + currentBuildType = "release" + } else if (taskGraph.hasTask(buildDebug)) { + println "[[${project.name}]] (APP) taskGraph DEBUG (build)" + + currentBuildType = "debug" + } else { + if (taskGraph.hasTask(assembleRelease)) { + println "[[${project.name}]] (APP) taskGraph RELEASE (assemble)" + + currentBuildType = "release" + } + if (taskGraph.hasTask(assembleDebug)) { + println "[[${project.name}]] (APP) taskGraph DEBUG (assemble)" + + currentBuildType = "debug" + } + } +} + +task buildRelease(type: GradleBuild, dependsOn: build) { +} + +task buildDebug(type: GradleBuild, dependsOn: build) { +} + +// task assembleRelease(type: GradleBuild, dependsOn: assemble) { +// } + +// task assembleDebug(type: GradleBuild, dependsOn: assemble) { +// } diff --git a/SDKLauncher-Android/app/src/main/AndroidManifest.xml b/SDKLauncher-Android/app/src/main/AndroidManifest.xml index fb236505..57635ff5 100644 --- a/SDKLauncher-Android/app/src/main/AndroidManifest.xml +++ b/SDKLauncher-Android/app/src/main/AndroidManifest.xml @@ -4,9 +4,9 @@ android:versionCode="31" android:versionName="1.31" > - + + + @@ -20,7 +20,8 @@ android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" - android:theme="@style/AppTheme" > + android:theme="@style/AppTheme" + android:usesCleartextTraffic="true" >