I have created a dummy Android project from within Android studio, and I can make it run, but the Editor itself fails to find the R class. In fact I can't find the gen folder. I thought that maybe that folder should be added as a source folder or a classes dependency, but I just can't find it.
Can anyone help?
#joe_deniable gave me the idea to look closer in the build folder, and I found a folder that had been excluded by intellij, where my R was happily having an ice cream. This was here:
build/source/aidl/debug
I had to remove this folder from the exclusion list and add it to the sources, and could finally start coding in this new IDE.
Thanks
The folder layout is different to eclipse. I don't think there's a "gen" folder. My "R" file is in the following location:
(module name)/build/source/r/debug/(package name)/R.java
I think this file is created when you create a new project using the wizard.
I had the same problem on linux. I've resolved it installing ia32libs and rebuilding the project. The R class is generated from android.
you can find it in the directory app/build/generated/source/r/debug/package name.
Another possibility is that the package you used has some issue - the target package is not the same with the defined one. In turn, R can not be found in the package.
Goto to Top right corner in Studio, click on search button enter R.java , you will get the file
thank you
Related
When using android studio's refactoring tool refactoring -> rename to change file names or file paths it does not change the corresponding imports.
In Android projects this happens automatically, but when in a flutter project name changes of files breaks all classes importing the renamed file.
Is it possible to fix this?
I found the source of my problem.
Search for references and Search in comments and strings were unchecked.
Checking search for references solved the issue.
To rename files in Android Studio and changing the references of that fil in the code use Refactor > Rename on the file itself.
Just check the Path of your main.dart file. Correct it like ..\HomePage\\main.dart it will work.
In Android Studio, project.gradle file is not show when in Android View, but is when in Project view
Android View
Project View
How can I fix this ??
From the Gradle Tool Window in Android Studio (View > Tool Window > Gradle),
Right click on the the project's Gradle config with (root) next to its name.
Click on Ignore Gradle project,
and right click again then click on Unignore Gradle project.
The trigger to this 'buggy' phenomenon actually lies outside your project folder.
Assuming a project name of 'SilverBirch', try this:
(a) Close the project in Android Studio 3.0.1.
(b) Rename your project folder (inside the workspace folder) to 'SilverBitch'
(c) Re-open it via Android Studio (you obviously can't do so using 'recent projects')
(d) You should get a window titled Import Gradle Projects with text that reads: The modules below are not imported from Gradle anymore. Check those to be removed from the ide project too:
(e) Tick the (old) project name and click OK.
(f) At last your 'Android' view shows build.gradle(Project:SilverBitch)
(g) Repeat whole process, renaming back to original.
Alternatively, if you're insane, do this:
Locate the project.dat file AND folder for your project - it will have a path that looks something like this (assuming Windows)
C:\Users\<userid>\.AndroidStudio3.0\system\gradle\Projects\5be1ee38\project.dat
[The system-generated hex-string container name will vary, but the file is always project.dat]
The first line of this file references the 'missing' build.gradle and will clearly identify the owning project.
Delete the file AND its containing folder then re-open the project via Android Studio.
Because googling 'project.dat' yielded nothing, and because I made a rude assumption that this contained only system-generated data, and because I couldn't resist 'seeing what happens' I actually deleted
the entire Projects file [C:\Users\<userid>\.AndroidStudio3.0\system\gradle\Projects]
So far, so good - no serious side-effects yet! Maybe those plugins needed re-specifying anyway? etc.
Close Android Studio -> Remove project .idea folder -> Open Android Studio -> Open your project. This worked for me!
NOTE: when you remove .idea folder you will also lose project related preferences (such as XML code style for project)
Right Click on "Gradle Scripts"
Click Load/Unload modules
Load unloaded project module
Done
In my case, I found that my project.iml located in project/.idea
So I move it to project/
and change one line like following:
<module fileurl="file://$PROJECT_DIR$/My_Project.iml" filepath="$PROJECT_DIR$/My_Project.iml" />
the old one should look like this:
<module fileurl="file://$PROJECT_DIR$/.idea/My_Project.iml" filepath="$PROJECT_DIR$/.idea/My_Project.iml" />
After that, go back to android studio, every thing seems perfect!
This worked for me:
In your root project folder, open the *.iml file, and make sure that the value in module external.linked.project.id=, the *.iml filename, and the project directory name are all the same.
Now my build.gradle (Project: X) shows.
This worked for me.
Simply go to your AndroidStudioProjects Directory.
Search for your Project
Rename it with some other name
Strat your Android Studio, and then Import Project (Gradle, Eclipse ADT, etc.)
mode. let the Gradle Build Finish.
And that's it.
FIXED IN AS 2.2.1
After update Android Studio to the 2.2 I've got this problem. It's hard to use such format with a small 13-inch display.
In Project view and Android view I get folders name as full packages name but I want to see just names of the directories:
I tried to search for this problem, but I only find "Compact empty middle packages" which impact only for a top level folder.
"Flatten packages" option creates tons of the directories, for every package making everything even worse:
One more screenshot:
In the Package/ Project or Androidview etc, Go to the gear icon on the right side and uncheck Flatten Packages and Compact Empty Middle Packages. This should show you the break down by directory instead of flattening it.
Note: This has now been fixed in Android Studio 2.2.1
AOSP - Issue Tracker:
Project structure view is showing full package names for sub packages when data binding is enabled.
https://code.google.com/p/android/issues/detail?id=222914
Check this configuration if Flatten Packages is not your desired solution:
Hope it will help
I have a trouble to add a package under one of the flavor folder in Android Studio: after I right click on the java folder and I could not see the 'Package' or 'Java Classes' options there!
I did exactly the same for another flavor and it was fine.. Now I am stuck here, without knowing if it is a bug in AS or I did anything there. Anyone help me please!
(I googled it and did not solve it with what I have found so far)
=======EDIT========
I close the project and create a brand new empty project, now even in the main folder I cannot find the 'Java Classes' or 'Package' when I right click on the java folder I added.
However, if I just create the folders of the package under java with a class there, and do a build, it will finally recognize that and make java blue color and then I am able to see the menus if I right click the blue java folder.
So it sounds like some bug in AS.
It might just be the build flavor you are currently selected correctly to enable that flavor.
If we have two build flavor let's say free and pro. If pro is selected is current build flavor. The flavor free will not be shown as java package in blue color as you mentioned, it will be shown as directory structure. Hence change the build variant and make it workable.
Not sure if you faced the same issue, but sharing it for reference of others who might face this issue as i faced now.
Package option is available only for selected flavor. switch to desired flavor and IDE will refer that source directory and will convert it to package and directories from other flavors will be listed as normal directories tree structure.
I found this Solution.
File > Project Structure > Select the lib folder > Click on Sources > Apply and Okay
Now you can see the new package option by right clicking the lib folder, the new package option will be shown.
Step1
Step2
Step3
Control click (mac), or right click the /java directory and select Mark Directory As -> Source Root. You should then be able to right click the /java directory and select -> New -> Package. Your java directory will also appear blue.
Solution. File- Project Structure- Modules- Right click on lib - Select Sources.
then the option "Package" will appear on your list.
I am getting this warning on assembly references in a VS2012 Winforms application project. In this case the references are for Infragistics controls used by the app, which are located in the bin folder.
This issue has been addressed in the following link, but the answer ("set the Build Action" property) doesn't work because there is no Build Action property in VS2012 for referenced assemblies.
VS2005: Assembly '<assembly>' is incorrectly specified as a file.
What's the fix?
You probably refer to the wrong Assembly.
You need to "set the Build Action" for the Assembly which located in Bin folder, NOT from references.
Go to Solution Explorer > Expand the Bin folder, right click on the
Assembly that give warning, and you should be able to set the Build
Action
Again, it is not the assembly that located in the References panel but it is from Bin Folder
Have you tried removing the references, saving the solution and exiting Visual Studio - then re-opening the solution and re-adding the references?
The problem is almost certainly lurking in the project file (.csproj if this is a C# app) if you fancy opening it up in a text editor and having a look - might also help if you were to paste it here.
Alternatively, have you tried recreate the project from scratch? May be a quicker solution than trying to work out what's happened.