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

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

Related

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.

How to open the project from GitHub in Android studio? Troubles with Maven and android support libraries.

I'm starting to use Android Studio. I'd like to open project from GitHub
https://github.com/TonicArtos/StickyGridHeaders
On first screen I click 'Check out from Version Control', 'GitHub', select place on disk.
After cloning I have a question 'You have checked out an Android Studio project file… Would you like to open it?', I agree.
Than I agree to auto-import for Maven project.
Than I find the project 'Examples', try to build it and get 'No resource found that matches the given name Theme:AppCompat', and import android.support.v7.app.ActionBarActivity does not work.
https://www.dropbox.com/s/ph04ogcr2txmge3/Screenshot%202014-07-24%2017.42.22.png
What to do to make the example app? Requirement is to save the project structure for using 'git status' and 'git diff' commands.
There are several SO questions on this topic, but #MartinRevert's answer (https://stackoverflow.com/a/24978323/5025060) is the only one I found mentioning Android Studio's (AS's) Gradle dependency. If the Github project was built with Eclipse, importing it to AS will work but the result will not be buildable with AS (indication: the project's "Make project" icon is grayed out in AS).
Building on Martin's answer, and using IntelliJ's Migrating From Eclipse Projects page as a reference, I found a simple and transparent way to import an Eclipse-based Github project into AS 2.1.2:
Import the Github project using AS:
File->New->Project from Version Control->Github
This clones the Github project, but if it is not a Gradle Project (see above), follow these additional steps:
Create a new project using:
File->New->Import Project and click on the folder you stored the project to in step (1) above. Accept all of the defaults and AS will "import" the Eclipse project to a Gradle project which it will now be able to build.
You may now delete (using a native directory removal tool) the project you created in (1) above.
Related questions:
Android Studios - import project from GitHub
How to import an existing project from github into Android Studio
The project is not a Gradle Project, so it is not compatible with Android Studio yet.
I recommend to check out from Github inside Eclipse and export as a 'Gradle Project'.
Then, proceed to import that project into Android Studio.

Android Studio The project is already registered

I've a big problem with Android Studio.
I have a project that depends on two other projects (as libs).
I followed the guide Problems importing project into Android Studio regarding ActionBarSherlock for import external modules.
I opened "Project Structure", imported the module, but after that I can't see it in the Modules area.
The Modules area contains only the root module, seems it is not refreshed (this is strange). So if I try to add the module as a Dependency, Android Studio doesn't find any module!
Then, if I try to re-import the module, it says that the module/project is already registered!!
Maybe I'm missing something, but I don't know what....! I have this problem both on Windows and MacOSX.
Thanks in advance,
Federico
Look around in your .idea directory for mentions of the problematic project. I had the same problem and resolved it by deleting the entry from .idea/sbt.xml.
In ij go to menu: View -> Tool Windows-> Gradle
Right click on the problematic module and click Refresh External Project, You should see the module in project explorer.
I had a similar problem with ABS and other library imports. The 'Project Structure' interface just wouldn't show the modules. On trying to import the modules, it would prompt, "The project is already registered". Seems to be an IntelliJ/Android Studio issue. Invalidate Caches option didn't help.
Reimporting the project after some cleanup did work for me.
As a precaution, take a backup of your project and store it safely
Ensure that your project builds via gradle command-line and you have all required dependencies specified in respective build.gradle files. Try building with: gradle clean && gradle build
Close the project in Android Studio (or close Android Studio)
Delete .iml files and .idea folders from all modules and the main project
Start Android Studio and reimport the project (Import project from external model > Gradle)
you should remove the project from respective gradle/sbt/maven/ant tab (used to be on right vertical line of Android Studio/Intellij IDEA)
See this answer: https://stackoverflow.com/a/30442195/907576
My issue was fixed when I restart IDEA.

Android Studio Error "output path is not specified for modules"

I just recently upgraded to the newest version of Android Studio (0.1.1), but I also used Android Studio to relocate my project to my Dropbox folder. So, I'm not exactly sure which one is causing this problem. When I build or try to run my project I get this error:
Cannot start compilation: the output path is not specified for modules
"actionbarsherlock",
"EmPubLite-EmPubLite".
Specify the output path in Configure Project.
I can't find any reference to "Configure Project" and the Project Structure option under File no longer works in this release.
Solution for Android Studio version < 1.0 :
You just have to go to your Modules settings > Project and specify a "Project compiler output"
and make your modules inherit from project. (For that go to Modules > Paths > Inherit project.
Or you can specify your output for each module if you want.
In order to do so you just need to follow this steps:
Open Project structure (F4 on one of the modules in the project explorer)
Click on Project tab on the left
Define "Project compiler output:" as YOUR_PROJECT_PATH\out (or any folder you want)
Click on Modules tab on the left
Go over all your modules and verify that under the Paths tab the Compiler output is set to "Inherit project compile output path"
I ended up re-importing the project using Gradle and it's back to normal. Very weird issue.
this is a problem that I face in case I open my phonegap project with Android Studio and Webstorm.
They are IntelliJ-based project and I guess they are both writing the files in .idea
Reimporting the project is the solution.
got same error while using studio feature to import from GitHub repository.
I deleted the whole project and .. cloned it using git terminal and imported as new project ... studio prompted to add VCS root, accepted ....everything was fine afterwards. As #lordhong prompted.
I found this:
http://www.chrisdew.com/blog/2013/07/17/android-studio-nosuchmethoderror-lazystringarraylist/
it is realy help for me.
Thus, in my case, the problem was to have two libraries:
protobuf-2.4.1.jar
and new protobuf-2.5.0.jar
it resulted error:
APK path is not specified for module “Example-Example”
To correct this, rename file protobuf-2.4.1.jar to protobuf-2.4.1.jar.disabled
mv protobuf-2.4.1.jar protobuf-2.4.1.jar.disabled
How I finally managed to fix after hours!
File -> Project Structure -> Facets -> choose module's facet -> Packaging. Enter in APK Path absolute path to apk to be created: C:\workspace\MyCompany\MyProject\myProject.apk
Press ok and run your project

Android Project Dependencies

I need help with a project dependency issue in the Android SDK.
I have the following projects:
"Sync" (a Java only project)
"Agonis" (an Android Library project)
"Dragonis" (an Android application project)
Agonis has a project dependency on Sync, and Dragonis has a project dependency on Agonis, like so:
Dragonis->Agonis->Sync
I have correctly used the Properties->Android->Library dialog to add Agonis as an Android Library. I have exported the Sync project in the Agonis build path setup:
http://i.stack.imgur.com/GsQIR.png
In the Dragonis project, I see both Agonis and Sync in the "Android Dependencies" virtual folder:
http://i.stack.imgur.com/EhH8L.png
From here, I would expect everything to just work, but it doesn't.
I can start the app, but as soon as I instantiate a type from the Agonis project (com.mob.agonis.AgonisServer), I get a NoClassDefFoundError. If it matters, the Agonis type I am trying to instantiate extends a type that is in the Sync project (com.mob.sync.Server).
I tried cleaning all the projects, and using Android Tools->Fix Project Properties on both Agonis and Dragonis to no avail.
Am I overlooking something?
Put the jar library in the folder libs and add it to the java built path.
Right click on the file -> Build Path -> Add to Build Path
Hope it helps.
I figured it out.
The Sync Java-only library was compiling to 1.7 Java byte code. Android only supports converting Java 1.6 byte code to DEX.
Scroll to the top of the console, kids.
You can solve this through the command line tool. You could create/update the Dragonis and Agonis android projects - one as an application and other as library. See http://developer.android.com/tools/projects/projects-cmdline.html
You can easily set up the dependency from D -> A using the command line tools as shown in section called referencing a library project. At this stage, a build of D automatically triggers a build of A.
Now modify the build.xml of A - to include a dependency on : build and copy Sync.jar at the pre-compile stage (look inside build.xml to find the placeholder). The build and copy tasks can be done by starting a sub ant process using subant. See http://ant.apache.org/manual/Tasks/subant.html
At this stage all your dependency work properly on command line if you trigger ant build. Now you can also use eclipse by importing the android project Dragonis from source.
From the project properties of "Sync" set the "Java Compiler"-> "JDK Complience" to 1.6. Rebuild and enjoy!

Categories

Resources