I tried to test the release build of the app. So I have added the below config to build.gradle of my app. But that didn't make any effect. Test always runs on debug build
android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "com.****.****"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0 Beta"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
testBuildType "release"
signingConfigs {
release {
keyAlias '******'
keyPassword '*****'
storeFile file('path to keystore')
storePassword '*****'
}
}
buildTypes {
release {
minifyEnabled true
debuggable true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
debug {
multiDexEnabled true
}
}
}
When searched for answers in other SO thread I found testBuildType "release" will run test on release build but it did not work
I'm not sure I got it all, but a few things :
You can test your release with the build variant menu on Android studio (menu at the bottom left) (#Sagar Chavada suggestion)
When you generate your signed apk with Android studio you can choose at the end the build type, release in your case
I know it's for testing purpose but debuggable true in your realease build won't allow you to push it on Google play
Whenever you are building a project and want to create a signed apk then
Add following code in to android {} in your build.gradle file.
productFlavors {
RELEASE {
applicationIdSuffix ".release"
versionNameSuffix "-release"
}
DEBUG {
applicationIdSuffix ".debug"
versionNameSuffix "-debug"
}
}
Go to Android SDK --> Build.
Tap on Generate Signed APK
It will ask to create a debug or Signed build (apk format)
Then select release flavour and generate apk.
Related
I'm running into an odd issue and not at all sure why.
I'm using firebase app distribution to install development-grade versions of my app and whenever I try to install a dev version of my app, it won't install claiming that the app exists already, but it doesn't.
I have the app from the store installed and upon uninstalling that, the app will then install but I don't understand why as both have different applicationIds.
the store version has: com.example.myapp & the dev version has com.example.myapp.preview and the app name is also different as is the version code and version name.
I don't get what they seem to share that is causing it to not allow both of them to coexist.
Not sure if this is important, but when I try to install the dev version, play protect will pop-up claiming the app is unknown and to be sure you trust it.
I'm hoping someone can steer me in a direction on solving this as I'm simply lost on what's causing the conflict.
here is the relevant gradle config:
android {
compileSdk 32
defaultConfig {
applicationId "com.example.myppp"
targetSdkVersion 32
minSdkVersion 26
versionCode verCode
versionName "4.2.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
signingConfigs {
development {
storeFile file("../keystore/development.jks")
storePassword System.getenv("DEV_SIGNING_STORE_PASSWORD")
keyAlias System.getenv("DEV_SIGNING_KEY_ALIAS")
keyPassword System.getenv("DEV_SIGNING_KEY_PASSWORD")
}
debug {
storeFile file("../keystore/debug.jks")
storePassword System.getenv("DEBUG_SIGNING_STORE_PASSWORD")
keyAlias System.getenv("DEBUG_SIGNING_KEY_ALIAS")
keyPassword System.getenv("DEBUG_SIGNING_KEY_PASSWORD")
}
release {
storeFile file("../keystore/prod.jks")
storePassword System.getenv("PROD_SIGNING_STORE_PASSWORD")
keyAlias System.getenv("PROD_SIGNING_KEY_ALIAS")
keyPassword System.getenv("PROD_SIGNING_KEY_PASSWORD")
}
}
buildTypes {
development {
versionNameSuffix "-DEV"
minifyEnabled false
applicationIdSuffix '.preview'
debuggable true
signingConfig signingConfigs.development
firebaseCrashlytics {
mappingFileUploadEnabled false
}
}
debug {
versionNameSuffix "-DEBUG"
minifyEnabled false
applicationIdSuffix '.debug'
signingConfig signingConfigs.debug
firebaseCrashlytics {
mappingFileUploadEnabled false
}
}
release {
signingConfig signingConfigs.release
// Enables code shrinking, obfuscation, and optimization for only your project's release build type.
minifyEnabled true
// Enables resource shrinking, which is performed by the Android Gradle plugin.
shrinkResources true
// Includes the default ProGuard rules files that are packaged with the Android Gradle plugin.
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
// Makes crash reports readable
// #see https://firebase.google.com/docs/crashlytics/get-deobfuscated-reports?platform=android
firebaseCrashlytics {
mappingFileUploadEnabled true
}
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
packagingOptions {
resources {
excludes += ['META-INF/*.kotlin_module']
}
}
kotlinOptions {
jvmTarget = '11'
freeCompilerArgs += "-opt-in=kotlin.RequiresOptIn"
}
buildFeatures {
viewBinding true
}
lint {
abortOnError true
}
}
I have discovered my issue, it appears I was reusing the same file provider identifier, I made that more dependent on the application id and now I'm able to install the dev app alongside my store version.
I also has add product flavors as I saw a few SO answers claim that's a better way to go about what I was looking to do.
I have built a release android apk file, conceived for a size of 7.9 MB.
I manage to install it on my android device, but not to open it because it crashes.
When i use flutter run --release it still does not open and detects no errors.
How can I solve that problem?
Thank you for your help.
Note: I have found several questions close to mine, but they have an error or are not entirely similar to mine. As a consequence the solution given do not work on my case.
Here is some of my build.gradle
android {
compileSdkVersion 28
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
checkReleaseBuilds false
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.misteref.mykamus"
minSdkVersion 16
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
}
in app level build.gradle
set minifyEnabled and shrinkResources to false
or use progaurd if you need this two be true
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled true
shrinkResources true
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
To expand on #Joachim Haglund's comment
update your gradle file with the following. All the builds will then be included in the aab file. (It's also worth checking what SDKs you have installed/require updating with Android Studio)
android {
defaultConfig {
//add the following
ndk {
abiFilters "x86", "x86_64", "armeabi", "armeabi-v7a", "arm64-v8a"
}
}
}
I was following this documentation "Configure the build process to automatically sign your app" https://developer.android.com/studio/publish/app-signing#sign-auto and trying to generate apk for release version.
However, the apk that is generated always locate inside debug folder even though I did setting for release on Module Setting.
This is gradle file.
android {
signingConfigs {
config {
keyAlias 'key0'
keyPassword 'password'
storeFile file('C:/path/to/filename.jks')
storePassword 'password'
}
}
compileSdkVersion 28
defaultConfig {
applicationId "com.packagename"
minSdkVersion 19
targetSdkVersion 28
versionCode 3
versionName "2.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
}
}
and I clicked Build Bundle(s)/APK(s) -> Build APK(s)
Is this what it supposed to do? If not, how can I fix this?
In android studio click on Build variant option on left vertical bar and then select release Build variant then Build Bundle(s)/APK(s) -> Build APK(s)
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 this build config in my gradle file ?
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
debug {
applicationIdSuffix ".debug"
versionNameSuffix ".debug"
}
qa {
applicationIdSuffix ".qa"
versionNameSuffix ".qa"
}
}
sourceSets { debug { res.srcDirs = ['src/debug/res', 'src/debug/res/values'] } }
}
why when i am try to run qa it trow me and error for not having key for this flavor ?
The only build type for which Gradle can build your project "out of the box" is debug, as the Android Plugin for Gradle knows to use the plugin-created debug signing keystore. For everything else, you either need to:
Configure a separate signing keystore (e.g., for release)
Initialize the new build type from the debug build type, akin to using a copy constructor, so it uses the same rules that debug does for signing
In the following sample, I want to define a new mezzanine build type, giving it the same signing configuration as I use for release. So, I use mezzanine.initWith(buildTypes.release) to set up mezzanine as a copy of release, then continue to configure it with different rules:
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "21.1.2"
defaultConfig {
versionCode 2
versionName "1.1"
minSdkVersion 14
targetSdkVersion 18
}
signingConfigs {
release {
storeFile file('HelloConfig.keystore')
keyAlias 'HelloConfig'
storePassword 'laser.yams.heady.testy'
keyPassword 'fw.stabs.steady.wool'
}
}
buildTypes {
debug {
applicationIdSuffix ".d"
versionNameSuffix "-debug"
}
release {
signingConfig signingConfigs.release
}
mezzanine.initWith(buildTypes.release)
mezzanine {
applicationIdSuffix ".mezz"
debuggable true
}
}
}
In your case, you would use something like qa.initWith(buildTypes.debug) before configuring the rest of the qa build type.