Build two different apk using one single code in android eclipse - android

I am still working with Eclipse to develop android applications. Now there is a situation where I am supposed to build 2 different applications (You can consider as free and non-free version apk) using same app-code. I have got thousands of links regarding build.gradle and application package-name and others on google, but I don't how to build/use it in Eclipse.
Another question I have is how to point to 2 different images
based on different application.?

If you want to release two different build (paid and free). You need to change the package name. Just goto the manifest file.
For example: for free version
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.free">
and similarly for paid version
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.paid">
Alternatively, I will recommend you to use In app purchase feature and release only build

Try this.. Is there any way to integrate Eclipse with Gradle in Android project?.. There is no simple answer for this question.. Either you use eclipse with gradle and set two flavours with different in your build.gradle
productFlavors {
free {
applicationId 'your.package.name.free'
}
paid {
applicationId 'your.package.name.paid'
}
}
or else just copy your project twice and change package name. If you want to upload both your apps in play store then you need two different package names.

Related

How to Build different APK files using different databases in Android using Gradle tool?

We have a platform to read poetry with a SQLITE Database say SHAKESPEARE.DB .
We also have another poetry say Wordsworth.DB.
So for each poetry database we want to create a separate application like Shakespeare.apk and wordsworth.apk.
During build we want to mention the Database and mention the name of the APK.
How do we Change Database during android build through gradle and deploy different APK's
I would want to Create and Deploy Database specific APK using Gradle ?
Step #1: Use a consistent means of embedding the database in the app. For this answer, I will assume that you are using SQLiteAssetHelper, with the database packaged as words.db in assets/.
Step #2: Create two product flavors for your app in your app/ module's build.gradle file. For this answer, I will call these flavors vanilla and chocolate:
productFlavors {
vanilla {
applicationId "com.commonsware.android.gradle.hello.vanilla"
}
chocolate {
applicationId "com.commonsware.android.gradle.hello.chocolate"
}
}
(replace the applicationId values with ones more relevant to your project)
Step #3: Create a sourceset for each flavor (app/src/vanilla, app/src/chocolate/).
Step #4: Put a different words.db in assets/ of the flavor (app/src/vanilla/assets/words.db, app/src/chocolate/assets/words.db).
Now, when you build vanilla, it will use the vanilla edition of words.db. When you build chocolate, it will use the chocolate edition of words.db. No Java code changes are required. You can also put different resources in those flavor-specific sourcesets, for different icons, labels, etc. Because you have different applicationId values, both flavors can be installed on your test devices at the same time, and both flavors can be distributed through app distribution channels like the Play store.

Android Wear: Package Wear app for some product flavours

I have an Android handheld app with a couple of product flavours and 1 wear module. I need to only package this wear app with flavour1 and not flavour2.
As I understand this, adding the wear module as a dependency would include it in both flavour1 and flavour2.
I'm aware I could build the wear app manually and then add it to the flavour1's res/raw directory and have a res/xml/wearable_app_desc.xml containing the app's version and path details as outlined here:
https://developer.android.com/training/wearables/apps/packaging.html#PackageManually
But this seems like manual work and I was hoping there is a better way to do this?
if your flavors are flavorA and flavorB,
you can easily do so,
when u link it correctly in the build.gradle
Means:
flavorAWearApp project(':WearAppProject')
All the best, hope this is what u want,
Mike

Android Studio - nested flavors (Gradle)

I am trying to generate different APKs for free and paid version (removed ads in layout files), additionally I want to track with Google Analytics downloads from different stores (Google Play, Amazon, etc.)
In the directory tree it would look like this:
\
\[free]
\[amazon]
\[googleplay]
\common part for free app
\[pro]
\[amazon]
\[googleplay]
\common part for paid app
Is it possible to have such build variants with Gradle build? If not, what would you be your suggested solution. I know I can prepare flavors in flat structure (amazonfree, amazonpro, googleplayfree, googleplaypro), but some of the code would have to be duplicated.
flavorDimensions is what you search for. One dimension would be price for you ( free/paid ) and the other dimension is the store (play/amazon/..)

change package name on build android app

I'm having some questions about how to make different builds (flavors) in android, I need to make two apks, with different package-name. Inside the code just I need to change an URL and enable some tracking libs to make a DEVEL and PROD releases . How can I do this? I don't want to use Gradle for now, until they make an stable release. Any idea using maven or any trick?

How to have both Debug and Release apk on same device?

While continuing to develop my application and test it on a real phone, I need to have the release version of it on the same phone, for demonstration purposes (the release version is much more responsive, thanks to no-logs).
The problem is that the only way to make two applications co-exist on the same device in Android is by having different package names.
But package names require re-factoring and lots of propagating manual fixes... not to mention that this confuses version control...
Ideally, Eclipse+ADT would allow appending a modifier variable that would automatically generate a different package name for debug/release and would allow such co-existence, but I couldn't find any mechanism that allows doing that.
Do you know of any way to workaround this?
Creative solutions and ideas are welcome.
Use Android Studio because gradle make your life a lot easier - just use applicationIdSuffix
android {
...
buildTypes {
release {...}
debug {
applicationIdSuffix '.debug'
}
}
}
For more go here.
The only way I know is to change the package name in your applications manifest file. Eclipse should handle all the code renaming for you.
Could you put all your code in a Library Project and then just have two normal projects,
that have different package names and just include the library project in both?
This should keep all your code in one place.
The normal projects would most likely only need a valid manifest file that points to the
activities in the library project.
You may want to try this technique using ant, Jenkins and perhaps other tools to automate package renames as suggested by #LAS_VEGAS.
Although not what you asked for, this cool code snippet can help you find out at runtime whether your code is debug or release.
Another interesting such attempt can be found in this thread. I am not sure though if it works on Android.
In Android Studio, Adding build variants using Product Flavours which can be easily customized for various environments and to test side by side multiple app variants of same app. Check out this link for more information - Configuring Gradle

Categories

Resources