Where the JDKName is coming from? - android-studio

I am using several computers to work with my android project. Every time I am checking in my updates to GitHUB I see several files where updated even though I did not really update them, namely the *.iml files and .idea/misc.xml file. What changes is the value of the jdk-name attribute. While checkin ig from one computer it is '1.6 (2)', while from another it is just 'JDK'
My understanding is that something in the setup of JDK is different between my 2 computers. So what is different and how do I fix it?

The JDK names are maintained internally in Android Studio; this is different from IntelliJ where you edit them through the Project Structure dialog.
It's not intended that you check .iml files or anything in the .idea folder into source control in Android Studio. The Gradle build files are the source of truth for project structure.

Related

Validating Subversion Android Studio Project Build: New Project from SVN

Given an existing Android Studio (4.0.1) project that builds and deploys properly and that has an associated SVN repository, I would like to create a separate Android Studio project and get that to also build properly. The purpose is to 1) Prove that the SVN repository is complete (has everything needed to get a build working), 2) Document the steps required to get this Android Studio project out of SVN and building.
Selecting Get from Version Control from Android Studio's welcome screen, I can specify the SVN repository and checkout:
Take the default/latest format for SVN:
And indicate I'd like to make a project out of the contents of the SVN repository:
Then I'm presented with an option that I'm unsure how to answer:
I have tried them all, none successfully. Rather than go into the details of each here, I would like to learn about which option makes sense in which situation.
The original project was created 5 or more years ago with Android Studio's 'start a new project' wizard. I've use Android Studio's default build stuff all along, and upgraded Android Studio and the various plug-ins when nagged sufficiently. I'm not sure what the important build artifacts are (or artifacts critical to a clean import are), and if those artifacts are indeed in the SVN repository and up to date. I can copy the project in the file system and rename things to get it to build, but creating another instance is not the question; the source must be exclusively the SVN repository.
I'm eager to make this question complete, so please do me the favor of specific criticism in the comments so I may improve the question or remove it, as needed.
The optimal person to answer this question would know much more about how Android Studio builds work than I do. I have strictly "cookbook" level knowledge. So without significant study, I am unable to validate intricacies of the process without more knowledgeable people to help.
The last Import Project dialog from this SO question only appears if the contents pulled from SVN are not a complete project.
In other words, if what gets pulled is a complete project, the project just opens, without having to go through any other questions and/or selections. Otherwise, other logic takes over and Android Studio tries to create a legit project for you from the bits it finds.
The solution is to make sure that the check-in from the original working project is complete, including gradle files. If Android Studio is set to view the "Android" artifact view, then everything in the list should display in the VCS "included in source control" and "checked-in" font color.

Android Studio has lost Run Configurations

Android Studio lost all the run-configurations of a project and it is not the first time this happened. This always occurs (as far as I can tell), when switching projects and/or having opened an Android project in IntelliJ IDE.
In an attempt to restore them, I've reverted several missing .xml files from the .idea directory, including runConfigurations.xml, which did not yield the desired result. the documentation does not really help either.
Q: Where are these run configurations being stored, (in order to keep a backup of them)?
As described in Run/Debug Configurations Dialog documentation when: Share check-box is enabled Run/Debug Configuration files are stored under .idea/runConfigurations/ directory.

Android Studio not detecting my module

I cloned my repo and now Android studio (1.3.1) is having hard time detecting my module 'app'
It is not showing any module in edit configuration(as in image below).
It's already defined in 'Settings.gradle'
include ':app'
I tried importing this app module but it says project already contains module with this name
Tried other solutions too. Stuck here.
Note: This repo doesn't have .iml file of project.
Had a similar issue with Android Studio 3.5.3.
Deleting .iml and local.properties files along with .idea and .gradle folders before reopening the project fixed my issue.
Different SDK installation worked for me.
How I came to know?:
(Meanwhile 2 days passed in this issue, I tried all possible solutions like adding facets, adding modules etc. (I came to know it is working in other collegue's machine ) But they didn't work, So last option for me was fresh installation of Android Studio. So I...)
1. Installed Android Studio 2.2.3 with different sdk location unknowingly(Let's say loc2).
2. It was working, later I made batch update to 2.3.2. After update, I chose project location as sdk location (Lets say loc1 ). This time it din't work and I got same error. This was a moment when switching to loc2 worked!!

Change the subversion commit location for a copied project in android studio

I have a project which i have copied from a different completed project,and refactored the package name. after the refactoring and sync was complete android studio asked me whether i wanted to add the newly created files to subversion. i remembered that my previous project was shared through subversion. so i went ahead and disabled the vcs integration for my current project to prevent any accidental modification to my previous project. but now whenever i enable vcs integration on my current project, i am not able to share it as a new project through subversion. i think android studio is holding onto the url of the previous project. so my question is how can i change this? i want to share my newly created project as a new one through subversion. how can it be done?
i remember when i used eclipse, i was used to deleting the CVS directories from my newly created projects which are copied from other ones, and it worked flawlessly. is there any way like this with android studio?
thank you.
I got my answer eventually. the trick was to delete the .svn directory hidden in the root folder of my project. deleting that directory gave the prefect result. and i was able to share my project as a new one through subversion.

What are .iml files in Android Studio?

What are .iml files in Android Studio project? I read that it is configuration file for modules. I do not understand how it works, and can't I just use gradle scripts to integrate with external modules that you add to your project.
Also, most of the time AS generates them, so I cannot control project behaviour. If I have a team that works in different IDEs like Eclipse and AS, is it possible to setup my project so it's IDE agnostic?
I don't fully understand how this system works.
What are iml files in Android Studio project?
A Google search on iml file turns up:
IML is a module file created by IntelliJ IDEA, an IDE used to develop Java applications. It stores information about a development module, which may be a Java, Plugin, Android, or Maven component; saves the module paths, dependencies, and other settings.
(from this page)
why not to use gradle scripts to integrate with external modules that you add to your project.
You do "use gradle scripts to integrate with external modules", or your own modules.
However, Gradle is not IntelliJ IDEA's native project model — that is separate, held in .iml files and the metadata in .idea/ directories. In Android Studio, that stuff is largely generated out of the Gradle build scripts, which is why you are sometimes prompted to "sync project with Gradle files" when you change files like build.gradle. This is also why you don't bother putting .iml files or .idea/ in version control, as their contents will be regenerated.
If I have a team that work in different IDE's like Eclipse and AS how to make project IDE agnostic?
To a large extent, you can't.
You are welcome to have an Android project that uses the Eclipse-style directory structure (e.g., resources and manifest in the project root directory). You can teach Gradle, via build.gradle, how to find files in that structure. However, other metadata (compileSdkVersion, dependencies, etc.) will not be nearly as easily replicated.
Other alternatives include:
Move everybody over to another build system, like Maven, that is equally integrated (or not, depending upon your perspective) to both Eclipse and Android Studio
Hope that Andmore takes off soon, so that perhaps you can have an Eclipse IDE that can build Android projects from Gradle build scripts
Have everyone use one IDE
Add .idea and *.iml to .gitignore, you don't need those files to successfully import and compile the project.
They are project files, that hold the module information and meta data.
Just add *.iml to .gitignore.
In Android Studio: Press CTRL + F9 to rebuild your project. The missing *.iml files will be generated.
Those files are created and used by Android Studio editor.
You don't need to check in those files to version control.
Git uses .gitignore file, that contains list of files and directories, to know the list of files and directories that don't need to be checked in.
Android studio automatically creates .gitingnore files listing all files and directories which don't need to be checked in to any version control.

Resources