I have repository in Git that has this structure:
-web-app
-mobile-app
When I checkout the project in Android Studio my project has structure like this:
android-studio-project
-web-app
-mobile-app
The mobile-app folder is folder that contains the module of my android application end when I commit some changes some files and folders like gradle/wrapper, build.gradle, gradle.properties, settings.gradle are outside the folder mobile-app and my Git structure goes like this:
android-studio-project
-web-app
-mobile-app
-gradle/wrapper
-build.gradle
-gradle.properties
-settings.gradle
-...
I want to put all files and mobile-app folder in sub-folder in order to achieve first Git structure.
I tried to create a folder in Android Studio and move all needed files there but the project totally messed up.
I moved the gradle's files in to mobile-app folder but could not build the project at all.
Any ideas how can achieve the desired Git structure?
Related
I'm trying to move my IntelliJ IDEA (2017.3) Android project to another computer just copying the files and it does not work. I am aware of this and this, but in the case of Android project it does not work. All the xml files inside .idea store paths relative to the home ($USER_HOME$) instead of project home ($PROJECT_DIR$). Oddly, Maven projects seem to generate paths relative to the project home and those ones can be copied. But not with gradle projects.
Anyone knows how to solve this ?
EDIT: Bear in mind that I want to copy ALL project settings included running configurations. I want that someone opens the project and find exactly what I have. I know I can reimport the project, but then I'll loose some configuration.
Here's the files and folders that need to be excluded from the copy (assuming that your project has a module called app), preferably if you copy the entire project folder to some where else on the same computer and then deleting the unneeded one by one:
folders .idea, .gradle or any folder who's name starts with a .. They are usually found within the root folder of the project and within the module root folder.
build folder found in the project root folder and in module root folder.
any file who's extension is .iml, found in the project root folder and in module root folder.
local.properties found in project root folder.
The rest of the files and folders need to be kept. With the above excluded, the project can be re-imported in Android Studio properly with the correct configurations relative to your second PC.
On a side note, these are the typical exclusions added in .gitignore of an Android Project Git Repo.
Ok, I found the problem. It is related to how gradle resolve symlinks. This is the issue. Summarizing, if you open your project with a path that contains a symlink, absolute paths will be created in the configuration files and your project won't be portable.
I have reopened the project again using an absolute path and then all the configuration files use PROJECT_DIR instead of USER_HOME
I have the library and 2 samples for it. Say my-sdk, sample1, sample2. The file structure is:
Project folder, inside it settings.gradle, my-sdk and samples folder. Inside samples I have sample1 and sample2 folders.
My settings.gradle:
include ':my-sdk', 'samples:sample1', 'samples:sample2'
The problem is:
In Android Project View I see 4 projects:
sample1
sample2
my-sdk
samples (empty)
How to remove samples folder from Android Project View?
BTW. I have file samples.iml inside samples folder. So looks like for me that Android Studio thinks thats samples is a module but it just a folder for other modules.
UPD If I try to remove this empty module from Module Settings F4 than IDE crashes.
Do these steps:
remove from the sample folder the .iml file
remove from the sample folder the build.gradle (if it exists)
run a ./gradlew clean and resync gradle project.
If it is not enough remove:
.idea : in this folder Android Studio saves the settings
.iml in each module. In these files Android Studio stores the module information
Delete these resources, and then reimport again the folder.
I am following some posts/questions about AndroidStudio-1.2 and it seems that there is a different project structure: app/src/main; while my old 1.0 project looked like: src/main (no app).
Not sure if this is causing this, but I am not able to get gradle to identify any test files, while running tests.
You probably have to rename src/test to src/androidTest.
The app directory is a subproject directory. By default AndroidStudio generate a structure ready for multi-module project. i.e. :
a root directory with the root build.gradle + gradle.settings (listing all modules in your project)
a subdirectory (named "app") where you can put all the sources for your application.
Later it is more easy to add a library module (just create a directory myLib in the root folder).
This structure is just proposed by AndroidStudio: you can also use AndroidStudio with only one level of directory and one single build.gradle.
I am using IntelliJ Idea for Android development and IntelliJ uses a folder named out for putting APK file.
I am also using Mercurial as VCS and when I clone the project the out folder is left out from the cloned directory.
Also folder out is also not shown in the project structure and when I go to Open Module Settings -> Modules the folder is excluded as shown in the image below
Why out folder is excluded and how to include it in VCS (Mercurial)?
Why out folder is excluded
Because this folder doesn't contain sources and (I suppose) IntelliJ mirror own settings into .hgignore file of related repository
how to include it in VCS (Mercurial)?
Just
Never do it
because versioning of build artifacts is bad idea, useless, wasted time and space - save only sources, not repeatable results
but, if you want to try all racks on the way - remove the related string from .hgignore.
In Eclipse (on Windows) I created a cross-platform folder structure for Phonegap :
--phonegap_android
--assets
--www (symlink/junction to 'src')
...
--phonegap_ios
...
--src
index.html
Here's what I did to get this working :
created an Android-project in Eclipse based on the phonegap-android
folder.
made a junction for the 'assets/www' folder to link with 'src' (using the Sysinternals command)
created a svn-repository, for this entire project (the parent project that has the different folders for android, ios and src).
I can run the application now, but I have problems committing the project to svn.
The 'www' folder is a junction-folder, so when changes are made to this folder, I want this folder to commit to the real source folder : 'src'.
I tried different approaches :
Setting an svn:ignore on 'assets' to ignore 'www', but then of course
nothing in www is committed, when I commit the android-project in Eclipse.
Setting an svn:externals on 'assets' to define 'www' as an
external to svn://myproject/src, but then it still tries to commit everything in assets/www and I get an error 'No versioned parent directories'.
Any ideas how to get the www folder NOT committed, but at the same time get the src folder to get committed to the svn repository?
Dylan,
Following with svn:externals will work.
Create Folder 'phonegap_android'
Under 'phonegap_android' create folder 'assets'
Commit them to svn repository 'svn://myproject/phonegap_android'
Now for the 'phonegap_android' folder, set the svn:externals as follow
'../src assets/www'(if your svn path for src is at same level as phonegap-android svn://myproject/src which is in your case)
On windows using tortoise svn, it will let you commit 'phonegap_android' folder with svn:external changes.
Take svn updates and you are done.
Henceforth whatever you commit to phonegap_android/asset/www folder, it will be committed to src folder(svn://myproject/src)