Created new project in Android Studio on the desktop.
in the Android view in the Project Explorer all looked normal.
Moved the project to a new folder on the desktop and opened it in Studio.
Now in the Android view in the project explorer there is no dropdown icon on the Java directory.
I have invalidated caches, cleaned the project and probably a couple of other things I have forgotten, still cannot see my source files.
I tried both copy and move using file explorer in win7.
I have faced the same issue, although #Igor answers fix your issue, it was different for me because the Java files are missing in the file directory. Same as you, I've also followed the same steps from https://developer.android.com/training/basics/firstapp/creating-project.html and there's nothing special with those steps.
I have resolved the issue by downloading the SDK quck fix in the "Messages Gradle Sync" explorer.
After that, the java folder will appear to the project explorer.
I've faced a similar issue: I could see my java directory in the Android view, but not in the Project view. I finally managed to fix it by going in the menu: File > Sync Project With Gradle Files.
Hope it helps someone.
Your top-level project in Android Studio should show the absolute path of the directory on your machine. Look in the Project perspective (not Android perspective). Like D:\workspace\myproject. Go ahead and navigate into that directory with file explorer on your machine, and make sure that its java sub-directory contains classes!
If you are using a library project , then you need to add below lines in gradle library level
android {
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
and you need to change the word kotlin to java according to folder name you already have.
Related
See update below
I recently changed my android project in android studio from one folder to another in Dropbox. Now all of my references to my res folders are dead, despite the file being intact. I tried cleaning, rebuilding, and invalidating. Still - these issues persist. Have a look, will you?
All red-marked areas come with this code...
Cannot resolve symbol '#string/app_name'
Validates resource references inside Android XML files.
And here is a screenshot of the marked areas:
Despite that I have a perfectly intact res folder and strings.xml file.
What could be going so wrong? All I did was move my files! I moved the whole folder, nothing more!
Should I go back to eclipse? All was working so well before. Any help would be greatly appreciated. If this is a duplicate, I am sorry - I tried several solutions to similar problems as mentioned before but to no avail.
Thank you and if you need more information please advise.
By the way here is the package explorer:
As you can see the manifest and res sources are all there.
UPDATE
The problem was found to be with the build.gradle file under app. With a simple addition of a line:
compile 'com.android.support:appcompat-v7:19.1.0'
the gradle was reloaded by Android Studio and the project fixed, all proper references recognized. Thank you to the answerer!
You have to add the following dependency in your build.gradle (Module App)
dependencies{
compile 'com.android.support:appcompat-v7:19.1.0'
}
It should solve your problem.
In order to ignore gradle error while importing Android Studio Projects, follow the following steps:
Suppose you want to import a project Named: MyProject1
Copy the Project from its directory and paste in an empty folder (MUST BE EMPTY).
Make sure you have closed the MyProject1 from Android Studio by clicking Files>>Close Project
Click on the Open an Existing Android Studio Project
Locate the new directory, where you have pasted the MyProject1 folder.
Recheck if "MyProject1" folder itself contains the "MyProject1" folder then it will not work.
Now select the MyProject1 folder and go ahead.
It will start the gradle build.
After successfull build the you can start refactoring.
NOTE :You have to copy the folder that contains the following files only:
For my case I am importing Bdjobs Projects.
I have just imported my eclipse project in android studio. it keeps my saying that
Error:SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
I have seen some tutorials of editing local.properties files but it didnt work. here is my project.properties file:
sdk.dir=E:\\Mod Eclipse\\adt-bundle-windows-x86_64-20130219\\sdk
Actual directory of my folder is :
E:\Mod Eclipse\adt-bundle-windows-x86_64-20130219\sdk
A quick note about this if trying to run a Facebook sample and this error pops up, make sure you select the build.gradle file in the root of Facebook sdk, for all the samples when 'opening an existing project'. I got this error when I tried to open the gradle for just the Scrumptious sample from the 3.22 SDK
If you are sure that you have assigned correct SDK path in project settings,
and you can see it in local.properties as well, but still getting this error then there are chances that you are missing something in you project.
I was getting the same error after looking in to my project I found settings.gradle was missing.
and then add following script to your apps build.gradle
You will not face this error any more. It worked for me may be gradle set up was the blocking issue
My problem was:
I cloned a project from github
I clicked open existing Android Studio project
I chose the path of the inner sample app instead of the containing folder.
So what you should do is:
close the project.
click open existing Android Studio project
select the parent folder instead of the sample app.
You should also change it on Project Structure.
Close the current project and you'll see pop up with dialog which will then proceed to Configure option.
Configure -> Project Defaults -> Project Structure -> SDKs on left column -> Android SDK Home Path -> give the exact path as you did on local.properties and select Valid Target.
There you go.
The simplest solution sometimes is just do the File -> Invalidate Cache / Restart.
If it does not help then go for the more complicated stuff, as suggested in other answers
You can add a local.properties with to set the sdk.dir like sdk.dir=/Users/roofe/Library/Android/sdk.
But please note below, which is very important,
add the local.properties to the uppermost path of the project. Here the uppermost have some difference with root path of a project.
For example in the below project, I just use the ijkplayer-example, but this module also used other module with different cpu architecture.
If I only add local.properties to ijkplayer-example will not work. Here will get sdk location issue for other module.
While I can add the local.properties to the ijkplayer directory, then when I try to open the ijkplayer-example project, there will auto create a local.properties for ijkplayer-example, and everything works well.
In my case, it was a fresh install with checkout from github.
Just close the checkout window.
Create a new project (not from git, just a fresh one).
exit the project.
checkout whatever you like
Its just the fastest way that I found.
So I had the same issue, and none of the answers given previously helped me. What I did was check for new API updates (in my case, I updated to API level 23) and the problem was fixed.
Sync project with Gradle files, It will modify the project's local.properties file.
In Android Studio, I just clicked on File and then Choose Project Structure or Ctrl-Alt-Shift+S. This'll clearly show you the Android SDK location and an input box where you can browse to the correct one if it is not correct.
I add just local.properties file where my project is located. In local.properties:
sdk.dir=C\:\\Users\\dglig\\AppData\\Local\\Android\\Sdk
such kind of path is there which is our Sdk path.
So just create local.properties file manually and inside this just copy the Sdk file location.
Probably local.properties file missing.
Copy a local.properties from an existing file and add it to your current project. That worked for me.
I installed the SDK again (from here for example :
https://www.mediafire.com/file/azbsqg6dmg7z7np/Sdk+tools+for+android+studio.rar/file
& it created the directory & the packages, after installation.
Now I open android studio & everything is normal.
Everything posted so far was helpful in an overall learning capacity. However, most of the time, fixing one problem created others. What ended up working for me was completely deleting the GitHub project .zip file and any unzipped files. Then I made sure the correct .zip file was re-downloaded and unzipped. When it came time to open it in Android studio, I noticed there were 2 folders with identical project file names, one being contained in the other. The first (or upper) one is actually the .zip file. Open the other one!
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.
I follow all the necessary steps for Android Studio installation. I also checked this question, but still facing the same issue.
But whenever I create any new project, following screen come. I couldn't found any project structure as I can see in Eclipse.
Here, I can't find any "src","res" or any file structure. Any idea, how to get proper Project Structure?
when I tried to add "New Module" following error comes to submit.
No message
java.lang.IllegalStateException:
at com.android.tools.idea.wizard.NewModuleWizard.onFailure(NewModuleWizard.java:159)
at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$3.execute(ExternalSystemUtil.java:340)
at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$4$1.run(ExternalSystemUtil.java:364)
at com.intellij.openapi.progress.impl.ProgressManagerImpl$TaskRunnable.run(ProgressManagerImpl.java:493)
at com.intellij.openapi.progress.impl.ProgressManagerImpl$6.run(ProgressManagerImpl.java:304)
at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:185)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:226)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:175)
at com.intellij.openapi.application.impl.ApplicationImpl$10$1.run(ApplicationImpl.java:695)
at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:458)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
at com.intellij.openapi.application.impl.ApplicationImpl$1$1.run(ApplicationImpl.java:154)
When I go to Edit Configuration, can't create any module due to above error.
Go to File > Project Structure > Project Settings > Modules.
Click on the green colored + and add new module.
select Application module and set the content root to your project module.
Click next and then finish.
This should do the trick and the complete project structure will appear.
It worked for me.
Change the SDK to a level that you have installed in the SDK manager. The SDK manager can be accessed from Tools -> Android -> SDK Manager. For me, Android Studio was packaged with API Level 17 but the new project wizard tried to target API Level 18.
When something like that happens to me, to fix it, I go to
File -> Project Structure -> Modules, click (+) to add a module.
To import the main module you have to search for the IML extension file to load the project structure configuration again (for example app.iml), and thats all. I hope it helps.
Kip2's solution worked for me with a slight variation:
1.) File -> Invalidate Cached/Restart..
once android studio restarts:
2.) File -> Sync Project with Gradle Files
Just doing "File -> Sync Project with Gradle Files" (or doing "File -> Sync with File System"), did not correct the problem. I had to invalid the cache first, and then sync the project with gradle files for the project to display properly.
Finally find solution.
Whenever Android Studio starts, it search for "Gradle" installation. If not found, it will download new version of it and cache it here.
C:\Documents and Settings\user\.gradle\wrapper\dists\gradle-1.6-bin\72srdo3a5eb3bic159kar72vok
Here 72srdo3a5eb3bic159kar72vok directory name may be different.
What you need to do is, download gradle-1.6-bin.zip, place it in above directory. Then decompress it there. But make sure your path should like below.
C:\Documents and Settings\crathod.SOLUSOFTINDIA\.gradle\wrapper\dists\gradle-1.6-bin\72srdo3a5eb3bic159kar72vok\gradle-1.6\bin
Now, when you restart your Android Studio, Gradle will be initialized and Project will opened in Full Project Structure.
Modules or the project structure could also not appear because you're in a branch where *.iml files are missing. This happened for me when I was migrating from Eclipse and had decided to check back into the original branch that had the Eclipse-like project structure. What solved my problem:
Checkout the branch with Android Studio-like project structure
File -> Invalidate Cache & Restart
Also, make sure that the root iml file matches case with your root folder. Incorrectly named iml file will cause such problems.
Just delete the root iml file (you can backup if you like), close the project and re-open it. Android Studio will generate the correct iml file and the project structure will be restored.
This is tested on Android Studio 2.1
Before:
After:
I got the java folder (src folder) and others.
Solution:
File > Sync Project with Gradle Files
Android Studio Version: 3.2.1
Note: This case did not appear on the old version. For example, 1.5.1 (2016/03 before)
Keywords:
file explorer
file structure
file hierarchy
file system
folder & file list
project explorer
project structure
project hierarchy
disappear / gone / did not see
Android Studio bug / issue
simple way to restore
Delete the project hidden .idea file and .gradle file and restart your project this will fix your issue.
I deleted the app from the list of apps when you open Android Studio, then I reimported the project.
For Android Studio 2.2, you can simply click the left bottom and then select Project
In Android Studio 2.3.1, you don't have the Application module option if you wanted to add a module. The best solution is to right click your project and select "Jump to the source" from the menu. That solved my issue.
I have an Android project developed on Eclipse (GNU/Linux) that I last touched half a year ago. I am trying to import the project into Eclipse 3.6 on Windows (with ADT installed) installed using File -> Import Project in Eclipse. When the project is imported, I see the following error twice on the console:
[2010-12-10 02:17:12 -
com.android.ide.eclipse.adt.internal.project.AndroidManifestHelper]
Unable to read C:\Program
Files\Android\android-sdk-windows\AndroidManifest.xml:
java.io.FileNotFoundException:
C:\Program
Files\Android\android-sdk-windows\AndroidManifest.xml
(The system cannot find the file
specified)
Why is Eclipse looking for AndroidManifest.xml on the Android SDK path? The file actually seems to be in the project's directory. How do I fix this problem and get the project to compile?
A simple solution is to either reimport the AndroidManifest.xml file or make a change to the file and save it. This worked for me.
If you see an error about AndroidManifest.xml, or some problems
related to an Android zip file, right click on the project and select
Android Tools > Fix Project Properties. (The project is looking in the
wrong location for the library file, this will fix it for you.)
from: http://developer.android.com/resources/tutorials/notepad/notepad-ex1.html
The way you are importing the Android project into Eclipse is wrong. The Correct way of doing is File -> New Android Project. In the Contents Tab in "New Android Project", select "Create project from existing source" and choose the Build Target. That should fix your problem.
It appears that this error is produced because Eclipse thinks the default location for new Android projects is the Android SDK path. Even if the project location is changed, the error fails to be resolved, so the trick is to change the project location before Eclipse is aware of the condition generating the error.
To circumvent this quirk I imported the old project with the following steps:
File -> New -> Android Project
Un-check 'Use default location' and browse to project root directory.
Click 'Create project from existing source'
It's important to do step (2) before (3) otherwise the error persists and prevents running the project.
I had the same problem, all of the above did not work. I cleaned the project and it worked.
Instead of using File ---> New Android Project --> "Create project from existing sources", which will result in the error your are seeing, choose "Create project from existing sample" and choose it from the drop down. This will work.
Experienced JAVA developers tend to go with the first option which is normally there and works for classic Eclipse projects. But this is not your typical project and I bet the Google developers put this special case in the wizard to accommodate the differences.
I had the same problem. I was trying to compile the JakeWharton view page sample, so I checked out the GIT in a directory in a different folder then the workspace which caused the problem.
Eclipse was maintaining 2 folders:
1. A new workspace folder was made under the workspace directory, which eclipse checks for libraries and others source code including the AndroidManifest.xml file
2. The existing folder which was not under the Root workspace
To fix the problem after importing I had to manually move the files in the new workspace folder created by eclipse.
I met this problem when using Facebook SDK, now I solve it by doing this:
Close the project;
Copy "AndroidManifest.xml" file to the project's root path;
Open the project and refresh it, it's Done!
this worked for me by the way:
I changed the project name to the exact name of the project that I am importing.
Eclipse seems somewhat fragile in its naming conventions. One of the causes for this error is a difference between the project name and the folder name in the workspace. I imported a zip file for a project named "HelloDialogs" into a workspace folder named "HelloDialog". This caused the "AndroidManifest.xml file missing" error. Once I renamed the folder correctly, everything worked fine.
Because of the multiple different answers here, I thouhgt I'd add yet another one that worked for me, as I had exactly the same issue when first working with Phonegap android dev tools.
So I found (as mentioned by Gintautas in comments to the accepted answer), that I had to create a new project using the phonegap 'create' script, then when importing the project into eclipse. the only way to get this to work successfully was if the project was originally created in some temp folder somewhere other than the place I actually want to work with it.
So I created a project in windows like this in a cmd window...
c:\phonegap\phonegap-2.6.0\lib\android\bin>create.bat c:\temp\android_boilerplates\test app.test test
Then I imported the project in eclipse like this...
File > New > Project
Within the new project wizard select: "Android Project from Existing Code"
Click "Next"
Now navigate to the temp location of your project and set that to the root directory, check the project you want and check "Copy projects into workspace" as the example below...
Click "Finish"
And that's it, Eclipse should copy all your project files into your workspace and there shouldn't be any errors in your project (fingers crossed).
Your project should look something like this...
Hope that helps, it took me an age to work out why Eclipse didn't like creating a new project from existing code when the new project was being setup in the same place as the existing code. This isn't a problem for other languages I've used, so it was a little weird, but understandable as Eclipse (I'm guessing) seems to want to overwrite certain files.
Eclipse randomly decided to make another folder instead of the one that i had specified, but doesnt have any resources or data or layout etc in it..
it has some conflicts i guess..
anyway, a noob approach to this was, copying the original file to some other location(i put it to desktop)..
now create new project-create existing project, select this one from desktop, n VOILA.. its all fine.. :D
I am a little late to this game but I caused this same problem by generating the initial application into the exact location I was going to work on it. That is to say I put it directly into my current workspace. I then did File, Import, Existing Android Code Into Workspace. The import process blanked out my android.xml file.
I tried above solutions and had no joy. I then generated the initial application into a temp directory and imported from there. This worked for me.
The only way to import a project into eclipse workspace is to create an empty project and then drag and drop all the folders and files into this project. Why is this so is beyond me.
The answer from Raunak is wrong.
I found a .classpath file in the root directory of my Android project. I opened it and updated the file paths in it, and it seemed to fix the problem for me.
I had the problem when I tried to update an old project with recent code from the SVN. I had the Manifest.xml exported to my local file system as backup and deleted it. I've then reverted my complete project to the most recent version from the SVN and then it worked :)
This is what I had to do to get this to work. Fortunately I had backups of earlier "project".
1) Import the project as usual.
2) If the errors with empty xml etc. comes up, close the project.
3) Go to the original project if you have backup.
4) Copy all of the projects root files and directories and paste it over where Eclipse expects the projects root directories and files to be.
5) Open the project and refresh. Make "Clean" if necessary and you're done!
Always make backups because Eclipse f--kups! I learned this the hard way when suddenly my Android project refused to work because of empty manifest-file.
Sometimes if you automatically fix imports in MainActivity IDE imports android.R class instead of one that will be generated for the project. Remove the import and recompile.
when importing project from another workspace add existing project in workspace. and tick to the copy projects in workspace.then check the api level and supporting library from project.properties files.then rebuilt project and clean it.. it is works for me.
2017 Solution: Much Easier and tested solution is to remove your application folder from elipse project only then Import it again and the problem will be fixed immediately!