How do I export an Android Studio project? - android

I just started using the Android Studio IDE and I already released and published a simple APK to Google Play store.
The problem is that I did this at work.
Now I downloaded the Android Studio at my home and I want to continue working and fixing bugs on my Project.
I see that there is Import Project in the Android Studio home screen, but from where I export the project in order to import it?
I tried Zipping my whole Project folder and import it but it didn't work very well.

In the Android Studio go to File then Close Project. Then take the folder (in the workspace folder) of the project and copy it to a flash memory or whatever. Then when you get comfortable at home, copy this folder in the workspace folder you've already created, open the Android Studio and go to File then Open and import this project into your workspace.
The problem you have with this is that you're searching for the wrong term here, because in Android, exporting a project means compiling it to .apk file (not exporting the project). Import/Export is used for the .apk management, what you need is Open/Close project, the other thing is just copy/paste.

As mentioned by other answers, as of now android studio does not provide this out of the box. However, there are ways to do this easily.
As mentioned by #Elad Lavi, you should consider cloud hosting of your source code. Checkout github, bitbucket, gitlab, etc. All these provide private repositories, some free, some not.
If all you want is to just zip the sources, you can achieve this using git's git archive. Here are the steps:
git init # on the root of the project folder
git add . # note: android studio already created .gitignore
git commit -m 'ready to zip sources'
git archive HEAD --format=zip > /tmp/archive.zip
Note: If you intend to send this by email, you have to remove gradlew.bat from zip file.
Both these solutions are possible thanks to VCS like git.

It seems as if Android Studio is missing some features Eclipse has (which is surprising considering the choice to make Android Studio official IDE).
Eclipse had the ability to export zip files which could be sent over email for example.
If you zip the folder from your workspace, and try to send it over Gmail for example, Gmail will refuse because the folder contains executable.
Obviously you can delete files but that is inefficient if you do that frequently going back and forth from work.
Here's a solution though:
You can use source control. Android Studio supports that. Your code will be stored online.
A git will do the trick. Look under "VCS" in the top menu in Android Studio.
It has many other benefits as well. One of the downsides though, is that if you use GitHub for free, your code is open source and everyone can see it.

Source control is best way to handle this problem, if you don't want to pay then try bitbucket
It's free, allows private repo for upto 5 members team.

Windows:
First Open Command Window and set location of your android studio project folder like:
D:\MyApplication>
then type below command in it:
gradlew clean
then wait for complete clean process. after complete it now zip your project like below:
right click on your project folder
then select send to option now
select compressed via zip

Apparently, there's a lot of "dead wood" in the "build" directories of a project.
Under linux/unix, a simple way to get a clean, private backup is to use the "tar" command along with the "--exclude=String" option.
For example, to create an archive of all my apps while excluding the build directories, I have a script that creates the following 2 commands :
cd $HOME/android/Studio
tar cvf MyBackup-2017-07-13.tar Projects --exclude=build

For Android Studio below 4.1:
From the Top menu Click File and then click Export to Zip File
For Android Studio 4.1 and above:
From the Top menu click File > Manage IDE Settings > Export to Zip File ()

Related

Android Studio integration with GitHub failing to upload project files apart from MainActivity.java

I have recently created a new Android application and have used its VCS to integrate with GitHub. My problem is that although the integration appears to work, the only file in my Android application that has been saved to GitHub is MainActivity.java. I have tried to add files into GitHub but via the Website but this fails as there are too many files and it doesnt allow Folders to be added.
Has anyone else had this issue?
It's frustrating as when I make changes to MainActivity.java it gets saved and committed/pushed okay but the VCS in Android just doesn't see the other files I have changed such as the content_main.xml which I changed to see if it would then be added to GH.
I cannot seee how to add files within Android Studio to GH via VCS. Does anyone have any pointers where I may start? Thanks!
NB I have had a look through existing questions but none address my issue as far as I can tell.
Usually when you start a new project, Go on VCS -> Enable Version Controle Integration.
Then you should have the Version Control accessible on the Bottom Left of the IDE.
In the tab Local Changes, you will see Default and Unversioned Files.
Just take files from Unversioned Files to Default to start to track them.
To my shame once I checked Xiaomis suggestion I could see that my git was pointing to a directory lower than my /app directory. I tried to change in in my GitHub shell but was unable to do this as GitHub Desktop shell didn't recognise the new directory.
To fix my muddle I deleted my original repo and delted the .gitignore file and other git files from my Android project folder. I then opened Android Studio and went through the process of creating a new repo from there, circumventing GitHub entirely. This worked and enabled me to select my /app directory as the Git root.
Thanks go to Xiaomi who's suggestion made me notice that git was looking at the wrong root. Live and learn!

Using Android project with Team Foundation Server 2010 and branching. Is there a simpler way?

This is what I did. If there is a better way please reply.
Make sure all developers have installed Android SDK & Tools in the same paths.
Install the Eclipse TFS plugin from Microsoft.
Link at the time of this writing is: http://www.microsoft.com/en-us/download/details.aspx?id=25125
Here are the steps I followed:
I started my Android project in a random folder (workspace) and did my initial development.
Then I wanted to move the project under my development branch at $root/Development/MyBranch/Android
The Android folder did not exist, so I created is using TFS. If you do it manually from explorer then TFS will not let you create it server-side.
From the original project workspace I did "Export" --> "General|Preferences", to some folder.
Then I did "Switch Workspace" --> "Other"
I specified the local path of $root/Development/MyBranch/Android
Now I get an empty workspace.
Then I did "Import" --> "Project Settings" and specified the file I exported before.
Then I did "Import" --> "General|Existing Projects into Workspace" with "Copy Projects into Workspace".
Amazingly enough I got my project up and running from the new location, with a few hiccups as usual.
Then I did "Team|Share Project..."
I followed the wizard.
There is a crazy screen about creating a new workspace. Just click EDIT and make sure that the TFS root mapping is ok.
Finish the wizard and you are done so far.
When you run the project, the plugin will also add the gen and bin folders to TFS.
Don't try to battle this, just check them in. More details later.
At this point, I have everything checked-in, so I merge to Main.
At this step I want to merge the project to another developer's branch.
The process is similar.
Using TFS create the $root/Development/OtherDev/Android folder.
Start Eclipse on the dev's PC and do "Switch Workspace" --> "Other"
Specify the local path of $root/Development/OtherDev/Android
Now you get an empty workspace.
Then "Import" --> "Project Settings" and specify the preferences file exported before (I included it in TFS for reference).
Then "Import" --> "General|Existing Projects into Workspace" with "Copy Projects into Workspace" and copy the project from the local folder of $root/Main/Android
Then do a "Team|Share Project..." to connect the project with TFS.
Now close Eclipse.
Do a merge $root/Main/Android to $root/Development/OtherDev/And
Checkin $root/Development/OtherDev/Android
Guess what, looks like you are done. Unless I did something wrong, but it "works on our PCs", so far.
Special note: Since Eclipse/TFSPlugin will always try to add the gen+bin dirs to source control, simply keep them always checked out, and even if you check them in sometime, don't merge them back to main. It's just a waste of disk space on TFS merging these files around.
This method is so complicated, that it just doesn't feel right.
Is there a better way to get the same results?
Thanks!
As for the bin/gen directories... TFS 2010 SP1 and newer has an ignore option. Bin should be added automatically but gen isn't. To add, Right click the folder, then choose Team and then Click Ignore. You will probably need to remove these folders in TFS aftwerwards, but they will not sync with TFS anymmore.

Can't checkout an android project in STS 2.9.1 and Subversive on Windows 7

The problem
I have a strange problem with SpringSource Tool Suite 2.9.1 Release and Subversive plugin, running on Windows 7 Home Premium x64. I'm trying to checkout an android project from an SVN repository.
Here's what I'm doing:
File > Import > SVN > Project From SVN
I fill in the path to my repository and check the HEAD revision
I click Finish
The project is found and the default option is Check out as a project with the name specified. I leave the name alone Set the Depth field to Recursively and again, select the HEAD revision.
I click Finish
A progress bar appears for a second just to show an error message:
Checkout operation for 'https://(.....)/Android' failed.
svn: Cannot create new file 'C:\workspace-sts-2.9.1.RELEASE\AppName \.svn\lock': System can not find the path specified
When I retry and follow the steps from 1 to 6, another dialog appears. It says:
This project already exists in the workspace
or there is a data folder in the checkout destination.
It allows me to select a folder to overwrite. When I do that, a similar but different error message is shown. It says:
Checkout operation for 'https://(...)/Android' failed.
0x0000000f: The folder 'C:\workspace-sts-2.9.1.RELEASE\AppName \.svn' is locked by some external process. Please unlock the folder and try to check out the project again.
What I've tried
First, I opened the SVN Lock view to see if there were any locks created by the IDE. There were none.
I restarted the computer, hoping it would solve the problem of any application locking the file but this does not seem to be the case.
After that, I created a new workspace in a different location and tried to check out the project in there. The result was the same.
Then, I attempted to change the version of SVN Kit. The situation persists in:
SVN Kit 1.2.3
SVN Kit 1.3.5
Native Java HL 1.5.4
Native Java HL 1.6.12
I thought that changing permissions to the directories of my workspace was worth giving a try. It didn't do the trick either.
Finally, I checked out the project in a different location, using Tortoise SVN and imported it into my workspace. I could run it (though some build path settings seemed to be missing) but it's not a solution. I can't possibly imagine working on the project simultaneously with a couple of people without the ability to commit/update/view history/resolve conflicts in my IDE.
I was advised to install a separate version of eclipse with its own set of tools and a different workspace for this application alone but it doesn't seem like a good idea. I'd like to keep it all in a single IDE. I'd also prefer to avoid reinstalling the whole thing as I don't feel like configuring all the other tools (mostly spring and android-related) from scratch.
Has anybody seen a situation like this? How can I get it working?
It's uncear to me whether this is a subversive problem or an SVN problem. I would try checking out from the command line (you must install SVN command line tools to do this, but I'd recommend having the tools around as a backup anyway).
Checkout from the command line and then import into STS using File -> Import -> Existing projects into workspace. Once in the workspace, you can select the project -> Team -> Share project to get svn support on it.
Rename the project and check out again , It must be a problem where u are trying to checkout the project which already exists with same name in the Package Explorer

Building Android default email client: No default.properties exists? (Also, build path errors)

I'm just trying to build the default Android email client, the source is located here:
https://android.googlesource.com/platform/packages/apps/Email
I cloned the git repository, imported it into Eclipse, but Eclipse groans that default.properties doesn't exist. How do I generate default.properties and fix the build paths for this particular application?
EDIT: I hope I don't sound too demanding here, but there might be some special requirement for this particular application, since I've cloned so many other applications and built them successfully, so before replying if you could clone this repo and try building it yourself, that would be swell.
EDIT2: I also tried running this:
android update project -p . -t 3 -s
in the project directory, which generated the missing files, but now the project inside Eclipse is riddled with hundreds of errors:
Screenshot
I think the problem is that you're trying to import an existing project. Maybe try creating project from source, i.e. create a new android project and specify the location of the source. Eclipse will then create all the necessary files for you, including default.properties.
This file is auto-generated, so you shouldn't have to create it yourself (and if you do, it might get overwritten anyway). Try setting the android library to make eclipse rebuild your project.
This is located at "Project Root->properties->Android.
See which android version is being used and change it to a new one. Then change it back after eclipse has re-build the project for you.

Move Android Eclipse project into workspace

Eclipse is really bugging me with this. I have an Android project that is not in the workspace. Since Android projects don't work correctly if you use Eclipse's Import>existing project you have to make a new Android project from a folder on disk. If this folder
is in your workspace, it won't work. If it isn't it works, but then the project is located outside of my workspace folder, which is irritating. Does anyone know a way around this?
You can fix this by following this alternative import flow:
Make sure your project folder you want to import is in your workspace folder
In Eclipse, go to File → Import...
Click General → Existing Projects into Workspace
Make sure the "Select root directory" radio button is selected, and browse to your workspace directory.
In the Projects box, check the box next to the project folder you want to import and click Finish.
This will properly import your Android project.
I've experienced this problem too, when, for example, I tried to create a new android project based on existing source (the Notepad Exercise 1 example program that the android developer's documentation provides). I believe the problem you are experiencing with Import not working is that what you are trying to import a "project" that isn't really an Eclipse project at all (e.g. no .project/.classpath - it's just source code with a directory structure that deceptively looks like a project).
Like cisteams has alluded to above, if this is the problem, the procedure around this goes something like this:
Make a new android project choosing "Create project from existing source", making sure that the source directory is indeed outside your workspace (you'll have to live with this for a second). This should a) make the necessary .project/.classpath files in the source directory (which is still outside your workspace for now) and b) make the project show up in your list in Eclipse.
Right click the project in the Package Explorer and choose Delete, making sure that the option to delete files on disk is unchecked when it comes up.
Now import the project like you would any other project (you can do this now because the .project/.classpath files were created in step 1 above). There should be an option when importing for "Copy projects into workspace", so tick that option.
And you should be done. You can go back now and delete the copy of the project that isn't in your workspace to avoid confusion later on.
What version of Eclipse and ADT are you using?
Currently this approach is working fine for importing projects that are checked out from SVN. It does require that you have a .project and .classpath files (normally they are checked in to revision control).
If you do not have these files (some open source examples don't include them) then you need to use the Android Wizard for creating a new Android project from existing source. The key here is that it is a New not an Import, so yes it doesn't like it if the files are in the workspace. What you can do is create the new project externally using the wizard to create the .project and .classpath files. Once those exist you can use the normal import to bring the files into your workspace (and check those missing files into your source control).
Also you must delete the current install on your phone or you will get a signature fail from other comps install of the same app. So do the above and uninstall app off your phone before running the app on the new computer.

Categories

Resources