ANSWER
Ok. So a lot happened here. So let me assemble the answer.
First create the desired flavors:
productFlavors{
training{
applicationIdSuffix ".training"
versionNameSuffix "-training"
}
full{
}
}
Second, get a list of all the path structures you may need by:
- Click on the Gradle icon on the right of the IDE
- under your project > Tasks > android, click sourceSet: This will show you all the directory structures you may need
- right click sourceSet and click run to get a list of the directory structures
- Do not remove the
google-services.json
file from /app to /main. Then make copies ofgoogle-services.json
and place one under each flavor directory. So for me for example, I placed one under /training - IMPORTANT Go to developer console, and create credentials for each flavor: production and debug. And update each
google-services.json
file with the correct information.
QUESTION
I could tell you the business need, but that's a bit beside the point. I have a requirement to create two "production" APKs from a single source code. Nothing else to change. It's the exact same app, except there are two of it, each with a different launcher icon. I don't even know how to start doing it. Has anyone accomplished this and don't mind sharing? I am using Android Studio with Gradle, on a Mac.
UPDATE
Based on the feedback I was able to update my gradle file to this
productFlavors{
training{
applicationIdSuffix ".training"
versionNameSuffix "-training"
}
full{
applicationIdSuffix ""
versionNameSuffix ""
}
}
Right now fullDebug and fullRelease compile fine. But when I change Build Variant to trainingDebug or trainingRelease, the code no longer compiles: R cannot be resolved.
EDIT:
I finally see what you guys were asking for. Here is the trace:
Executing tasks: [:app:generateTrainingDebugSources, :app:prepareTrainingDebugUnitTestDependencies, :app:mockableAndroidJar, :app:generateTrainingDebugAndroidTestSources]
Configuration on demand is an incubating feature.
WARNING: The `android.dexOptions.incremental` property is deprecated and it has no effect on the build process.
Incremental java compilation is an incubating feature.
:app:preBuild UP-TO-DATE
:app:preTrainingDebugBuild UP-TO-DATE
:app:checkTrainingDebugManifest
:app:preFullDebugBuild UP-TO-DATE
:app:preFullReleaseBuild UP-TO-DATE
:app:preTrainingReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAnimatedVectorDrawable2420Library UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72420Library UP-TO-DATE
:app:prepareComAndroidSupportCardviewV72420Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2420Library UP-TO-DATE
:app:prepareComAndroidSupportPaletteV72420Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72420Library UP-TO-DATE
:app:prepareComAndroidSupportSupportCompat2420Library UP-TO-DATE
:app:prepareComAndroidSupportSupportCoreUi2420Library UP-TO-DATE
:app:prepareComAndroidSupportSupportCoreUtils2420Library UP-TO-DATE
:app:prepareComAndroidSupportSupportFragment2420Library UP-TO-DATE
:app:prepareComAndroidSupportSupportMediaCompat2420Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42420Library UP-TO-DATE
:app:prepareComAndroidSupportSupportVectorDrawable2420Library UP-TO-DATE
:app:prepareComAndroidVolleyVolley100Library UP-TO-DATE
:app:prepareComCrashlyticsSdkAndroidAnswers136Library UP-TO-DATE
:app:prepareComCrashlyticsSdkAndroidBeta114Library UP-TO-DATE
:app:prepareComCrashlyticsSdkAndroidCrashlytics255Library UP-TO-DATE
:app:prepareComCrashlyticsSdkAndroidCrashlyticsCore238Library UP-TO-DATE
:app:prepareComDavemorrisseyLabsSubsamplingScaleImageView350Library UP-TO-DATE
:app:prepareComEgosventuresCar360LibraryCaptureCar360libraryCapture1012Library UP-TO-DATE
:app:prepareComGetbaseFloatingactionbutton1101Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppinvite940Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAuth940Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAuthBase940Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesBase940Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesBasement940Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesGcm940Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesIid940Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesLocation940Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesTasks940Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseAnalytics940Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseAnalyticsImpl940Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseCommon940Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseCore940Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseIid940Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseInvites940Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseMessaging940Library UP-TO-DATE
:app:prepareComJakewhartonTimberTimber410Library UP-TO-DATE
:app:prepareComMelnykovFloatingactionbutton130Library UP-TO-DATE
:app:prepareComWritingmindsFFmpegAndroid032Library UP-TO-DATE
:app:prepareIoFabricSdkAndroidFabric1310Library UP-TO-DATE
:app:prepareJpWasabeefRicheditorAndroid120Library UP-TO-DATE
:app:prepareTrainingDebugDependencies
:app:compileTrainingDebugAidl UP-TO-DATE
:app:compileTrainingDebugRenderscript UP-TO-DATE
:app:generateTrainingDebugBuildConfig UP-TO-DATE
:app:mergeTrainingDebugShaders UP-TO-DATE
:app:compileTrainingDebugShaders UP-TO-DATE
:app:generateTrainingDebugAssets UP-TO-DATE
:app:mergeTrainingDebugAssets UP-TO-DATE
:app:processTrainingDebugManifest UP-TO-DATE
:app:fabricGenerateResourcesTrainingDebug
:app:generateTrainingDebugResValues UP-TO-DATE
:app:processTrainingDebugGoogleServices
Parsing json file: /Users/myname/StudioProjects/appname/app/google-services.json
:app:processTrainingDebugGoogleServices FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processTrainingDebugGoogleServices'.
> No matching client found for package name 'com.company.appname.training'
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 9.567 secs