Android Studio: Importing Eclipse project from SVN along with Library projects - android

I am able to import the main project along with two other library projects from SVN. But while in the process if I select,
"Create project from existing sources" it creates the project and after doing some modifications in Project settings it works. But I could not find the Gradle file and it gives error "The project 'CrossConnectRefactored' is not a Gradle-based project" if I select the Gradle icon.
If I select "Import project from external model -> Gradle", it creates the project but still without 'Gradle' file and it gives the similar error.
If I first Export the project from Eclipse using 'Android -> Generate Gradle build files' and import the same in AndroidStudio then it creates all the required Gradle files properly. But I didn't get option to build/run the project and it always says 'Gradle project sync failed. Basic function...'.
It also gives the below error,
Could anyone please help me out with the 1st or 2nd option?

Related

Checkout Git project in Android Studio causes "project does not use Gradle"

Previously I had a project, used Gradle as build system and Git as VCS and only added src/, res/, assets/ and manifest.xml to the repository. (As it is recommended I ignored all build files). Now I use android-studio-3.1.2 and tried to import that project:
Checkout project from Version Control → Git → clone
Then selected yes for Would you like to create an Android Studio project for the sources you have checked out to … ?
create project from existing source → select project name, location and type (.idea) → …
But I ended by this warning:
Migrate Project to Gradle?
This project does not use the Gradle build system. We recommend that you migrate to using the Gradle build system.
What causes this problem and how I can solve that?
Problem is caused by ignoring build.gradle files (in project and it's modules) and settings.gradle.
Also I did not find any way to solve that automatically by Android Studio. I have to create a project from scratch and move my files to that.
You dont need import project from scratch!
It is gradle problem which doesnot come from git
If you have latest android project,
You can copy paste "The Gradle" to project which have not gradle configuration!
It is more easy

Github project import to Android Studio : Migrate Project to Gradle? This project does not use the Gradle build system

First of all This is not a duplicate of any of below questions
Migrate project to gradle error
Can't migrate project to Gradle in Android Studio
This project does not use the Gradle build system. We recommend that you migrate to using the Gradle build system
Android Studio Import Project Error
Now let me talk about the problem. I've downloaded a zip file of GitHub project file to build on my laptop. The name of GitHub project is "VNCpp" As I'm not allowed to insert more than 2 links, I have given the project name so someone can search.
When I import this project into my android studio, it gives me this error : "Migrate Project to Gradle? This project does not use the Gradle build system. We recommend that you migrate to using the Gradle build system"
Edit: Android Studio has built in facility to import eclipse project and convert it into gradle build format. But in this case, it is not happening.
I'm getting 2 options while importing the project 1)Import from available sources and 2) Import from external model i.e gradle
When I select Import using external model it shows error like in this image:
gradle path error
And when I select Import from existing sources it creates some file system that doesn't have gradle structure. So I cannot edit and build the app on studio :
File system without gradle structure
What should I do now to properly import the project ?
I solved this problem after reading carefully [the documentation(https://developer.android.com/studio/intro/migrate.html).
Clone the project from GitHub
Close all Android Studio projects.
From the Android Studio welcome screen, click Import Project (Eclipse ADT, Gradle etc).
Select the project folder with the AndroidManifest.xml file
Click ok.

Android Studio not recognising Gradle projects

No matter what projects I import they never work - Android Studio is always flagging this is not a Gradle build project.
I select VCS -> GIT and clone the repo without any problem. I then go through the wizard with no issues (I select create project from existing sources), creating my code base with a warning, below. When i try to run throws all sorts of errors.
Migrate Project to Gradle? This project does not use the Gradle build
system. We recommend that you migrate to using the Gradle build
system. More Information about migrating to Gradle.
Don't show this message again.
When I go to the link it makes no sense whatever to me, it says to create an arbitrary Gradle file and populate it with my references (I think), which is out of my understanding. I shouldnt have to do this as it says in the repository instructions that it is in fact a Gradle-based project.
The project I am trying to clone is
https://github.com/googlesamples/android-play-location.git
Can anybody tell me specifically how to import and run the following git repo in Android studio for example?
Ok from the start (as i dont know what other way works)
Go to Git master page (it has 'download to zip' or 'clone to desktop' button). use https://github.com/googlesamples/android-play-location as a test master page if you like to ensure you have no other issues i did not.
Click 'download zip'
Unzip the project
Close the current project in Android Studio -> File/Close Projects
A popup screen like this will appear, choose Import Project (Eclipse ADT, Gradle etc.)
You will be asked to select the project, select your unzipped project within the master folder, eg basicLocation
Select 'create project from existing resources' default
dont change project name (may cause issues)
Next through 'import project -> directories'
Next through project -> libraries
Next Through import projects -> modules and module dependencies
Next through import project ->SDK
Next through import project ->manifest.xmls
Android Studio starts. Ensure the configurations dropdown has a project in it called 'app' app
Select 'sync Gradle' icon (green circle)
May get language warning, ignore or accept restart, doesnt matter
At bottom it should now say 'Gradle executing tasks' after which it will run on device or emulator :)
Short answer: File > Open > the build.gradle file you just cloned with the repo
I just wanted to add this, because I had the same problem, and even if Fearghal´s answer and comments pointed me in the right direction, I think he may have added unnecesary extra steps, i.e. Download as ZIP, Close current project, etc.
Simply put, you VCS > Git Clone, and then open the build.gradle file. That´s it
This can happen for many reasons. I typically see it when I move the directory. The easiest way I have found is to close the project and then reopen it using "Import project (Gradle, Eclipse, ADT, etc.) menu item then selecting the folder. This will force it to reimport the project and fix any metadata/configs.
What worked for me was
On Android Studio
Open the settings.gradle file
include your project
include ':myproject'
Well, as Android Studio correctly says, https://github.com/googlesamples/android-play-location is not a Gradle project.
Any subdirectory of that repository is however.
They are different projects.
So clone that repository and import one of its subdirectory in Gradle.

Import Android project not select 'copy project into workspace' error

I have a problem with importing Android project to Eclipse in three scenario:
I have clone my Android project from Bitbucket and synchonized with Eclipse workspace successfully! But the project raise many error.
Then I remove my project and using import function in android (File>import project). I import the project from repo and also check to 'copy project into workspace', awesome! the project work perfectly.
Then I testing again. I also use import function and not check on 'copy project into workspace', oh no, the project keep the error like scenario 1.
We've always had this issue - however, we face it in P4 SCM.
I guess the problem would be the same, anyway - your project may not be detected as an Android project.
First create a new Android Project. Now, go to Navigator in Eclipse (Window -> Show View -> Navigator) and open .project file - copy it's contents and paste in your (imported) project's .project file. This should fix it.
Make sure to make the required changes (the project name is the only change we usually make) after copying.

Import an eclipse android project with version control system into Android Studio

I am trying to import an eclipse project with version control system into Android Studio.
Support for direct eclipse project import was added in Android-Studio version "0.5.5" where we don't need to export project first from eclipse to import it into Android-Studio.
I have an eclipse Android Project which I am trying to import into Android Studio.
Import is successful but imported project no more has version control.
Edit:- More detail
Suppose I have following Directory Structure
Project ----
|---------- .git/
|----------- MyApp
|------------MyApp_imported
During project import, I point Android Studio to Project Directory "MyApp", It copies all files in my project "MyApp" to new directory "MyApp_Imported". But imported project doesn't have version control enabled.
Now I am not sure how to proceed further.
How should I tell Android Studio to use old repository for imported project.
A step by step guide to do this will be very helpful .
Here is text from Android Tools Project Site
Project
- Importing modules should now work properly. You can import existing Eclipse
ADT projects as well as Gradle modules into an existing Gradle project;
it will copy in the sources as is done for full project import, as well as
handle dependencies transitively. Import modules either from the project structure dialog or the File | Import Module action.
- New project structure dialog implementation: Should be faster, includes
Gradle sync notification, should only perform a Gradle sync at the end
when necessary, and won't list invalid IntelliJ module warnings as before.
This is actively being worked on and the individual editors
(for flavors, build types, signing configurations etc) will be improved
in upcoming builds.
Here is the step by step solution to do it.
Open Android Studio -> Import Project-> Select your project directory. (In above case "MyApp")
Remember Select the directory which contains Manifest file otherwise new "direct import wizard" doesn't
get triggered and android studio uses old import wizard.
Android Studio will create a copy of your project "MyApp_imported" with new directory structure.
Copy your existing ".git" directory inside "MyApp_imported"
Android Studio -> VCS -> Enable version control
This will make Android Studio use your existing repository for imported project. Though imported project has
different directory structure but git handles them pretty well.
You might want to also call git add . and git add -u in the root folder of the imported project to make sure all new files are added and existing file moves are detected by git.
Android Studio -> Changes
Review all files and commit. Git will automatically handle new directory structure and file history etc will not be lost.
Now you can share it on github/Bitbucket by
VCS-> Share it on GitHUb
Note:- For bitbucket you will have to install "Bitbucket plugin" for Android Studio.
Couple of months ago I got my job as android developer.The first problem i had faced were my collegues who using Eclipse.I was allowed to use Android studio if I will not make any changes to existing project structure.After 3-4 attemps I finally found a decision.Here is steps to open Eclipse git project without migrating to Gradle and without changing project structure.
Clone git repository of project
Add /gen and /.idea to .gitignore
Open any of already created Android Studio projects.
File -> Open -> Choose path root project folder(with src and res inside)
Doble-click project to open project structure
Select root project folder -> F4
Project -> Project SDK -> Android API XX Platform && Project language level -> Override in interfaces
Modules -> Sources tab. Mark src as Sources && res as Resources.
Modules -> Paths tab. Use module compile output path.Create folders output and output_test inside gen folder (create gen if folder not exist yet).Output paths should look like C:\Users\User\project_rep\project\gen\output
Modules -> Dependencies tab. Click "+" -> Jars or directories.Select all .jar libraries which are using by your project.(Android Studio can pretend like its added only one jar but thats not true)
Facets -> "+" -> Android
Facets -> Structure tab -> Reset to defaults.
Close Project Structure window.
Run -> Edit configurations -> Android Application -> Module -> Select your module.Target device -> Show chooser dialog.
Edit configurations -> Before launch -> remove Gragle aware make, add Make.
Finally, after all of those steps you are able to hit Run button.Enjoy!
The import process does not make this easy. But here's something to try:
Let Android Studio do what it wants to do. It creates a file in the root of the new copy of the project which shows what was moved where.
Make a fresh (scratch) copy of the original git repository. Use "git mv" commands to duplicate the directory structure changes which Android Studio made. Commit the changes.
Copy the resulting .git directory into the project made by Android Studio. Use "git status" there to see how the result of the import process differs from what you did in your scratch copy of the project. At this point you might just choose to commit the remaining differences right there.

Categories

Resources