Android common Java class best practices - android

I am building a new project which uses some Java class from my other projects. I just found a bug in one of my file and I have to fix it everywhere.
Is there a way or best practices to solve this issue.
I have now these projects:
Project A (game)
Project B (game)
Project C (tutorial app)
in each projects I have these common classes:
Settings.java
Progress.java
Now I copy these files to each projects. All these files are identical and other than the bug I just found, I do not have to change them.
Thanks

How about making your own Android Library Project and linking to it from the projects where you are willing to use it.
Here, take a look. Explanation of different kind of projects you can create.

Related

Migrate project from Eclipse to Android Studio with more projects depending on a single library

I have an old eclipse android workspace which has the following structure:
one library project which has all the code and default graphics and resources
other projects which depend on the library project, but with different package names, different strings.xml and different graphic resources.
Basically what this means is that all my code is in the Library Project, and all other projects are really just different apps, based on the same code, but looking differently with different names
All these were in one Eclipse workspace and now I need to update the project, so upgrading it to Android Studio sounds like the best way to go.
The easy way is to hope that export works for your case. I battled with Eclipse->Studio migration for weeks. I had exactly that situation - one common project and other apps on top of it. Studio will just convert your common project into an Android library module, and other 'app' modules will be converted into Android app modules. Check out this answer: https://stackoverflow.com/a/22797387/2102748
When you're migrated, you should look to move your source files from the ant-style hierarchy to the gradle-style hierarchy. There is a lot of content for that here: http://tools.android.com/tech-docs/new-build-system/user-guide
Android Studio will also ask you to replace .jar libraries it knows about (like appcompat, google-play-services, etc) with gradle dependencies - do it. Life becomes so much easier.

Shared Library for Android and other Java project

Hi I'm quite new at Android programming, and I am working on a project, which contain classic java part and Android part, and I need to share some classes between these 2 subprojects. I solved it that I have other project, where are the shared classes.
Is this the best way ? Or is there better solution ?

How to batch add libraries to a lot of projects

I'm studying the Busy Coder's Guide to Android Development and I'm running the projects from his GitHub repository. The thing is: there's like 100 projects at a minimum and every single one of them I have to add manually the ActionBar Sherlock and Google Play Services because the projects usually come with a broken reference to them. Is there a way that I can list all of my projects and just add the libraries to them all at once. This is such a pain and so unproductive.
As noted on the cw-omnibus repository home page:
These projects can be imported using the normal Eclipse import process. That being said, importing all the projects is probably a really bad idea, simply because there are so many of them. Import select projects, if and when you need them.
Beyond that, you are welcome to write yourself a script that fixes up the project.properties files to point to your locations of these library projects, for those project.properties files that refer to other locations.
You should switch to Android Studio; it's the future. With Android Studio, you can set up libraries as project libraries in Module Settings. Then, every module you add to that project can use those libraries.

Create and Android project in Eclipse and duplicate it easily

What is the best way to create an Android project and duplicate it?
I would like to have projects that inherit a class that is responsible for the configurations and the base project to bug fixes and improvements.
Another problem that comes to mind is the design that some projects may change, for that matter should be able to add in my project resource folder that inherits the resources to change.
Thank you very much!
As for the duplication of project: you can easily copy-paste the whole project's structure and then from Eclipse you can do New Project -> Android Project -> create project from existing source.
What you are actually asking about, if I am not wrong, is Android Library project. This is a project that you can use to add on the source of other projects. You can read about android library projects here and in the linked page here.
I would use github fork system for inheriting projects and files. Take a look at github, create an account. Moreover, there is google code and tortoise svn alternative.

Reuse tips for Android

Android resources and their automatically generated references simplify the development of one app a great deal. But they also complicate the reuse of Android activities in multiple projects, and in general of any component that uses resources.
Library projects are a limited alternative. A project can depend on many library projects, but a library project can't depend on another, and adding additional JAR dependencies is not straightforward.
How do you reuse Android components (not plain old Java code)? Any tips and tricks?
I have some tips, tricks, and tools wrapped up in the Android Parcel Project.

Categories

Resources