I created a project, that is a finished product. Now I have different user, for them I have to change somethings such as app colors, name, service URL.
Now I made my project as a library and for different user I created different modules. And these modules are adding my project as libray.
Now my questions are
How to update my service url per client. Such as client url that is used in library project exist inside Common file. How to change/Override this?
How to change colors, and other resources?
What is a best way of creating library that allows to override its properties? And how to do that?
I know there is a complete link on android page to how to create a library. I have done that. But I really not getting how to override properties of library. How to give them a way to get updated by modules that are using them.
Related
I want to create three related android apps (employee, Manager, Secretary) in clean-architecture and also share common classes (utils, Ui & etc.) among all three apps in order to reduce code duplication. Each project has multi-modular clean-architecture design. Would you guide me on how to connect these three projects to the shared classes, please? Is there any sample code for my case?
My project after using clean-architecture book by Alexandru Dumbravan:
I think you might do some separation code between apps. You can merge it in you settings.gradle to merge all apps/libraries in one project.
Here is the example
There is 4 additional code/library in 1 project which is app, xxxapi,xxxauth and xxxcommon.
So you can set your settings.gradle into something like :
include ':app', ':xxxapi', ':xxxauth', ':xxxcommon'
If you already set that code, you can use it in all your code in one project as well.
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 started creating a library that will be shared with several projects.
The problem is that the Android documentation is really short about how to handle properly the library projects. I got really stuck dealing with the conflicts between the few classes I have in common in both the main projects and the library project.
I checked the sample from Android (Tic Tac Toe) but it is really too basic to help, but I just remarked that they used the following packages:
The main project: com.example.android.tictactoe
The library project: com.example.android.tictactoe.library
Is the library supposed to be always contained in the main project package? If yes, how to do when several projects have to share the same library project since the main package name belongs to one main project only?
My biggest problem right now is that my app is calling a class from the library project instead of the main project, and I have really no idea what is the best approach to follow.
Thanks!
Update: My question is related to this one: Best practice: Extending or overriding an Android library project class
There are lots of 3rd party libraries available (such as Action Bar Sherlock) and they do not share the same package as yours.
The packages for the library project and the main app project have no requirement of being related in any way.
In some cases it does help having the library as a sub-package of your main app package: this comes from the way you split the project and if the package for your library being a sub-package would help with organising the code, by all means make it a sub-package of your main package; otherwise, don't. It's all about structuring the code in the end.
It is ok for your app to call (actually use would be the work) classes from your library project. That's what libraries are for. They help keep code contained, reusable and decoupled from other pieces of code.
The problem is the other way around: when your library is calling a class from your main project.
The most common approach for Java and Android here is to use an interface: the library provides the interface that the main project implements, then the main project passes an instance of that implemented interface for the library project to use. The best example here would be callbacks. Android provides a set of interfaces (such as View.OnClickListener) that allow you to hook into the system and perform your application's logic (from the application's point of view, the Android classes in the SDK are the libraries).
Other approaches would be providing classes to be extended (this is just like providing interfaces, but it's used when you want to either leave the library user the option of not implementing/overriding all the methods or when you want to keep some base functionality in the object you will be receiving in your library through the use of the final modifier) and reflection (stay away from it as long as possible as it is very error-prone).
Currently I am working on an application aimed to small local businesses, which serves as a template for other applications (other stores). The base application allows local stores to send notifications to their customers, depending on the business context, notifications can be to report promotions, inform a client that he can pick up his order at the store, notices of new products in the store, etc ... What I do is work on the template for each client and then customize the appearance of the application in the background but the functionality is the same for everyone. My problem is that every time we have more businesses interested in the application and the problem arises when I find bugs or want further improvements, and to update the code in each of the applications can be hell (open each project, add the lines code, recompile, etc ...), and also publish new applications involves a great job because I have to change namespaces whole project, change the authority of the content provider, update references to the namespace associated with the template, etc. ...
Is there any way that I provide update and / or add portions of code in the original template and the changes are automatically reflected in all projects generated from the template?
I have understood Apache Ant can help with the compiling process of large project with many dependencies, but could be useful in the context of my problem?
The solution that I can think of right now is to create a project library and then put everything common to projects, including resources and Activities. The problem is that for example the application Content Provider could not go there because I need to have a single authority in the Manifiest defined for each application.
In advance thank you very much for taking the time to read my message. Any help or advice is welcome. Thank you again.
My question is there any way that I provide update and / or add portions of code in the original template and the changes are automatically reflected in all projects generated from the template?
Make the core code be an Android library project, and use that library project in all the customer apps.
The solution that I can think of right now is to create a project library and then put everything common to projects, including resources and Activities.
Correct.
The problem is that for example the application Content Provider could not go there because I need to have a single authority in the Manifiest defined for each application.
Your ContentProvider implementation can go in the library project. Your customer-specific project will need the <provider> element in the manifest, with a unique authority, pointing to the ContentProvider class from the library.
I have created a custom library that contains a UI that is to display data being read in from an external device. I have successfully created and applied the library to the project I need it in.
My main issue is I cant seem to use it at all. Ive tried to create an instance of the class file and this is failure. I have functions inside that class file I would like to use, but am unable since a simple declaration of a new class throws an exception for me.
Basically I dont want you to fix my problem, I want to see how this is done correctly. Ive searched the Internet for days and can not even find examples on how to do this.
I thought it would work just like creating an instance of any other class, but it does not. Thank you.
It sounds like you need to do some Eclipse project management.
The custom library including the UI and code that accesses the data source should be in an Android library project (see: "setting up a library project"). The Application which will use this functionality needs to include this library project (see: "referencing a library project").
See the Android docs about Managing Projects from Eclipse.