In iOS we've targets, which is a custom app compilation for a customer, like custom logo, or custom contents. Do this exist in android?
I do not feel like copying whole project, as 80% of the methods are exactly the same.
The Android Gradle build system supports creating build variants with e.g. different resources easily.
With the older Ant/Eclipse-based build tooling, people often rolled their own scripts for resource customization.
You may want to look into Content Providers in Android, as they are the closest thing to accessing and managing shareable, reusable resources which I think you are aiming for.
Using gradle build system you are able to use Build Variant which is combination of Build Type(e.g. debug, release) and Flavor(e.g. free, paid)
Build Variant: debugFree, debugPaid, releaseFree, releasePaid
Related
I'm new to unity3d , and I have to use it to batch build different apks for multiple android channels. I have to change project's package name, app name, icon, and meta-data values defined in AndroidManifest.xml, which is really boring me. What's worse is that I have to depend on different sdks that makes the project so heavy.
I know that android studio now is using gradle which can use buildTypes, productFlavors and sourceSet, manifestPlaceHolder, applicationId and some other configures to build different apks for multiple android channel.
I also find some plugins in github like https://github.com/zasadnyy/unity-gradle-plugin, but it can't use buildTypes or productFlavors features.
I wonder if it is possible to use gradle to achieve my goal? Any suggestions?
Not exactly what you're searching for, but you can also script the Unity build process to achieve the same thing.
You can do custom build with a combination of build pipeline and executing scripts from the command line.
Unfortunately, Unity's gradle support is substandard (as of Unity 2017 and possibly beyond). I would recommend using the Build Player Pipeline in combination with your own Post Process Build code to selectively enable or disable features and configure the output. You can configure the specific build using Custom Scripting Directives that can be modified in the Build Settings -> Player Settings panel when building the application.
I am using various services in my android app for which I need userIDs and keys. Now I can store all of the keys in my string.xml file. However, since I have two different environments (production and debug) in server, i need to figure out a way of maintaining two different sets of keys based on environment.
Is there a standard way of maintaining keys for android app ?
You are looking for gradle feature called build variants. This will let you have i.e. different string.xml for release build and different for debug ones. See docs:
https://developer.android.com/tools/building/configuring-gradle.html
Build variants are specific builds that you can produce from Gradle,
based around shared core source code. While a standard app may have a
debug and release build type, you can expand on this by adding flavor
dimensions.
Read official guideline about Configuring Gradle Builds
Using Gradle Build Variants
In iOS do we have something like Gradle Build Flavors on Android.
Basically I want to integrate Applause SDK with my app but I dont want that code to be part of the release build. I only want to use applause sdk only to distribute the app internally and for bug reporting.
If there is nothing like flavors then what is the best way to do this.
You can make use of Schemes and Build configurations in Xcode. Here's the official documentation: https://developer.apple.com/library/ios/recipes/xcode_help-project_editor/Articles/BasingBuildConfigurationsonConfigurationFiles.html
After you create a build configuration, you should edit your scheme to use that build configuration. For that click on your scheme and select Edit Scheme.
In short, the process is:
Create a build configuration
Set some custom flags for that configuration. For this, go to your target, select Build Settings tab, and search for Preprocessor Macros. There you'll be able to add custom flags
Edit your scheme, or create a new scheme, to use your build configuration.
In your code, you'll have to ask if the flag is available using preprocessor macros:
#ifdef APP_STORE
//do something
#endif
There are several approaches you can take to build an iOS app in different flavors:
Different versions of a resource file
Use a custom build variable to switch between different versions of a resource file. This article discusses how to build an app with different icons.
For *.strings files and resources linked in *.storyboard files the suffixing approach suggested in the first item did not work for me. So I added a Run Script build phase early in the pipeline. Using a script you are free to do whatever you want before the usual build chain handles your files. This is great for dynamic file generation or advanced file selection logic. As a switch you can (again) use a custom build variable.
Modifiying code
Use a compiler flag as suggested here. These can be checked using the preprocessor.
Alternatively you can (again) check custom build variables. To make them accessible add them as a key in a plist file.
My server needs to keep building a large amount of Android projects. All of them are almost identical except for minor change on manifest.xml or any resource file (if it's better for the task) for each build. To reduce cost and improve efficiency, I try to implement incremental build. My planned procedures are:
after the first successful build, skip all the previous
procedures (aapt to generate R.java, adle to make java, etc.)
directly call aapt to make resource files, e.g., *.ap_
call apkbuilder to make classes.dex and usigned.apk
make signed.apk
So my question is whether the above solution is possible? And any clue about how to implement it?
This isn't necessarily a solution for your particular requirements but perhaps it will provide you with some useful pointers.
I have an Antlib that I use for building Android projects. You probably won't want to use it yourself as it has some drawbacks, but it should serve as an example of how to perform the various steps to build an Android app using Ant. In particular, it shows how to call the various Android SDK tools from Ant and how to use the Ant uptodate task and Ant's if and unless attributes to avoid processing files that haven't changed.
The source for the Android Ant macros is here (the Antlib documentation might help you to make sense of what it's doing).
I have an App that is produced for different brands. Now I have two flavors, brand1 and brand2. The difference between brand1 and brand2 are only the resource files.
First I assumed I could set all shared data into my main path and the differences into the flavored path. But in this scenario my build failed, because resources in my main path are missing.
I would go on like this: set all resource differences between the brands in the main path as dummy data. The merge will do the rest for me.
In iOS I can set a build path for each build target.
Is something like this possible with flavors? Or what is the best practice in this situation?
[EDIT 2013 08 07]
The problem in my case was that I created the app in eclipse and exported it to android studio.
Here the problem and solution is described more precisely.
Another solution is to put everything shared (basically the a "vanilla" version of your app) as a libary project, including default resources.
Then you can create seperate "brand" projects that use the library project. Any resources you put in these will "overwrite" the library project resources.
http://developer.android.com/tools/projects/projects-eclipse.html#SettingUpLibraryProject
I've done this for clients and it's worked quite well.