I have created a signed apk build from Android Studio and by default it's name is app-release.apk .
I just want to rename it to my app name. What should I do, please suggest?
Here are the steps to modify generated apk name :
Open app level "build.gradle" file and apply below code
buildTypes {
release {
debuggable false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
applicationVariants.all { variant ->
variant.outputs.all {
def applicationName="customized_apk_name"
// outputFileName = "${applicationName}_${variant.buildType.name}_${defaultConfig.versionName}.apk"
outputFileName = "${applicationName}.apk"
}
}
}
}
Related
I'm trying to release new update to my users on play store, but whenever I roll out the release all users complaint me about app is not updating or not installing after downloading update from play store.
How do I configure my gradle / manifest / or build settings such that users will successfully install the new update without needing to uninstall the existing apk from the device?
Please correct me if my settings are configured incorrectly.
build.gradle(app)
android {
compileSdkVersion 31
defaultConfig {
applicationId "com.myapp"
minSdkVersion 23
targetSdkVersion 31
versionCode 11
versionName "2.2.0"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
signingConfig signingConfigs.debug
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
debuggable true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.debug
}
debug {
signingConfig signingConfigs.debug
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
bundle{
language{
enableSplit=false
}
}
}
build.gradle(project)
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
proguard-rules.pro
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-verbose
-keepattributes Signature
-keep class androidx.appcompat.widget.** { *; }
-keepclassmembers class com.myapp.Firebase** {
*;
}
I'm not able to understand which part of the mentioned code having issues with. Sometimes my build takes so much time during running app for testing on device. I new in this signing process. I will really appreciate your help.
I don't really know how to word this issue which is probably why i can't find any answers online.
in react-native we can do
./gradlew assembleRelease
and it will read ~/.gradle/gradle.properties and the SigningConfig in android/app/build.gradle
signingConfigs {
release {
storeFile file(BLAH_RELEASE_STORE_FILE)
storePassword BLAH_RELEASE_STORE_PASSWORD
keyAlias BLAH_RELEASE_KEY_ALIAS
keyPassword BLAH_RELEASE_KEY_PASSWORD
}
}
to produce a signed apk.
I'd like to create signed apks but using a different keystore file from a single command
so ideally
./gradlew assembleDev
and it would create an signed apk with a different output name and signed with a different key. Ideally with a different identifier so that the app can be installed side by side with the release version of the app.
I know i need to make changes to gradle config, but searching around i can't figure out how to do this. Is there a ready made tutorial that walks someone how to do this?
I'm thinking i can't possibly be the first person to want this.
You could use the buildType as the prefix for the property names
android {
signingConfigs {
release {
storeFile file(property('release.storeFile'))
storePassword property('release.storePassword')
...
}
dev {
storeFile file(property('dev.storeFile'))
storePassword property('dev.storePassword')
...
}
}
buildTypes {
release {
signingConfig signingConfigs.release
...
}
dev {
signingConfig signingConfigs.dev
...
}
}
}
After update gradle to 3.0.0-alpha5 my project can't sync gradle.
I received this message:
Gradle sync failed: No output of type: SPLIT_LIST
and in idea.log something about my release variant:
Variant 'release' has no output with type 'SPLIT_LIST'
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
The problem is with shrinkResources config. Removing it is temporary solution for now. Unfortunately I didn't find any info about deprecation of that so I think it's a bug.
According to Multiple Deployment testing in the Code Push tutorial, it is described, on Android, how to set the Staging key on the Debug build, and Production key on the Release build. However I find this insufficient, a Debug build will not run in the same way the Release build will so shouldn't it be better to create another Gradle buildType for Staging??
I can't find anyone talking about this anywhere, am I missing something?
Here's how I ended up setting up my productFlavors and buildTypes for a staging and live environment, along with debug and release builds:
...
defaultConfig {
applicationId "com.your.app.id"
minSdkVersion 16
targetSdkVersion 22
versionCode 5
versionName "1.5.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
debug {
debuggable true
minifyEnabled false
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
applicationIdSuffix ".debug"
buildConfigField "boolean", "DEBUG", "true"
}
}
productFlavors {
live {
buildConfigField('String', 'BUILD_ENV', '"live"')
resValue "string", "app_name", "Your App"
resValue "string", "reactNativeCodePush_androidDeploymentKey", "___YOUR_LIVE/PROD_KEY___"
manifestPlaceholders = [
appIcon: "#mipmap/ic_launcher"
]
}
staging {
buildConfigField('String', 'BUILD_ENV', '"staging"')
applicationId "$defaultConfig.applicationId" + ".staging"
resValue "string", "app_name", "Your App (Staging)"
resValue "string", "reactNativeCodePush_androidDeploymentKey", "___YOUR_STAGING_KEY___"
manifestPlaceholders = [
appIcon: "#mipmap/ic_launcher_staging"
]
}
}
....
And then some corresponding scrips we use in our package.json:
...
"dev-android": "node node_modules/react-native/local-cli/cli.js run-android --variant staging --configuration Debug",
"dev-android-live": "node node_modules/react-native/local-cli/cli.js run-android --variant live --configuration Debug",
"build-android": "cd android && ./gradlew assembleRelease",
"deploy-android": "code-push release-react your-code-push-app-name android -d staging --noDuplicateReleaseError",
...
Hope that helps.
I added the signing settings as the guide says. Now when I run ./gradlew assembleDebug, it requires my keystore and key passwords, and there are two APK files at the end:
./Main/build/outputs/apk/Main-debug.apk
./Main/build/outputs/apk/Main-debug-unaligned.apk
So Gradle builds a debug version of my module but requires the release key.
The build.gradle file of the built module is below.
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
signingConfigs {
release {
storeFile file("my-release-key.keystore")
storePassword System.console().readLine("\nKeystore password: ")
keyPassword System.console().readLine("Key password: ")
keyAlias "my_key"
}
}
defaultConfig {
minSdkVersion 9
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
signingConfig signingConfigs.release
}
}
}
dependencies {
compile 'com.android.support:support-v4:19.0.1'
compile 'com.android.support:appcompat-v7:19.0.1'
compile project(':Log-Wrapper')
compile 'com.google.android.gms:play-services:+'
}
Update #1.
The solution on https://stackoverflow.com/a/24281294/1065835 works, and I accepted the answer. But I personally prefer using the approach described here. Release keys are stored locally and safely, and there is no need to type passwords every time when compiling a release version.
Seems I could merge some suggestions picked up here and there.. ..and I got it working.
The problem seems to be the fact that writing ANYWHERE in build.gradle something like:
storePassword System.console().readLine("\nKeystore password: ")
it will be executed ANYTIME.
The solution I put together was, creating a signingCongif block BEFORE buildTypes block:
signingConfigs {
release {
storeFile file("c://my.keystore")
storePassword "" // REQUIRED otherwise cannot be overwritten
keyAlias "myAlias"
keyPassword "" // REQUIRED otherwise cannot be overwritten
}
}
buildTypes {
[...]
and tweaking gradle configuration with this:
gradle.taskGraph.whenReady { taskGraph ->
if(taskGraph.hasTask(assembleRelease) || taskGraph.hasTask(installRelease)) {
// Only execute when we are trying to assemble a release build
def passKeystore = System.console().readLine("\nKeystore password: ")
def passKey = System.console().readLine("\nKey password: ")
android.signingConfigs.release.storePassword = passKeystore
android.signingConfigs.release.keyPassword = passKey
}
}
Note that:
1. This block was outside and before the "android {}" one.
2. This was tested in COMMAND LINE execution only. Seems some fixes are needed where no console is available.
It appears as though there are only 3 options:
Extract my signing config to a separate pseduo-project
Automate the signature, but sign EVERYTHING with release keys
Enter the passwords manually on the command line
This is my workaround and your 4th option to achieve a perfect balance:
apply plugin: 'com.android.application'
gradle.taskGraph.whenReady { taskGraph ->
if(taskGraph.hasTask(':app:assembleRelease')) {
android.signingConfigs.release.storeFile = file(KEYSTORE)
android.signingConfigs.release.storePassword = STOREPASS
android.signingConfigs.release.keyAlias = KEY_ALIAS
android.signingConfigs.release.keyPassword = KEYPASS
}
}
android {
...
defaultConfig {
...
}
signingConfigs {
debug {
}
release {
}
}
buildTypes {
debug {
...
}
release {
...
//signingConfig signingConfigs.release
}
}
}
This allows you to use a stored key and signature ONLY on release builds