Generating signed apk stucks when minifyEnabled true is used - android

While generating releases apk with minify enabled true ,gradle build doesn't finish and stucks at app:crashlyticsUploadDeobsRelease.
gradle build log

Replace your build Types code with this code in app level gradle file. when you are debugging or running code on your device before final release then select built variant debug and when you are going to built signed apk for release then select built variant release
buildTypes {
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

Related

Why proGuard doesn't work when its active?

I want to reduce my app size.
I saw some tutorials and understood that I have to use the following code in build.gradle(app) :
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
I tried it but the app size didn't change until I added another code and it worked :
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
My question is why it should be use debug because it wasn't used in tutorials I saw.
I'm worried about slow app with this way.
Note : My Android Studio version is 3.5 and my gradle version is 7.0.4.
An Android Studio project default buildtype is debug, you can see it on "Build Variants" panel on left bottom corner of Android Studio. You can also change it to release

Why is Android Studio not creating the native-debug-symbols zip file when building a signed bundle

I have followed the instructions at https://developer.android.com/studio/build/shrink-code#native-crash-support to build the native-debug-symbols.zip file to upload to the Google Play Store with the new release of my app. However, no zip file is being generated. Here is the code in my build.gradle
buildTypes {
release {
debuggable false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
ndk {
debugSymbolLevel 'SYMBOL_TABLE'
}
}
debug {
debuggable true
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
ndkVersion "23.0.7599858"
I have checked that the ndk directory is loaded under the Sdk folder and it contains the folder for 23.0.7599858. In Android Studio I select build->generate signed bundle. Under app/build/outputs there is no folder for native-debug-symbols. There are three folders named apk, logs and mapping. What am I doing wrong?

ProGuard doesn't obfuscate when building alternative buildType from Android Studio

So in a few words ProGuard doesn't obfuscate sources when I build alternative buildType from Android Studio but works when I use "Generate Signed APK..." option to create apk file.
And some more details here: Android Studio 2.1.1, Gradle version: 2.10, plugin version .2.1.0
I've 3 build types with the following configuration:
buildTypes {
release {
minifyEnabled true
...
proguardFile 'proguard-rules.pro'
proguardFile getDefaultProguardFile('proguard-android.txt')
signingConfig signingConfigs.release
}
releaseDebug {
debuggable true
minifyEnabled true
...
proguardFile 'proguard-rules.pro'
proguardFile getDefaultProguardFile('proguard-android.txt')
signingConfig signingConfigs.release
}
debug {
debuggable true
minifyEnabled false
...
proguardFile getDefaultProguardFile('proguard-android.txt')
testProguardFile 'proguard-rules-test.pro'
signingConfig signingConfigs.release
}
}
I run application directly from Android Studio and have such results:
release - obfuscated
releaseDebug - NOT obfuscated
debug - not obfuscated
When I use "Generate Signed APK..." option:
release - obfuscated
releaseDebug - obfuscated
debug - not obfuscated
Is it a build system issue or I missed something?
P.S. Just for clarification, minifyEnabled is already enabled for releaseDebug build type and ProGuard is working but not in this particular case. This is not related to debug mode.
Finally, after some tests, I recognized that this issue is caused by debuggable true statement in releaseDebug configuration.
So Android Studio (or Gradle) will not use ProGuard obfuscation if you use debuggable true and minifyEnabled true statements in your alternative build type.

App crashed when i build a signed APK with jsoup

My android app was crashing when i build a signed apk. The crash was not seen when i did a debug build. The build.gradle file is like this:
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
debug {
debuggable true
}
}
setting minifyEnabled to false is not the correct solution, that would disable proguard while building the release version
The reason why setting minifyEnabled is working is because proguard might be obfuscating jsoup.
So, you should keep minifyEnabled as true and include these rules for jsoup in your proguard-rules.txt file to prevent the app from crashing :
-keep public class org.jsoup.** {
public *;
}
What i did to prevent the app from crashing is that i have made minifyEnabled to false from true in the build.gradle file. In that file i have made the following change.
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
debug {
debuggable true
}
}
If anybody have any other answers please post it here.

connectedAndroidTest and release build type

I'm using gradle:1.2.3
I would like to run my androidConntectTests (instrumentation tests) on release (signed, minified) configuration, but I cannot.
My build types:
buildTypes {
debug {
minifyEnabled false
debuggable true
}
robotium {
debuggable true
minifyEnabled true
signingConfig signingConfigs.release
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
minifyEnabled true
debuggable false
signingConfig signingConfigs.release
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
I have read, that those tests can only be run on debbugable configurations, so I made "robotium" build type (see above), but it still does not work.
When I try calling "gradle tasks" it shows only connectedAndroidTest-Flavour-Debug, and calling "connectedAndroidTest-Flavour-Release/Robobium" simply fails with "task XXX not found in root project".
Is there any way to make instrumentation tests run on diffrent build type?
The android gradle plugin will create test variants for all your flavors. To switch the build type used you can do this, as stated in the documentation
Currently only one Build Type is tested. By default it is the debug Build Type, but this can be reconfigured with:
android {
...
testBuildType "staging"
}

Categories

Resources