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.
Related
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
Following some links here I tried to rename a project. I went to c:\path\to\AndroidStudioProject and renamed the folder there, then found the .idea file and changed that. Now the project loads but java files are missing! However, on clicking java (in the bar at the top), then com I can see them each with a small red j.
I then looked in module Gradle build where there were 3 files, one with the new name and 2 older ones which stated that they did not belong so I deleted them, copying the compile info into the new one. Naturally on doing a Sync Now I get a bunch of errors.
Why does this have to be such a complex operation? Can anyone assist?
After you rename the folder, open the project in Android Studio. From there, right click something that needs to be renamed (e.g., module, package names, etc.) and use Refactor->Rename from the context menu. Keep doing this until everything that can be refactored is.
You will need to manually change the value of applicationId in the app-level build.gradle. Obviously, things like #string/app_name will also have to be changed manually. I recommend making these manual adjustments from inside Android Studio rather than directly editing the files. That way you'll know immediately if you break something.
I am unable to see the folders that are physically existing, this is the case.
But in actual fact I have other folders as welll
So what can I do?
Above your the file directory view in Android Studio is a drop down which currently is most likely set to Android. Change it to Project and you should be able to see all your files.
I tried the all the approaches mentioned above but can't fix rather than fix it by a hardcore approach -
Step 1. Close your Android studio.
Step 2. Delete .gradle and .idea folder from your project directory.
Step 3. Open your project and you will see the files again.
go to View menu then click tool window then after click on project
view->toolwindow->project
it worked for me
for me doing the following works:
from menu go to: View--->tool windows ---> Project
then click the little gears icon (settings) you will see an option to change the empty middle packages. it looks like this:
disable "Hide Empty Middle Packages" under the Project View settings dropdown and then it should make everything show up.
If anyone ever does what I did maybe this will help:
Android Studio does not like it when module names begin with a number. I was learning from some tutorials and named the first module "1-name" and the next one "2-name". Setup was fine and it ran, but only the "Gradle" Scripts entry would show in the navigation window in "Android" mode.
I have checked out a cross-compilation project from SVN on Eclipse (on a Linux system). I am unable to open a functions declaration from the functions's right-click context menu (or by pressing F3). Upon research, I found out I don't even have anything like Index -> .. in the project's right-click menu. I have tried a lot with the Preferences -> C/C++ -> indexer but no useful results. I am not using Eclipse to build it but there are no errors since I can build it using makefile
PS: Though there are a few questions with the matching title, but none of them helped me
Here is the solution found after a million attempts. The project should be checked-out as C/C++ project, by selecting import using new project wizard.. The index will NOT be available in the SVN projects checked-out directly. Hope it saves some one's time
Eclipse Kepler SR2 on Windows 7 here.
Faced the same issue, the following sequence of inputs made it work for me:
Import...
"Checkout projects from SVN."
Select branch etc.
Check the "Check out project configured using the New Project Wizard" radio button.
Select "C/C++ -> C Project."
Pick a toolchain, doesn't matter which if you use an external one.
Now you can right click on the project (once fully checked out) and rebuild the indexer.
I am using Indigo and solved it as follows (without checking out again!)
Right click on project in question and select New->Convert to a C/C++ Project
After selecting toolchain, indexing gets built automatically.
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