I have two Android apps with different icon and color themes but that share the same activities, layout and logic. Any idea how to manage these apps? It would be counter-productive to duplicate the logic and layouts. There should be only one instance of layout, logic, etc.
this is the perfect scenario for using an Android library project.
Use your project as library (check the properties) and let the two implementing projects use that library.
You can re-use code and resources like layouts, images etc. across multiple applications using a library project, linked to from your different customised projects.
In Android Studio, you can harness the power of the gradle build system and easily create a solution for your problem. Check out http://tulipemoutarde.be/2013/10/06/gradle-build-variants-for-your-android-project.html
Related
I want to create several different apps/projects that all use a common code base, as well as the same activities and views. The unique things between each project would be:
App name
Bundle identifier
Icon
Version
Analytics ID
Web service URL
Various images and colors
I believe this would involve creating a library project that contains the common code between projects, and then creating each project with the unique items above that reference the library project. Is this the approach I should be taking? Am I able to create all the views/activities in the library project and have the other projects use these?
Thanks!
I know there are a lot of questions out there about multiple Android versions pertaining to free/paid versions but this might be a little different.
My app currently uses AdMob for advertising and it's published on the Android Market and on the Samsung App Store. Unfortunately, the Samsung store will require everyone to migrate to their own Ad Network in the future, Samsung AdHub. Both AdMob and AdHub have their own libraries, their own SDKs.
I'm looking for a solution to build 2 different versions, one including AdMob the another including AdHub (and all the necessary code). What solutions do I have to easily build 2 versions without much hassle when it's time for a new version release?
Lots of solutions recommend to move the main project into a library project and then build 2 other apps which include the library project (the base project). But I'm not very fond of that solution (I prefer to keep my app in one single project, if possible) and I'm trying to look for alternatives and then make up my mind about which one is better for my needs.
I'd think you should make this possible in your code using the Strategy design pattern. It suites well and can be switched at any trigger your like (even on runtime). If you make a facade for each jar file you will be able to change the dependencies while building, having the same source code.
Other option with this method is just making some configuration in your application that determines which library to use.
Some interesting solutions can be found here:
https://groups.google.com/d/topic/android-developers/8pRugcnzR_E/discussion
The way to go now is to use Android Studio and use different Gradle flavors for each app. Thus, if you fix core functionality, you can quickly do a build for each appstore with it's own ad network.
Library Projects is the way to go. Create a base project where you implement all the common stuff and then create two separate project that use the common one as a "Library". then just implement the rest needed to make the Apps behave differently.
I'm currently in the process of creating quite a large scale Android application. As part of the application I've created a Custom View (one of many).
The Custom View in question is quite wide ranging in terms of functionality and because of that there are an awful lot of layouts, resources & drawable involved to respond to different devices, orientations, resolutions etc.
How can I separate out this functionality so it can be developed in isolation and not contaminate resources in the rest of the project. (Also, make it available to share across projects without having to untangle resource's).
I'm hoping that it is possible to somehow "jar" it all up in some way but fear this may not be possible. It would be great if anyone has any strategies to achieve this.
You'll probably want to look at a Library Project.
It lets you share code and resources between applications.
From here:
An Android library project is a development project that holds shared Android source code and resources.
Other Android application projects can reference the library project and, at build time, include its compiled sources in their .apk files. Multiple application projects can reference the same library project and any single application project can reference multiple library projects.
Are there libraries for android custom views? Re-usable components?
I did not found much on that topic. Just see everybody creates his own custom components, drawables and so on. Especially things like a homescreen-like viewswitcher and things like that, which reoccur often would be nice to have in a library.
You should check:
What Android 3rd-party libraries are there?
Android: how can i improve the look of an app?
You can put them into an Android Library Project. Here how to use them in Eclipse.
We have several apps that will be very similar in layout and code. The only difference is we will be switching out graphical elements, and making changes to a single constants file and strings file. Of course, theres several problems with this -- the first being namespace. Having an app with the same namespace will overwrite any other apps.
What are some suggestions to doing this?
Currently our namesapce is:
com.company.appname
I figured I could do:
com.company.appname.appversion
I've seen post about ant scripts that helps with this, but I'm wondering if theres more fluid solutions now.
I would suggest looking into Android Library Projects to help with this.
I use this approach for a Lite vs. Free edtions of one of my apps. I have a Library project that contains all of the source and most of the resources for the apps and then 2 projects that use the 1st as a library project, one for Lite and one for Full edition.
The two dependent projects each have their own resources and manifest, allowing the namespace to be different and for me to swap in different strings, drawables, etc. depending on the edition.
I tried the Ant approach but it seemed to be much more of a hassle than the Library project approach. Hope that helps.