Android white labeling - android

I am working for a company which has this "foo" app on the store, the app is a helper for our hardware which is revelled by resellers. We made sure that the name is as generic as possible - in order for our vendors to be able to market the app as "their app".
However - some re-sellers do want to have their exact name and icon on the app. And they are willing to pay so, I need to make this happen.
Questions:
I understand that I am looking for build variants. But still, how can I modify the apk-package-name , display name is default launcher icon using build variants?
Is this permitted...? I am not "officially" spamming the store, but it feels like I could get banned for doing that exactly.
Code signing - I will upload the APK my self, and I will need to sign using different certificates (whatever it's called on android). Again - this is vague, and I cannot find documentation on this subject.
I also plan on releasing a beta version of my app in this way. I am currently using the standard mechanism, but this means that testers cannot show case the app to customers (as it's not finished or crashing most of the time) [1]
Does the term "white labeling" apply here...?
[1] the joys of working in a small company :)

You can do this with build variants as you suspected but also you would likely need Flavors.
Here is an example gradle file that has multiple build types and flavors. You set the ApplicationId (packagename used in Play Store) in the flavor settings.
Set up the signing in each type/flavor. You can add resources, icons, manifests etc that are specific to each flavor. You can even replace whole class files so customer specific code is only included in the apk for the customer you are building for.
defaultConfig {
applicationId "uk.co.foo.default"
minSdkVersion 14
targetSdkVersion 23
versionCode = 113
versionName = "3.2.3"
}
signingConfigs {
release {
storeFile file("X:\\Android Projects\\Keystore\\MyKeys.jks")
storePassword "MyPassword"
keyAlias "KeyAlias"
keyPassword "itsasecret"
}
}
productFlavors {
Customer1 {
applicationId "uk.co.foo.customer1"
}
Customer2 {
applicationId "uk.co.foo.customer2"
}
}
buildTypes {
debug {
applicationIdSuffix ".debug"
versionNameSuffix " Debug"
}
beta {
applicationIdSuffix ".beta"
versionNameSuffix " Beta"
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
signed {
minifyEnabled false
debuggable true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
Here is the folder structure for adding resources for each type\flavor. In this example, the second flavor is called "fan". The "main" folder is used by default. Each type and flavors resources are merged into the apk (replacing any of the same name in the main folder) depending on which build you choose in the "Build Variants" section of Android Studio.
Android Studio will display which folders are in effect for the current build as shown highlighted in this image.
Edit - full official documentation is available here: https://developer.android.com/tools/building/configuring-gradle.html

Related

Android build with multiple productFlavors buildTypes using travis

My Android project has multiple build type and productFlavors
flavorDimensions "default"
productFlavors {
favor1 {
applicationId "com.abc.android"
versionCode 1
versionName "1"
}
flavor2 {
applicationId "com.abc.android"
versionCode 1
versionName "2"
}
}
buildTypes {
staging {
debuggable true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.debug
}
develop {
applicationIdSuffix ".develop"
debuggable true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.debug
}
I have placed my file, say(Abc.java) under each of flavor1staging, flavor1develop, flavor2staging, flavor2develop directory
I can do ./gradlew assemblefalor1staging on my local Android studio and it works fine but when run using travis it cannot map the file and gives me error Unresolved reference Abd
Similarly for any string resources that are defined in the flavorbuild folders but not in the main folder
I have a question does the build is working fine if you give it only 1 build type?
Because according to Travis-CI they do not mention about supporting multiple build types in this link
https://docs.travis-ci.com/user/languages/android/
As all builds in the example containing only one build as you can see in these examples
https://github.com/andrewhr/rxjava-android-example/blob/master/app/build.gradle
https://github.com/pestrada/android-tdd-playground/blob/master/app/build.gradle
Please follow these projects if the project working fine after you make build.gradle as it is shown in example then add multiple builds if then gives issues need to check also log.trace of android & maybe not supported.
make it simple then complex the solution so that you could find where is the error.

How can I have two applications installed in Android with the same code base

I am trying to have two applications with the same code base. Why that? Because I am using Crashlytics and I must have the main application installed and the beta application installed as well. Because the testes want to compare both applications "in a good way" such as open the beta application and click on home button and open the main application and compare anything.
I have created a buildType like this...
buildTypes {
Debug {
debuggable false
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
ext.enableCrashlytics = false
}
beta {
debuggable false
signingConfig signingConfigs.debug
ext.enableCrashlytics = true
applicationIdSuffix ".beta"
}
}
but when I build my application using Beta or Bebug buildTypes just replace my application installed and does not create one more application.
I have changed my applicationIdSuffix for ".beta" and my main application has applicationId "com.br.whatelse.application".
Is it possible I have two applications installed with the same codebase?

How to Run Different Product Flavors in Android Studio

I'm writing my first android app, and I'm just getting started with product flavors. I have an ad-supported app in beta, and I'm writing a paid version with no ads. I can compile both flavors, I think. When I open the gradle window, I see targets like "compile AdsDebugSources" and "compile PremiumDebugSources."
Now, if I double-click on either of those, the build runs to completion without error, but I can't figure out how to run the results. If I click on the green "Run" arrow at the top of the screen, I can never run the premium app.
There's only one entry, "app" that results in a an apk being installed and run on the attached device, and it's the AdsDebug version. I guess I need to add a new configuration, but I can't find any documentation that even mentions the word "flavor."
I've tried adding a configuration, but I don't understand what the questions mean. I looked at the settings for the default app, but they don't seem to mean much. How do I tell it that I want the premium version of my app?
Or does my problem have nothing to do with configurations? I've noticed that when I look at the Build/Edit Flavors the two flavors are listed, but none of the data fields are filled in. I would have thought that these would be copied from the manifest. Have I neglected something?
All I did to set up the flavors was to add this code to the app level build.gradle file:
flavorDimensions "dummy"
productFlavors {
ads {
dimension "dummy"
applicationId 'com.example.myApp.ads'
}
premium {
dimension "dummy"
applicationId 'com.example.myApp.premium'
}
}
What else do I need to do?
Open the Build Variants tool in Android Studio. By default, this is docked on the left.
It will show a list of modules in your project, with a drop-down for each indicating the build variant that will be used by the Run button.
SOLUTION
If you want to create different type product flavours (like different urls: development url, Quality url and production url of our application)
so you want to follow this code is working properly.
android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
defaultConfig {
applicationId "com.premsinghdaksha"
minSdkVersion 17
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
flavorDimensions "client"
productFlavors {
// use for production debug and release build
production {
dimension "client"
buildConfigField("String", "BASE_URL", "YourURL")
//if you want to use string anywhere of app show you define
// buildConfigField and get value where you want to use.
buildConfigField("String", "Shop_", "\"Shop1\"")
// production app name
//if you want change application name and app icon so you define
// resValue, manifestPlaceholders and get these value in Manifests file.
resValue "string", "app_name", "Your production name"
//production app icon
manifestPlaceholders = [
appIcon : "#mipmap/app_icon",
appIconRound: "#mipmap/app_icon_round"
]
signingConfig signingConfigs.release
}
// use for quality debug and release build
quality {
dimension "client"
buildConfigField("String", "BASE_URL", "YourQualityurl")
buildConfigField("String", "Shop_", "\"Shop2\"")
//use for quality app name
resValue "string", "app_name", "quality App name"
// use for quality app icon
manifestPlaceholders = [
appIcon : "#mipmap/quality_app_icon",
appIconRound: "#mipmap/quality_app_icon_round",
]
}
// use for development debug and release build
development {
dimension "client"
buildConfigField("String", "BASE_URL", "development url")
buildConfigField("String", "Shop_", "\"Shop3\"")
//use for dev app name
resValue "string", "app_name", "developer app name"
//use for dev app icon
manifestPlaceholders = [
appIcon : "#mipmap/developer_icon",
appIconRound: "#mipmap/developer_icon_round"
]
}
}
}
If you want to create signingApp for live application, So you have follow this code in build.gradle(:app) in android{}.
signingConfigs {
// use for signed apk
release {
storeFile file("../premsingh.jks")
storePassword "app#app"
keyAlias "key0"
keyPassword "app#app"
v1SigningEnabled true
v2SigningEnabled true
}
}
Result will be showing on build Variants and click drop down Button use click of variants.

android release apk bigger than debug apk

I'm using proguard to reduce my apk size. The debug apk reduce from 90mb to 55mb, but the signed apk is 71mb. Here is my build.gradle code:
apply plugin: 'com.android.application'
android {
signingConfigs {
XXXX {
keyAlias 'xxxx'
keyPassword 'xxxx'
storeFile file('/Users/xxxx.jks')
storePassword 'xxxxxx'
}
}
compileSdkVersion 23
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.xxxx"
minSdkVersion 14
targetSdkVersion 22
versionCode 61
versionName "4.1.8.1"
multiDexEnabled true
signingConfig signingConfigs.XXXX
ndk {
abiFilters "armeabi", "armeabi-v7a", "x86", "mips"
}
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.XXXX
}
debug {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.XXXX
}
}
productFlavors {
}
dexOptions {
javaMaxHeapSize "4g"
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
}
}
and
repositories {
mavenLocal()
maven {
name "jcenter"
url "http://jcenter.bintray.com/"
}
}
dependencies {
...
}
Further explaining sosite's answer, it seems that this happens only if comparing a debug apk built via Run or Debug meant for a specific device (even without Instant Run enabled) instead of a debugapk built via Build > Build APK (for any supported device).
Any variant (even debug itself) built via Build APK will include all the resources for that variant. Also, the Run/Debug apk includes pre-dexed classes specific for that single device, while Build APK ones includes only some general pre-dexed classes that the compiler determines safe for all supported devices - the full dexing only occurs in the device itself, when the apk is installed.
I've zipdiff-ed an apk generated via Debug with another via Build APK for the same variant of the same project and published the simplified output for demonstration (also available as html).
When you build your app locally for specific type of phone then Android Studio attach only necessary resource files. When you build release version then you have attached all types of drawables so you app file size can increase drastically.
I suggest you to use jpg in place of png in as many places as you can and compress them of course - often I use tinyPNG website or just Photoshop ;)

changed package name now a pop up window appears in app

I wanted to create 2 different versions of the app on the same tablet, the code is identical just a different package name, in the build.gradle file I wrote this code:
QA {
applicationIdSuffix ".qa"
debuggable true
signingConfig signingConfigs.debug
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
now when I open the app, on some screens, it gives me a pop up to choose which package name I want to use. How can I get rid of this pop up message ? What caused it ?
I was testing on a nexus 10 tablet.
You can easily change package name in Android Studio.
you should leave the buildTypes unchanged and create productFlavors instead if you are just changing the applicationId
productFlavors {
QA {
applicationIdSuffix ".qa"
}
Dev {
applicationIdSuffix ".dev"
}
...
...
}

Categories

Resources