Android docs and release key resulted in failure? - android

I can't seem to figure this out and adding --stacktrace was not much help. My build of android works fine until I modify this code
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
to have the following code(notice I add 1 line to buildTypes and a whole section above it (it is all in the typical android section)
signingConfigs {
release {
storeFile 'release.jks'
keyAlias 'myAlias'
keyPassword 'password'
storePassword 'password'
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
signingConfig signingConfigs.release
}
}
I have tried signingConfigs and signingConfig both. using --stacktrace yields the caused by as
Caused by: groovy.lang.MissingMethodException: No signature of method: build_esgol9ch92dhm9du29nglcr2r.android() is applicable for argument types: (build_esgol9ch92dhm9du29nglcr2r$_run_closure2) values: [build_esgol9ch92dhm9du29nglcr2r$_run_closure2#96ce4db]
If I remove all contents of release section, it is interesting that I get the correct error ONLY when using signingConfigs (so I suspect signingConfigs is correct even though posts were correcting others on use singular over plural)...
* What went wrong:
Execution failed for task ':kds-android-studio:packageRelease'.
> A failure occurred while executing com.android.build.gradle.tasks.PackageAndroidArtifact$IncrementalSplitterRunnable
SigningConfig "release" is missing required property "storeFile".
As soon as I add another property it all fails with the very cryptic error.
Any ideas? or any ideas how to debug further?

Replace storeFile "file.jks" to storeFile file("file.jks")

Related

Android: Keystore was tampered with, or password was incorrect

I am unable to run the application, but able to generate APK.
When I run the app get these errors.
Execution failed for task ':app:packageProductionRelease'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> com.android.ide.common.signing.KeytoolException: Failed to read key engagepro from store "C:\Users\Administrator\AndroidStudioProjects\ProjectDocuments\EngagePro\engagePro.jks": Keystore was tampered with, or password was incorrect
...
Caused by: java.io.IOException: Keystore was tampered with, or password was incorrect
at com.android.ide.common.signing.KeystoreHelper.getCertificateInfo(KeystoreHelper.java:187)
... 29 more
Caused by: java.security.UnrecoverableKeyException: Password verification failed
... 30 more
app/build.gradle files snippet
android {
signingConfigs {
release {
storeFile file('C:\\Users\\Administrator\\AndroidStudioProjects\\ProjectDocuments\\EngagePro\\engagePro.jks')
storePassword 'axis1234'
keyAlias 'engagepro'
keyPassword 'engagepro123'
v1SigningEnabled false
}
}
buildTypes {
release {
lintOptions {
disable 'MissingTranslation'
checkReleaseBuilds false
abortOnError false
}
minifyEnabled false
useProguard false
shrinkResources false
debuggable true
zipAlignEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
debug {
minifyEnabled false
useProguard false
debuggable true
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
I am using the correct jks file also the correct passwords. I don't know what's wrong with it.

why run the app directly in Android Studioļ¼Œthe result apk is unsigned

I have configured the signature in the buildType code block, but when I run the app directly in Android Studio, the obtained apk is still unsigned, and I cannot get the signature information in the apk.
enter image description here
My build.gradle:
signingConfigs {
debug {
storeFile file('G:\\source\\AndroidSamples\\DiyView\\hwj.jks')
storePassword '123456'
keyAlias 'key0'
keyPassword '123456'
}
release {
storeFile file('G:\\source\\AndroidSamples\\DiyView\\hwj.jks')
storePassword '123456'
keyAlias 'key0'
keyPassword '123456'
}
}
buildTypes {
release {
minifyEnabled false
signingConfig signingConfigs.release
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
signingConfig signingConfigs.debug
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
apksigner verify -v .\app-debug.apk
DOES NOT VERIFY
ERROR: Missing META-INF/MANIFEST.MF
Change the build variant to release.
Simplest way is:
double tap left shift key.
Write variants.
Click on build variants
Select release from the dropdown.
At this point, click on Play button again.
Android Studio will install a signed apk.

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

How to sign an apk file when I click "Run(Shift+F10)" on android studio?

I do follow some other guide. It get the right signature when I follow "Build->generate signed APK". But when I click "Run", it automatically use an unknown source signature. (Is the "run" called "debug mode"?) How can I sync them?
All I have done, it to get the apk SHA1 value.
I found another way:
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
debug {
signingConfig signingConfigs.config
}
}
Sounds like you want to have a debug signing config for the app?
In your gradle you can specify a 'debug' signing config and a 'release' one.
android {
signingConfigs {
debug {
storeFile file("debug.keystore")
}
myConfig {
storeFile file("other.keystore")
storePassword "android"
keyAlias "androiddebugkey"
keyPassword "android"
}
}
buildTypes {
foo {
signingConfig signingConfigs.myConfig
}
}
}
Google Guide: here
EDIT: Typo correction

Categories

Resources