• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Copying existing project (source files) into another project

RATNAJEE

Newbie
Jan 16, 2019
11
0
31
I'm having two projects A and B. I would like to import the classes and XML layout files from B to A. I surfed through the net and some made a suggestion to make the project as a Library module and implement it into the other project, I tried but the classes were not updated the newly created module. Can it be possible to import entire project into another project in android studio? If possible, instruct the procedure..
 
Hello! Yes, you can make a library from your project. For this put project B to root project A. Then add to settings.gradle the text
include ':app', ':projectB'

and add to build.gradle
dependencies {
....
implementation project(':projectB')
...}
 

Attachments

  • exm.png
    exm.png
    3.3 KB · Views: 193
Upvote 0
Hello! Yes, you can make a library from your project. For this put project B to root project A. Then add to settings.gradle the text
include ':app', '
stickouttongue.png
rojectB'

and add to build.gradle
dependencies {
....
implementation project('
stickouttongue.png
rojectB')
...}

Alexandr0617: Thanks for your reply. I did that process, but the package name in project B was not recognised while importing. Can you suggest how to use the classes in project B in A?
 
Upvote 0
Hm... This is strange. Can you give me the source code with an example of such an error?

I copied the project B in root directory of A. I included in settings.gradle file and Implemented project in dependencies. My requirement is to run the project B when the button in the class of project A was pressed. I called the 'start Activity' method to run the main activity class of project B. This giving error that the class was not recognised. If I did any mistake or if you have any alternative process, pls suggest me.
 
Upvote 0
Have you tried this -

Import as a module:
  1. Start Android Studio and open the project you'd like to add the module to.
  2. From the Android Studio menu click File > New > Import Module.
  3. Select the Eclipse ADT project folder with the AndroidManifest.xml file and click Ok.
  4. Modify the module name if desired, and click Next.
 
Upvote 0
Have you tried this -

Import as a module:
  1. Start Android Studio and open the project you'd like to add the module to.
  2. From the Android Studio menu click File > New > Import Module.
  3. Select the Eclipse ADT project folder with the AndroidManifest.xml file and click Ok.
  4. Modify the module name if desired, and click Next.

Yes LV426, Thanks for your response. I tried this method but the classes were not imported and I tried to copy the classes from the project to the module then getting error: 'Unable to resolve dependencies '..even I implemented the module as dependency and I also added the dependencies from the project into this.
 
Upvote 0
Alexandr0617, now I'm facing a new error.
After installing and running APK file, the main activity was executed but the further activities were stopped. In logcat, i found the error (attached), ' The activity already has an action bar supplied by the window decor. Do not request window.FEATURE_SUPPORT_ACTION_BAR and set windowactionbar to false in your theme to use a toolbar instead.' But my project need the toolbar. Can anyone help me to solve this problem?
 

Attachments

  • cam_tmp_1.jpeg
    cam_tmp_1.jpeg
    636.8 KB · Views: 145
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones