I have searched and have not come up with anything on how to make a 'Group' or folder in android studios that I can use to just organize my many classes instead of just having them all in the package folder.
Any way to do this?
Related
I am creating an android app using Android Studio. In the project view, apart from the main folder where all my classes are stored I also have "androidTest" and "test" folders (marked with red in the image). I did not created these folders and I believe Android Studio generated these folders. What are these folders for? Is it safe to delete them?
Yes, you can delete them (and you can delete their references from the gradle file), but why even bother? These files are just there to nudge you do the right thing.
They're like the broccoli that your mother might put on your plate even though she probably already knows that you're not going to eat them. You could refuse them and even delete them, but there is really little to no point in doing that.
If you want less visual clutter, just use the "Android View" instead of the "Project View" and don't expand those particular test folders.
These folders are created by default for testing your code
src/test - Unit Tests
src/androidtest - Android Instrumentation tests
[Read more]
Typically when I use Android studios the project files on the side bar are all nice, organized and clean; having App - (manifest, java, res, assets) Gradle Scripts -
I like when it is like that. But for some reason, every so often when I open a project, typically one that I did on another computer with Android Studios, the files come in all expanded, That is they look like they just came out of the folder looking something like this: .gradle- .idea- app -(build, libs, src, .gitIgnore, app.iml, build.gradle, progaurd-rules.pro) build- gradle- And Still more. It is messy any unorganized. Even more, my namespaces are all expanded, so when I view files I have to expand the folders way out.
Android studios when working the way I like puts the namespaces into one folder, that is there will be a folder that is called com.etc.whatever and it doesn't have to be expanded way out.
So how do I get it back to normal?
You must change your project structure to Packages. it may work.
explore the other option given in project structure.
It is fairly easy to find information on the web that android res hierarchy cannot have subfolders, and that it needs to be flat. However it is not so easy to find as to why. I'm interested in the answer to the question:
Why res folders cannot have subfolders (when developing with Eclipse IDE, as I know it can be kinda hacked around using Gradle with Android Studio)?
My goal is to create multiple android APKs. All that is different is the package name and I manually override some things in the res folder.
I understand you can do a library project. The problem with that is we have to manage multiple manifest files and the version with that. That is not what I want to do.
I was looking into aapt to create the new package name and shared res folder. The problem is I do not know where to start. I see lots of examples like:
Custom Android build.xml for rename manifest package
also below is exactly what I want to do:
http://blog.uncommons.org/2010/07/19/building-two-versions-of-the-same-android-app/
Can anyone provide direction on where to start?
The best way to do this is to create a library project, and than create separate projects for each of the APKs that you want to have. Each APK project can than have its own Manifest and reference the Library Project. Believe me when I tell you that this is much easier than trying to rename packages during build/compile time. You can easily call into activities that are shared in the library package just as long as you use the fully qualified name in the individual APK's manifest file.
http://developer.android.com/tools/projects/projects-eclipse.html
I had the same problem before and made a batch file to copy files like images, mp3 files, etc. to the workspace folder where I have my application folder in it. You have to make everything dynamic if you don't want to use the library project. I hope this helps, else you can ask me anything you want.
I have an app on the iPhone and need to port it to android. For this I would like to group screen related files like classes and xml per screen in one "screen group" per screen somehow, ideally also strings and other value files
if I use folders I can only group res files separately and src files separately.
what would be the best way?
Thanks very much!
EDIT:
If that should not be possible, how to best then solve this issue? Do you create a subfolder in the src and another in the res for each screen?
The way you group files for the iphone is not possible for an android project. Android has pre determined folders which hold specific files, if you break this structure, your building process will fail. Its not ideal but that just how it it.
When it comes to source java files, they follow the concept of packages which are basically folders. The 'src' folder is the part where you can create sub folders as you desire. If you are adamant about keeping the files related to a screen in one place, you should create the layouts with java code and not use layout xml files.
But using xml layout files make development much easier and faster. Consider that as the presentation and java files as the logic+data. So group java files as you want and leave xml files in the layout folder with easy to identify names.
android uses certain directory layout for project structures (i.e. convention over configuration). Basically you will want to put your XML layout files in res/layout directory. Please read http://developer.android.com/guide/developing/projects/index.html#ApplicationProjects for further information.
Unfortunately, there's no easy way to do this in Eclipse. You can't create custom directories in your Android app's /res directory, you can only use permitted dir-names. E.g. you can't have a /res/layout-myscreen1 and /res/layout-myscreen2. You also must put your resources in /res, and your code files in packages, so they're at separate places in your project.
You can use Working Sets to group related files together however, but they're quite painful to use IMHO. Check the eclipse docs and tutorials out on them.