For some reason I have to run my Android App in release mode.I have to run through the code when running the app just like we use in debug mode. My break points are not hitting when I run in release mode, I have added android:debuggable="true" in manifest. Still the breakpoint is not hitting. Any help.
Thanks in Advance
In your gradle file, you must add debuggable ability in your release flavor.
buildTypes {
release {
debuggable true
minifyEnabled false
signingConfig signingConfigs.release
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
debug {
debuggable true
minifyEnabled false
applicationIdSuffix '.debug'
}
}
signingConfig is release configuration it must be added in gradle file in android{} block, something like this:
signingConfigs {
release {
keyAlias 'YourAppKey'
keyPassword 'somePassword'
storeFile file('appkeyfile.jks')
storePassword 'somePassword'
}
}
In my case, I have created the debug configuration same as previous release build and started debugging. It means you have to give sign build in debug version also in build gradle.
signingConfigs {
config {
keyAlias 'abc'
keyPassword 'xyz'
storeFile file('<<KEYSTORE-PATH>>.keystore')
storePassword 'password'
}
}
buildTypes {
debug {
debuggable true
signingConfig signingConfigs.config
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
So It will have the same sign as release build and you can debug when it runs.
buildTypes {
release {
debuggable true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
happy coding.Mark this answer up..if it helps.. :)
Few pennys for the new comers.
If even After adding debuggable true in release block, your debug points are not hit.
Remove the following code from the release block.
minifyEnabled true
shrinkResources true //remove resources
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
There's no "release mode". What you refer to is the build type which means steps taken during building (like minifying etc). Setting android:debuggable="true" will not automagically help, because when you "Run" the app instead of "Debug" you do not connect debugger to it so it will not stop for that particular reason.
So you can
set up your Debug build to be produced the same way Release
is
But is quite unclear what is the reasoning behind your need and I got a feeling you are trying to go the wrong way (i.e. debug is usually not using ProGuard, while release build is and ProGuard changes the resulting binary so your breakpoints from source will not really work anyway).
I think Marcin's argument above makes sense (much as there are situations that require debugging release builds), so here is a slight variation of the accepted answers that worked for me:
android {
...
buildTypes {
release {
shrinkResources false # this was key
minifyEnabled false # seems that it can't be set to true if shrinkResources is false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
Adapted from the official docs
NOTE:
When I set minifyEnabled true, the following crash occurred on app launch:
java.lang.RuntimeException: Unable to instantiate application co.mycompany.app.MyApp: java.lang.ClassNotFoundException: Didn't find class "co.mycompany.app.MyApp" on path: DexPathList...
In 2022, or at least in MY case
I tried many solutions but didnt work finally solution was to create a new siginig key and use it with all build types &variants.
Steps
1 - Go to AndroidStudio top menu select Build>Generate Signed Bundle /APK > (choose APK )
*for the first time create a new key (you know how to create one? or read docs )
BUT NOTE while you are creating key choose build type debug then continue
2 - Again Go to AndroidStudio top menu select Build > Generate Signed Bundle /APK > (choose APK) BUT this time choose existing key ( the one we made in previouse step)
in previouse step we chose build type debug this time choose release and continue..
3 - Repeat steps 1 & 2, with AAB (release & debug)
this is basically making sure all build types are being signed using same configs.
NOTE
maybe you need to add below code to app build.gradle
android {
...
signingConfigs { <-- Add this
config {
storeFile file('PATH_TO_KEY.jks')
storePassword 'YOUR PASSWORD'
keyAlias 'YOUR KEY ALIAS'
keyPassword 'YOUR PASSWORD'
}
}
...
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config <-- this
}
debug {
signingConfig signingConfigs.config <-- this
}
}
}
Related
I don't know if it is possible or not, but can it be possible to have different SHA1 in same project for different package named modules.These modules are different apps i.e., one for user and one for admin. While creating project i found that using modules will be great but i think now i got confused whether i should have different project or can be possible with this. Since i have to add the firebase cloud messaging to both modules. It is showing sha1 already used since both modules are having same SHA1.
I have checked every where but didn't found about it anywhere .
You can have different product flavors and different signing config. Also take a note that each certificate you will have different sha1.(https://developer.android.com/studio/build/build-variants)
signingConfigs {
debug {
storeFile file("debug.keystore.jks")
storePassword ""
keyAlias "debug"
keyPassword ""
}
production {
storeFile file("release.keystore.jks")
storePassword ""
keyAlias "release"
keyPassword ""
}
}
buildTypes {
production{
debuggable true
minifyEnabled true
shrinkResources true
signingConfig signingConfigs.production
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug{
debuggable true
minifyEnabled false
shrinkResources false
signingConfig signingConfigs.debug
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
I'm using the newest version of Android Studio and I am looking at publishing an app on the Play store. Unfortunately when I generate a signed APK it only gives me the open to produce a JKS file. All the tutorials I've seen makes it look like you put an APK and that's what you get out, but those are using older versions of Android studio. Do I need to put the JKS file through something else, download an older version of Android Studio or am I missing a step? I'm really new at this and I'd appreciate any help I can get. Thanks!
You need to create a JKS file once. After that make sure You have something like this in Your gradle file, inside "android" part:
signingConfigs {
config {
keyAlias 'key'
keyPassword '123456'
storeFile file('../app/key/yourAppKey.jks')
storePassword '123456'
}
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
}
After this part has been added just set build variant -> release and then use build -> build bundle/apk -> build apk
I have bought an android app source code from codecanyon. I want to generate android apk for distribution without android studio. Any alternative?
Reason:
I have some problem installing android studio in my pc which makes it impossible to use android studio.
You should specify signingConfigs and buildTypes in build.gradle's android block. For example:
android {
defaultConfig {
...
}
signingConfigs {
config {
keyAlias '...'
keyPassword '...'
storeFile file('../key.jks')
storePassword '...'
}
}
buildTypes {
debug {
useProguard false
minifyEnabled false
debuggable true
applicationIdSuffix '.debug'
}
release {
signingConfig signingConfigs.config
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
useProguard true
minifyEnabled true
debuggable false
shrinkResources true
}
}
}
Then from terminal or command prompt in root path of your project, run the following commands:
// To generate debug apk
gradlew assembleDebug
// To generate release apk
gradlew assembleRelease
yes you can do it in command line. see the tutorial from official site with this link
I have in my build.gradle:
android {
signingConfigs {
debug {
storeFile file("debug.keystore")
}
release {
try {
storeFile file("mykey.keystore")
storePassword "store_password"
keyAlias "myapp"
keyPassword "key_passowrd"
)
}
catch (ignored) {
throw new InvalidUserDataException("Something wrong")
}
}
}
buildTypes {
debug {
debuggable true
minifyEnabled false
versionNameSuffix '-DEBUG'
}
release {
debuggable false
minifyEnabled true
versionNameSuffix '-RELEASE'
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
In build variant, I choose "release". Then, I run my app on connected device, however, Android Studio keep popping up dialog saying:
But I do have signing configuration...
In build output, I don't see that app-release.apk either :
Why I get the error then? My Android Studio version is 3.0.1
You forgot to provide a link to your signingConfigs:
buildTypes {
release {
signingConfig signingConfigs.release
...
}
debug {
signingConfig signingConfigs.debug
...
}
}
You forgot to specify which signing config should be used for build type
debug {
signingConfig signingConfigs.debug
}
Also signing config names should not (but may!) match build type names (eg you may define alpha and beta signing configs and use them as
debug {
signingConfig signingConfigs.alpha
}
By default gradle (android plugin) provides 'system' debug signing config so you may just skip it but it will be available (currently your build script overrides 'system' signing config
Cannot debug application com.domain.test on device samsung-gt_i9300-323020cfc86b804f.
This application does not have the debuggable attribute enabled in its manifest.
If you have manually set it in the manifest, then remove it and let the IDE automatically assign it.
If you are using Gradle, make sure that your current variant is debuggable.
Your comment has already hinted the answer to this post but since you have not selected an answer I'll write it down.
Change build variant from release to debug from android studio left corner.
A right solution is written in https://stackoverflow.com/a/25628789/2914140:
open build.gradle of your module, type: 'debuggable true' (an example is below):
buildTypes {
release {
signingConfig signingConfigs.release
debuggable true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
debug {
applicationIdSuffix ".debug"
debuggable true
}
}
When you generate a signed APK from menu, you should edit 'release' branch changing 'debuggable true' to false in order to avoid a debuggable information.
In build.gradle
debug {
debuggable true
signingConfig signingConfigs.debug
}
for whose came here searching TS's quote, check if you set Android Application in Run/Debug configuration popup. Not Native, like in my mistake.