2

I just wanna ask if what is the simplest way to integrate two or more project.

For example I've done calculator android app and paint android app, now I want to create new project which is the allInOneApp . In the main activity of allInOneApp is a list of buttons. button for calculator, button for paint etc.

My idea for this is to copy paste all the classes and xml etc of the projects to allInOneApp and when I click the specific button it will intent to one of the projects. Is there any other way except copy paste.

3 Answers3

1

You can create an Android Library with each project so you can have as dependencies in your new app, so from the buttons you just intent the activities from each library.

Tutorial: https://developer.android.com/studio/projects/android-library.html?hl=en

You can also upload to Maven Central or JCenter your libraries and just add the dependencies in your gradle file as you do with other libraries.

Marta Rodriguez
  • 1,944
  • 2
  • 16
  • 30
  • I already created a library. Let say I have project A and project B. The project A is my Main application that has a Button (btnIntent). I made the project B as library and import it to project A. How can I intent the project A when I click the btnIntent to project B which is now an imported library to project A? –  Jun 27 '17 at 02:41
  • 1
    @ryanandrewBiugos If you have project B as a dependency in project A, you can Intent an Activity from project B as if it was in the same project. – Marta Rodriguez Jun 27 '17 at 07:20
  • I'm sorry . I don't get it. Do you have any tutorial or sample . Can I email you so that I can send what I really want with screen capture? thank you . sorry for disturbing –  Jun 28 '17 at 02:49
  • in app:gradle of proj. B I changed the **com.android.application** to **com.android.library**, menaing proj B is now a library. My problem now is how I will import it to proj. A? Do I need to upload it in [github](https://github.com/)? or it can import locally? how? –  Jun 28 '17 at 04:02
  • 1
    @ryanandrewBiugos you don't need to upload to github, you can importa as a project module, check out this answer: https://stackoverflow.com/questions/21170395/how-to-include-a-library-module-dependency-in-an-android-studio-project – Marta Rodriguez Jun 28 '17 at 08:38
  • Thank you .@Marta I made it but I think I have new issue because there is no error at all but when I try to run in my device it's giving me an error which is from gradle of both I think. Thank you anyway –  Jun 29 '17 at 01:36
  • Thank you @Marta Rodriguez I made it. You save my day :) –  Jun 29 '17 at 02:39
0

You can create multiple modules for multiple projects and one main module to call all module's main activity.

Dhiren
  • 160
  • 1
  • 1
  • 10
0

Making one of the application as a library should work.

This previous answer to a similar question might help you. https://stackoverflow.com/a/14979395/8000126