Monday, 9 July 2018

Errors in Importing Existing Project in Android Studio

When we import an android project developed by someone else or on different machine, most of the time errors occurs in doing so. Here I will suggest one possible workaround to solve this error and for that follow the following steps (please note that I am not an android expert but only a beginner and faced this problem so thought of providing my solution):

A. Import the existing project in android studio:
  1. New >> Open (in android studio)
  2. Select the project folder and you will see some errors, and that's why you are here.
B. Create another android project in a new window.
C. Select 'Project' from the tool window bar on left side, and 'android' from options available under it, as shown in the figure.



C. Copy the contents of files "build.gradle(Project: your_new_project_name)" and "gradle-wrapper.properties(Gradle Version)" from the new project and replace the contents of the corresponding files in the imported project.
D. Click on 'Sync Now' option. (you  will see this option when you will be inside the first file after replacing the contents). Probably, this will solve your problem but you will see some warnings.

I hope this will work for you.

NOTE: Sometimes, android studio need to download some contents and if you are using public network, like, University network then you might fail to solve this error. So in this case, I recommend to use some personal network, like, mobile phone net.

Thanks!
Vinod

Dedicated to my parents....