minifyWithR8 issue with Dynamic feature module, release build - android

I am working on a dynamic feature module for the first time. I am getting issues in minify gradle task. It says ListenableFuture file exists in base.jar and alt_acco.jar
below is my project configuration:
mobile.gradle
dynamicFeatures = [':alt_acco']
alt_acco.gradle. feature module
apply plugin: 'com.android.dynamic-feature'
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
tasks.lint.enabled = false
}
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
missingDimensionStrategy 'react-native-camera', 'general'
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
incremental true
}
buildTypes {
release {
}
releaseStaging {
matchingFallbacks = ['release']
}
debug {
}
}
productFlavors {
flavorDimensions "type"
standard {
dimension "type"
buildConfigField 'Boolean', 'Automation', 'false'
}
standardBasicOptimized {
dimension "type"
buildConfigField 'Boolean', 'Automation', 'false'
}
standard_charles {
dimension "type"
buildConfigField 'Boolean', 'Automation', 'false'
}
automation_charles {
dimension "type"
buildConfigField 'Boolean', 'Automation', 'true'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dataBinding {
enabled = true
}
}
dependencies {
// Import the Firebase BoM (see: https://firebase.google.com/docs/android/learn-more#bom)
implementation platform('com.google.firebase:firebase-bom:28.2.1')
// Firestore (Java)
implementation 'com.google.firebase:firebase-firestore'
// Firestore (Kotlin)
implementation 'com.google.firebase:firebase-firestore-ktx'
// Google Play services
implementation project(path: ':mobile')
}
settings.gradle
include ':alt_acco'
I am making a release build and the error I am getting is as follows:
Task :mobile:minifyStandardBasicOptimizedReleaseWithR8
/root/.gradle/caches/transforms-3/1169397e4788b932b8c86a71183af227/transformed/jetified-time4j-android-4.2-2018i/proguard.txt:1:1-27: R8: Ignoring option: -useuniqueclassmembernames
/opt/jenkins/workspace/APP-Android-Verify/mobile/build/intermediates/module_and_runtime_deps_classes/standardBasicOptimizedRelease/base.jar: R8: Type com.google.common.util.concurrent.ListenableFuture is defined multiple times: /opt/jenkins/workspace/APP-Android-Verify/mobile/build/intermediates/module_and_runtime_deps_classes/standardBasicOptimizedRelease/base.jar:com/google/common/util/concurrent/ListenableFuture.class, /opt/jenkins/workspace/APP-Android-Verify/alt_acco/build/intermediates/module_and_runtime_deps_classes/standardBasicOptimizedRelease/feature-alt_acco.jar:com/google/common/util/concurrent/ListenableFuture.class
> Task :mobile:minifyStandardBasicOptimizedReleaseWithR8 FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':mobile:minifyStandardBasicOptimizedReleaseWithR8'.
> com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: /opt/jenkins/workspace/APP-Android-Verify/mobile/build/intermediates/module_and_runtime_deps_classes/standardBasicOptimizedRelease/base.jar:com/google/common/util/concurrent/ListenableFuture.class
Help will be really appreciated.

Hey I had same issue because we had gradle cache enabled, I got it working by adding ./gradlew bundleRelease --no-build-cache, hope it helps.

Related

Cannot find a variant matching build type 'debug' and product flavors '[]' in :app

build.gradle module
`
android {
namespace 'com.bangkit.booking_futsal'
compileSdk 32
defaultConfig {
applicationId "com.bangkit.booking_futsal"
minSdk 21
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
viewBinding true
}
buildscript {
repositories {
maven { url "http://dl.bintray.com/pt-midtrans/maven" }
maven { url "https://jitpack.io" }
}
}
productFlavors {
sandbox {
buildConfigField "String", "BASE_URL", "\"BASE_URL\""
buildConfigField "String", "CLIENT_KEY", "\"CLIENT_KEY\""
}
}
}`
i added buildscript and productFlavors in gradle module, but it generates error as shown below.
[error(https://i.stack.imgur.com/dNlHG.png)
Cannot find a variant matching build type 'debug' and product flavors
'[]' in :app
here I use kotlin and android studio dolphin
I expect no errors when syncing the project

Android: Is there a way to generate an ".aab" file of my app without signature?

I tried the traditional generation of app bundle (.aab) without signature like we do for '.apk' using android studio menu option : Build >> Build bundle(s)/Apk(s) >> Build bundle(s).
Normally, it should generate an '.aab' file and the name of the file should contains the prefix 'unsigned' like in the '.apk' file generated in same way but it doesn't exists.
When I deliver this .aab file to my client, he say to me that the file is signed.
My Gradle file :
android {
compileSdkVersion compile_sdk_version
buildToolsVersion build_tools_version
defaultConfig {
applicationId "com.**"
minSdkVersion min_sdk_version
targetSdkVersion compile_sdk_version
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
renderscriptTargetApi min_sdk_version
renderscriptSupportModeEnabled true
dexOptions {
javaMaxHeapSize "4g"
}
}
kapt {
correctErrorTypes true
}
flavorDimensions "default"
productFlavors {
production {
dimension 'default'
versionCode rootProject.ext.version_code_production
versionName rootProject.ext.version_name_production
}
stagging {
dimension 'default'
versionCode rootProject.ext.version_code_stagging
versionName rootProject.ext.version_name_stagging
}
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
debug {
applicationIdSuffix ".debug"
}
qualif {
applicationIdSuffix ".re7"
}
}
compileOptions {
// Flag to enable support for the new language APIs
coreLibraryDesugaringEnabled true
// Sets Java compatibility to Java 11
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_11.toString()
}
buildFeatures {
dataBinding true
viewBinding true
}
}
dependencies {
..
}
}
How should I generate one without signature ?
Note: in gradle, I eleminate every signature declaration.
gradlew bundleRelease
Make sure that signingConfig in release build type is commented out

Unable to build : How to add Android Build Config for new Module

Now i am converting my android code to modularized architectural approach. Facing issues when trying add a dependency on "app" module from "chat" module.
I have the following build config for the "app" module.
android {
lintOptions {
checkReleaseBuilds false
abortOnError false
}
signingConfigs {
companydevconfig {
keyAlias 'company'
keyPassword '123456'
storeFile file('../app/jksFils/company_dev.jks')
storePassword '123456'
}
companyqaconfig {
keyAlias 'company'
keyPassword '123456'
storeFile file('../app/jksFils/company_qa.jks')
storePassword '123456'
}
companyprodconfig {
keyAlias 'company'
keyPassword '123456'
storeFile file('../app/jksFils/release.keystore')
storePassword '123456'
}
}
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.company.employee.dev"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.13"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
aaptOptions {
cruncherEnabled = false
}
testOptions {
unitTests.returnDefaultValues = true
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
testCoverageEnabled true
}
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
dataBinding {
enabled = true
}
packagingOptions {
exclude 'META-INF/ASL2.0'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
exclude 'META-INF/rxjava.properties'
}
flavorDimensions "company"
productFlavors {
dev {
dimension "company"
applicationId "com.company.employee.dev"
versionCode 277
versionName "2.0.0.16"
signingConfig signingConfigs.companydevconfig
buildConfigField 'String', 'BASEURL', '"https://dev.company.com"'
}
qa {
dimension "company"
applicationId "com.company.employee.qa"
versionCode 225
versionName "2.0.2.2"
signingConfig signingConfigs.companyqaconfig
buildConfigField 'String', 'BASEURL', '"https://qa.company.com"'
}
prod {
dimension "company"
applicationId "com.company.employee.prod"
versionCode 38
versionName "1.5.20"
signingConfig signingConfigs.companyprodconfig
buildConfigField 'String', 'BASEURL', '"https://cloud.company.com"'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
testOptions {
unitTests.returnDefaultValues = true
unitTests.all {
setIgnoreFailures(true)
jacoco {
includeNoLocationClasses = true
}
}
}
}
Now i have added a new module "chat". And it has following code in build config.
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.company.employee.chat"
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
}
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
dataBinding {
enabled true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
}
dependencies {
implementation project(':app')
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
When i try to build i get following Error.
ERROR: Unable to resolve dependency for ':chat#debug/compileClasspath': Could not
resolve project :app.
Show Details
Affected Modules: chat
ERROR: Unable to resolve dependency for ':chat#debugAndroidTest/compileClasspath': Could not
resolve project :app.
Show Details
Affected Modules: chat
ERROR: Unable to resolve dependency for ':chat#debugUnitTest/compileClasspath': Could not
resolve project :app.
Show Details
Affected Modules: chat
ERROR: Unable to resolve dependency for ':chat#release/compileClasspath': Could not resolve
project :app.
Show Details
Affected Modules: chat
ERROR: Unable to resolve dependency for ':chat#releaseUnitTest/compileClasspath': Could not
resolve project :app.
Show Details
Affected Modules: chat
Here are some things to consider
There are differences between App Module and Library Module.
Library Module is complied to .aar/file. However, App Module is Compiled to APK.
This means that you can not import App Module as dependency to Library Module. Therefore, Remove This line from Library Module:
implementation project(':app')
Make sure the library is listed at the top of your settings.gradle.
Open settings.gradle of the App Module and make sure there is your library listed
include ':app', ':chat'
import the Library Module to your App Module Build Gradle
import your Library Module as dependency
dependencies {
implementation project(':chat')
}
Most Importantly Have a look at :Create an Android library

Apk size increased drawable-xxxhdpi-v4

I am unable to figure this out. My apk size has increased by at least another MB since the last release. Yes, I have added some new code and couple of vector assets thats it. But there is this drawable-xxxhdpi-v4 which got added to my apk and my png images are repeated there.
Take a look.
Has anybody faced this?
I just cant seem to figure out why is this hapenning. Its not even like these are new images. The old ones which were 0 bytes in this folder are now occupying space.
Gradle version 2.14.1
Plugin version 2.2.3
App build.gradle:
defaultConfig {
applicationId project.APPLICATION_ID
minSdkVersion Integer.parseInt(project.ANDROID_MIN_SDK_VERSION)
targetSdkVersion Integer.parseInt(project.ANDROID_TARGET_SDK_VERSION)
versionCode Integer.parseInt(project.VERSION_CODE)
versionName project.VERSION_NAME
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
resConfigs "en", "fr"
javaCompileOptions {
annotationProcessorOptions {
includeCompileClasspath true
}
}
}
lintOptions {
abortOnError false
disable 'MissingTranslation'
}
dataBinding {
enabled = true
}
dexOptions {
preDexLibraries = false
}
// This is handled for you by the 2.0+ Gradle Plugin
aaptOptions {
noCompress "db"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
def BOOLEAN = "boolean"
def TRUE = "true"
def FALSE = "false"
def LOGGING = "LOGGING"
def STRICT_MODE = "STRICT_MODE"
def DEBUG_MODE = "DEBUG_MODE"
release {
minifyEnabled true
proguardFiles 'proguard-rules.txt', 'proguard-here-sdk.txt'
// Resource shrinking confis
shrinkResources true // remove unused resources
signingConfig signingConfigs.release
debuggable false
buildConfigField BOOLEAN, LOGGING, FALSE
buildConfigField BOOLEAN, STRICT_MODE, FALSE
buildConfigField BOOLEAN, DEBUG_MODE, FALSE
zipAlignEnabled true
applicationVariants.all { variant ->
if (variant.buildType.name == 'release') {
variant.mergeAssets.doLast {
delete(fileTree(dir: variant.mergeAssets.outputDir, includes: ['ic_launcher_debug*']))
}
}
}
}
lintOptions {
disable 'InvalidPackage'
}
packagingOptions {
exclude 'META-INF/services/javax.annotation.processing.Processor'
}
The below config worked for me
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
Yes. When you compile with Coccoon.io an android version of your app, it happens the same. The size of the app is increased at double. This is not only due to folders like this, but for the libraries Coccoon puts on the app for cordova.
I donĀ“t know if that will help you, but al least is a clue.

Can't run in debug mode

I am trying to launch my android application in debug mode, but everytime I check BuildConfig.DEBUG it says it is false. Even further, a buildconfigField defined in my buildtypes does not even show up in BuildConfig.
Here is my gradle file:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.22.0'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven {
url 'https://maven.fabric.io/public'
}
}
def versionMajor = 1
def versionMinor = 2
def versionPatch = 41
def versionBuild = 0 // bump for dogfood builds, public betas, etc.
android {
compileOptions.encoding = 'ISO-8859-1'
compileSdkVersion 21
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.name"
minSdkVersion 17
targetSdkVersion 21
buildConfigField 'Boolean', 'enableCrashlytics', 'false'
multiDexEnabled true
versionCode versionMajor * 10000 + versionMinor * 1000 + versionPatch * 100 + versionBuild
versionName "${versionMajor}.${versionMinor}.${versionPatch}.${versionBuild}"
}
signingConfigs {
release {
// release stuff
}
}
buildTypes {
android {
release {
debuggable false
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
buildConfigField 'Boolean', 'enableCrashlytics', 'true'
}
debug {
buildConfigField 'Boolean', 'enableCrashlytics', 'false'
debuggable true
minifyEnabled false
applicationIdSuffix ".debug"
}
}
}
sourceSets {
main {
res.srcDirs = ['src/main/res', 'src/main/res/xml']
}
}
dexOptions {
incremental true
javaMaxHeapSize "2048M"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
lintOptions {
checkReleaseBuilds false
abortOnError false
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.1.1'
// ... some other libs
compile('com.crashlytics.sdk.android:crashlytics:2.6.6#aar') {
transitive = true;
}
}
So in Android Studio I chooseBuild Variant "debug" for my app, but when I hit a breakpoint in the application and check the values of BuildConfig, the filed enableCrashlytics cant be resolved and the value of BuildConfig.BUILD_TYPE is "release".
What am I doing wrong?
This may happen if the code is in a library, there are multiple BuildConfig classes in a project, one per module, and only the main app one will be updated as expected.
If you want to have a proper BuildConfig.BUILD_TYPE across the app, you'd need to have debug/release build types on all your modules' gradle files, and trickle down the selected build-type from the main gradle file to the dependencies.

Categories

Resources