I have a strange issue where project specific root level files (.gitignore, gradlew, gradle.properties, etc) show up twice in Android Studio's project view. Does anybody know how to fix this?
I've tried re-importing the project (after deleting the .iml and .idea file/folder).
I found exactly the same problem recently when I created a new Gradle project and imported into IntelliJ. However, the root cause seems to be the use of symbolic links when importing the project.
I have the following symbolic link:
/data -> /Users/<user>/data
When I originally imported my project, I imported /data/checkouts/<project_dir> but found that I had duplicate files from the top level directory exactly like as shown above.
However, I removed the project and attempted to import it again, this time using the full path of /Users/<user>/data/checkouts/<project_dir> and found that I no longer see the duplicates.
I haven't seen this problem before when importing an eclipse or Maven project, so can only imagine that it might be related to the use of the Gradle plugin for IntelliJ.
Related
I had created a project with Android Studio and pushed it to bitbucket. After few weeks now I have cloned it on different machine to resume my work. I imported the project in Android Studio and now I keep getting 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.
More Information about migrating to Gradle.
Don't show this message again.
I have the gradle directory in my project. I tried using the option of use local gradle distribution and pointed it to downloaded gradle-1.10 but I still keep getting the same error.
First of all I would remove following files/directories from your project-folder:
bin/
build/
.idea/
.gradle/
projectname.iml
Then try to import the project again in AndroidStudio. This usually works for me, and to avoid that in the future, adjust the .gitignore file properly.
If the first tip does not help: have you tried downloading a more recent gradle (1.12) locally and point to that directory? (Don't point AndroidStudio to download, but do it yourself first).
You are not using a gradle-wrapper are you?
If you haven't started coding in your new machine, the simplest way would be to just delete your project directory, and use "import from VCS".
Not worth the time to find the "solution", trust me. I tried. Almost 2 years since you asked the question, and people are still getting the issue, then this problem is obviously not worth solving.
Most probably you have git checkout a parent directory of a working android project.
Close freshly checked git project
Open Project
Navigate to the git checkout directory
Select a sub directory inside the git checkout project and that is the intended android project for you
I ran into the same problem. For me the problem was my sttings.gradle was cleared. After adding incude: 'modulename'. It worked for me
I fixed this issue with the following steps:
Make sure that the following two files are in your project directory. If not, create a new one with reference of your other Android projects. These are default auto-generated files.
settings.gradle
build.gradle
If it is still showing any errors when you open your project, restart your project by selecting file/(invalidate /restart).
I had the same problem and I managed to fix it by invalidating caching and restart File - > Invalidate caches and restart
I added the following dependency to to build.gradle file in Android Studio and resync-ed the project successfully:
compile 'se.emilsjolander:stickylistheaders:2.1.3'
However I was unable to use any of the class in this library. Feeling strange I opened the source tree and see if there's anything wrong. I noticed the following:
You can see Android Studio can found the available classes for other downloaded archives, but not the one I mentioned in this question. The classes.jar file is reported empty.
I tried adding an older version of the stickylistheaders library (2.1.3). Still an empty classes.jar.
When I start this question I found a similar post here. But the author of that post tried to include the downloaded project in settings.gradle, and he finally managed to include the library through the "compile" directive. My problem is that I AM using the "compile" directive, but the downloaded archive has a "empty" classes.jar. I also tried adding the library mentioned in that question (i.e. 'se.emilsjolander:StickyScrollViewItems:1.0.0'). Also an empty classes.jar.
Some notes:
The actual classes.jar file found in build/exploded-bundles is not empty.
I tried cleaning the project. I suppose this will cause all dependencies be removed and re-downloaded. However, after that, Android Studio still cannot spot any class in stickylistheaders' classes.jar.
So far, this problem only exists for se.emilsjolander's libraries. Strangely, the answerer of this post1 posted a screenshot showing that he does see a non-empty classes.jar.
Update:
I also tried deleting .gradle's cache directory in my profile directory, clean the project and rebuild again. No luck.
I can unzip the classes.jar in question. Looks like the file isn't corrupt.
Anyone knows what's wrong here? Thanks.
I think I have found the cause: it should be a bug in Android Studio.
https://code.google.com/p/android/issues/detail?id=64008
In fact, the code can build and run despite seeing errors in Android Studio. So it is obviously an issue with Android Studio.
Update 27 Jan: It should have been resolved in Android 0.4.3. As from the release notes:
Fixed a bug around library syncing (where library dependency classes
and resources could suddenly not be found by the IDE)
Have you tried syncing your project with Gradle?
Tools -> Android -> Sync project with Gradle Files.
That should reload the build.gradle file and download the (missing) dependencies.
Try this once and make sure you are not getting any error in project Structure saying that "your_lib_name not used/added"
Open File > Project Structure
and check for erros. If error is shown click on it , it will expend the errors and will show some options on right, click on the Red bulb and choose "Add to dependency".
This seems be a bug in Studio which will be fixed in next release(Android Studio 0.4.3).
I am trying to get Android Studio to work with library dependencies for my project, I am using Android Studio 0.4.0.
I've removed the dependecies from the project structure dialogue, from the settings.gradle and from the build.gradle and also from my project.iml file.
I then delete the directories of the referenced libraries from my main project, but after a few seconds, the referenced library directory reappears but only contains mylibrary.iml file. Everytime I delete it, it reappears again.
Also when Android Studio loads it displays an error stating that non gradle projects can't be referenced from gradle projects but I no longer want them referenced but somehow I can't get rid of them.
The project was imported into Android Studio from an Export from Eclipse.
Thanks for any help you can provide.
Generally, clicking on the Sync Project with Gradle Files button should clear up problems, but if they persist, you can close Android Studio, delete all the .idea folders and .iml files in your project and re-import.
There is an official bug on improving this for Android Studio. It includes a bigger description of the problem and a workaround suggested by one of the Android Studio engineers:
Bug description - click on the star button to follow it:
https://code.google.com/p/android/issues/detail?id=61510
Google Engineer suggested workaround (note that some of the bugs described are fixed):
https://code.google.com/p/android/issues/detail?id=61510#c3
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.
I got this error on Android Studio (AS):
How I got it:
I created an AS Project from scratch and everything was fine.
Then a popup showed up, and (if I recall correctly) was saying something like: "Android Framework detected". I pressed "Yes' and some changes happened to the project/module. And after that I got the above error
Edit:
In my case the problem was not Gradle related. It had to do with IntelliJ/Android Studio configuration, an .iml file in particular.
I realized that after reading this informative post here.
On Android Studio v0.8.2 clicking on Sync project with Gradle files button solved my problem.
update
Thanks to the comment of jaumard. If the Sync project with Gradle files it's not visible you have to open the Gradle panel and click sync icon on top the toolbar.
Just call (in any case) File -> Invalidate Caches and Restart....
In my case:
settings.gradle file was empty. I added defualt code:
include ':app'
Then I clicked
Then project start works.
Double check that under project structure / module / Manifest file it points to the correct manifest file in your code and not the one in generated sources.
This is true for both Android Studio and Intelli J. Sometime when you import project from existing sources it prefer the manifest file inside the generates sources directory.
What helped for me was:
delete .gradle/ folder
delete .idea/ folder
delete ****.idea*** file
reopen Android Studio
import from gradle as Android Studio then suggests
I ran into a similar problem. Looks like my .../src directory for whatever reason moved under my .../lib directory. I moved it out of the /lib directory. Now both /lib and /src are at the same level. After a couple of clean rebuilds and restarts of Android studio everything is back to normal. My emulator started up fine.
You might want to check your directory structure. Compare the directory structure with a working project. You might be able to see the difference.
Moving my AndroidManifest.xml to PROJECT_NAME/src/main fixed the issue.
I had the same errormessage and noticed I had 2 MYPROJECTNAME.iml files, but with a different casing of MYPROJECTNAME. I created this situation after checking out from SVN the project into a directory with the casing error.
Just throw away the IML file with the wrong casing, after saving the content of both and use the content that works
I had this problem with a multi-module project when I renamed the app module. In my case to solve the problem I had to manually update the app module name in the project's settings.gradle file (Android Studio didn't update that value)
Happened to me. Found that i had wrongly opened the parent folder of the actual project in Android Studio.
In my case, it was my AndroidManifest.xml file, it was all messed up due to a new library that I added in my build.gradle.
So I took the AndroidManifest.xml from my latest commit on Git and I replaced it the current one, and also my settings.gradle was empty so I added include ':app'.
Hope it helps, and happy coding !
Facing same issue, resolve after adding the missing build.gradle file in root project.