Generating Signed APK from Android Source Code without Android Studio - android

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

Related

android Firebase not working in release builds

i created a key and generated a signed apk with the key created.
i used "Generate Signed apk" in android studio
then i used the keytool command to extract the SHA1 fingerprint and added to the firebase console in my app project settings
but still firebase does not work in release builds but works fine in debug variant.
android {
signingConfigs {
release {
storeFile file('C:\\folder\\signkey.jks')
keyAlias 'key0'
storePassword ********
keyPassword ********
}
}
compileSdk 31
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled = true
shrinkResources = true
debuggable false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
i checked gradle and the signing config is correctly configured and i tried generating another key but also didnt work

How come when I generate a signed APK it produces out a JKS file?

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

Android Studio keep asking for signing configuration though I already have for the release build APK

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

Generating unsigned apk in Android Studio 2.1.1

I'm trying to generate unsigned apk in AS 2.1.1. I had it working on 1.5.1 but right now I can't get it right.
Approaches tried:
signingConfigs {
unsigned {
keyAlias ''
keyPassword ''
storePassword ''
}
...
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.unsigned
debuggable false
}
...
}
Also another approach with not specifiying the signingConfig at all.
None of these work and both return with error.
Error:Execution failed for task ':app:validateUnsignedSigning'.
Keystore file not set for signing config unsigned
Generation is done by starting "assemble" task on whole project. Executing assemble task from the main module tasks tree produces the same result.
Build tools: buildToolsVersion '23.0.1'
Gradle: 'com.android.tools.build:gradle:2.0.0'
What am I missing?
To create unsigned apk set null as signingConfig:
buildTypes {
release {
signingConfig null
...
}
}

How to debug the Android App in release mode using Android studio

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
}
}
}

Categories

Resources