I opened my Studio today and Android Studio didn't recognize Kotlin files. .kt files started showing up as just an ordinary file. I checked my Plugins and I still have the Kotlin plugin. I tried uninstalling and installing it again. But no use.
I tried building my building my project from Terminal and it works fine. But Android studio doesn't understand Kotlin files.
Configuration:
Android Studio 3.1
Kotlin 1.2.41
OS: MacOS Sierra
Go to Library/Preferences and delete the AndroidStudio3.1 folder. This is the config directory for my Android Studio.
Once deleted, I started Studio again, and the config was created fresh. Now everything worked perfectly.
Update Kotlin plugin:
Go to
menu
preferences
plugins
find Kotlin plugin
update
I got this problem too, after upgrading my Android Studio from 3.1.4 to 3.2.1
And I have followed #Evgenii Vorobei step, found no "Update" button available just install and uninstall.
So I go to the root project build.gradle file update the kotlin_version from 1.3.11 to 1.3.21, sync project then restart Android studio
This is work for me
Update:
You also can update the plugin with Tools > Kotlin > Configure kotlin plugin update
I already had kotlin configured and could see the files in the "Project" view but could not see them in the "Android" view. When in "Android" mode, if you can see the File->new->Kotlin File/Class in the File Menu, create a new Kotlin file. When I did this, the new file appeared in the menu along with the other file I had copied in place.
I also had the similar issue, but in my case it was due to misc.xml file.
Android studio had added below line in misc.xml file
<component name="ProjectPlainTextFileTypeManager">
<file url="paht_to_file_not_being_recognized" />
</component>
after removing this line, everything worked perfectly. If you refactor -> rename file but then also the issue persist, this can be a possible reason.
I got the same problem when accidentally .kt file type association was moved to Text file from Kotlin.
To fix this remove *.kt from Text and add under Kotlin (if not present)
More info on it from jetbrains issue tracker
Lets say, I'm creating new file named HomeFragment, and AndroidStudio didn't recognize it as kotlin file. Fix Steps:
AndroidStudio -> Preferences -> Editor -> File Types
Click on File type auto-detected by file content, make sure this sections doesn't have prefill File name patterns - HomeFragment, if it does, delete it.
Click on Kotlin, make sure it has "*.kt"
Click on Text, make sure it doesnt have "*.kt"
once done, click Apply and OK
Related
This is not my project but the code runs fine. Some kotlin files show up as either R class from some random package or as XML files and have different icons. Files that show correctly have errors like Unresolved reference pointing to the files that don't show correctly but it still compiles and runs.
Android studio 3.2.1
Gradle 4.6
Kotlin plugin 1.2.51 and 1.2.71
Try these:
build -> clean project, build project
file -> sync project with Gradle files
file -> invalidate and restart
The fix to this is to open and save the file in question with a text editor like sublime text or notepad. I'm not sure if this is a bug with android studio or what but I can't submit a bug either way since I doubt this is reproducible. If anyone else is experiencing this, I hope this workaround works for you and thanks for everyone who helped, have a good day.
I've found some webpage but it does not guide me back to normal android project view.
http://developer.android.com/sdk/installing/studio-androidview.html
I did File => Other Settings => Default Project Structure => Default Settings => OK It make even worse, import library become not function-able.
I also had this problem (creating new project also looked similar to IntelliJ IDEA), got it fixed when I enabled some Android-related plugins.
Go to Preferences (Settings on Windows and Linux) > Plugins and enable Android Support, at a minimum.
Now you will have "Android" option in the Project View.
Try:
View -> Tool Windows -> Project OR the shortcut is alt+1.
If that's not working try:
Window -> Restore Default Layout OR the shortcut is shift+F12.
Also, check that Studio is up to date:
Help -> Check for update...
None of the above solutions worked for me so I fixed this by removing the .gradle and .idea folders from my project.
The square at the bottom left corner of android studio lets you spread the screen or it populates it with side menus.
For me, it happened when I used Kotlin KTS for Gradle files, but created a java library module for this project. After trying to reimport project I got an error:
New Gradle Sync is not supported due to containing buildSrc module
Solution:
Migrate added module to kts
Remove created by Wizard settings.gradle, if you already use settings.gradle.kts
Reimport project
File -> Close project
Android Studio: import project
Show it your current project location
Just had the problem happen to me again. I got the problem solved, but unfortunately I can't confirm the solution, now that it's fix; but I have strong suspicions on what was the cause.
In my case, the problem occurred as a result of reorganizing my project directory. My projects are stored in given directory lets call it "Projects". I renamed that fold to "ProjectsBackup" and created a new "Projects" directory. I then moved selected projects now contained in the "ProjectBackup" directory to the new "Projects" directory. After moving the first project, I used Android Studio to open that project. That's when the problem occurred. I got a message that it couldn't find the gradle-wrapper and offered me the choice to create it. The gradle-wrapper is stored in a directory call "gradle" and its stored in the "Projects" directory. I had not copied that directory over from the "ProjectsBackup" to the new "Projects" directory. At the time, I thought nothing about that since, a new one was created. After trying all the various suggestion in this problem discussion, android studio offered a notification from me to update my "android gradle" plugin. I did the update and after that the "android" view was now available for me to select. The android gradle update fixed the problem.
I unfortunately, can't tell you what changed as a result of the update, nor can I tell you how you can force Android Studio to update or reinstall the android gradle plugin. All I can tell you is that I got lucky that android studio gave me that notification to update the android gradle plugin. Things like "file/project structure" and changing the Android Gradle Plugin Version, didn't fix the problem. What I did notice, was that when I first looked at that, the drop-down list of android gradle versions was an empty list. I manually put one in "3.6.3", but it didn't help. If you run into this problems I would suggest you look at the dates of the two file in the "wrapper" directory and compare those to projects you may have that are working correctly with the android view. I wish I would have checked the date of the wrapper jar file, when it wasn't working. That's what I think might have been wrong (i.e. I got a wrapper.jar file that was incompatible with my version of android studio - unfortunately I can't prove that)
problem solve i have click this button
After update android studio Build number AI-141.1809159 version=1.2 in Canary update, i can't sync gradle project and always show "Gradle project sync in progress"
Following are the steps that I use (Kind a workaround),
Edit the root build.gradle file (adding a new line to file will also
do).
Save the file.
Restart the IDE (File->Invalid Cache/Restart->Just Restart).
Gradle Sync in progress notification should go away.
I found this was due to this plugin being used in AS:
'Android Studio Unit Test'
To disable this in AS 1.2 do the following:
File > Settings > Plugins > Android Studio Unit Test disable
Problem is solved, just update android sdk, it's work for me.
This happened to me twice and had to do with one of the gradle files having a date in the future (a glitch in Android Studio it seems). That is why just adding a space to the file and saving can fix the problem, as described above. Or go through your project with the operating system file explorer to find the file.
wait for some time, if you are using somebody else repo. It depends on the projects buildings. You might see new changes like file path, project-level dir appearing, etc.
Disable VPN if you have it active.
I'm using git, and creating lots of git branches for new features on a project I'm working on. Every once in a while, I'll create a new branch off master as usual (let's call this broken-branch, and this error appears:
Android Source Generator: [demo] AndroidManifest.xml file not found
I'll create a new branch off master, cherrypick the changes on broken-branch onto this one, and everything works fine. Why do I get this error, and how can I avoid it?
This happened to me today.. I clicked "Sync Project with Gradle Files" and all went fine.
While my IDE is IDEA13 with maven. Work fine with maven in command line, while using IDEA run( shift + F10) show this error. I do as below and fix this:
1.Open .iml in the project root.
2.Find some line like:
<option name="USE_CUSTOM_COMPILER_MANIFEST" value="true" />
3.Remove this line or change value to false.
This is my work way.
May Help.
I use IntelliJ Idea and found next solution:
in the root of the project (in catalog with root build.gradle) create file settings.gradle which consist include ':app'
Than go to IDE and run Gradle - refresh.
I know the problem in IDEA because you create a new project with Java configuration (not android, but with android sdk dependency)
File > New Project > Java (Java Module) > Project SDK Android 4.X
Here is the solution :
File > New Project > Android (Application Module)
If you are using Maven, backup the project and close it. Open IntelliJ and select Open..., choose the pom.xml file and then select yes to open this project. Because there is already a project a popup should appear, choose 'Delete Existing Project and Import'.
Note: I'm using IntelliJ Community Edition version 13
When I get "AndroidManifest.xml file not found" error I clean and then refresh the project and these steps seem to fix the problem.
It happens to me when I don't have .iml file to open the project. It's very easy to fix, you just need to close the project and reopen it taking care of select build.gradle file before click open.
I hope it helps somebody.
This worked for me.
My project already had a settings.gradle file.
I simple had to add the line include ':app' . N ow i can build and do everything.
open IDE
project
|--->build automatically
uncheck it
clean the project
check build automatically opriot
I just had this problem while trying to build the swagger code gen project. For whatever reason IntelliJ thought I should have an Android facet. Removing this facet allowed the entire project to build.
If in case, you encounter an error which shows:
AndroidManifest.xml file is not found
All that you have to do is reinstall the flutter package and the error is resolved!!!
Go File,Project Structure or press Ctrl+Shift+Alt+S,
Go Facets, Select your android project, in the structure there are configuration files, folders. Image of structure tab (before)
Location of AndroidManifest file was like this:
D:\Programming\Dart Flutter Projects\tip_calculator\AndroidManifest.xml
Change the location like this.
Image of structure tab (after)
Changed it to here:
D:\Programming\Dart Flutter Projects\tip_calculator\android\app\src\profile\AndroidManifest.xml
flutter upgrade --force
Helped me.
Works for you?
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.