I would like to make an small program in Windows to duplicate an android project to use it in eclipse. I know that there is an option in eclipse (New Project -> Android Project -> create project from existing source), but I would like to automate this step (doing it programmatically in Java). Is there any command, script, etc to do so? I have tried copying the project folder, renaming every reference in the new project´s files and importing the new project into eclipse using a ZIP, but it does not seem to work.
Thanks in advance.
Try working with Android Library Project may also suit your requirement
What exactly is the problem? Additionally, if you are working on multiple machines, do yourself a favour, and use some sort of version control (SVN, Git, etc.) That would make it easy to commit/checkout files across machines.
Related
For some reason I can't find a clear cut answer to this. I am currently using Eclipse for my Android projects and as you can see from the screenshot my workspace has multiple APK projects, hundreds to be exact.
The reason for doing this is because it is easy to copy and reuse projects within the same workspace very quickly.
My question is, can this setup be done in Android Studio? I can't tell if it's one APK per Android Studio, or you can work with multiple in the same instance sharing dependencies like Eclipse did.
I am currently using Eclipse for my Android projects and as you can see from the screenshot my workspace has multiple APK projects, hundreds to be exact.
Been there, done that, found it to be unusable, except by keeping most of the projects closed, as it appears that you are doing based on your screenshot.
The reason for doing this is because it is easy to copy and reuse projects within the same workspace very quickly.
In Android Studio, you copy and reuse projects by coping the directory, using your development OS' file manager, the command line, or your favorite other file-management tool.
can this setup be done in Android Studio?
Not really. Android Studio supports a project having multiple modules, where those modules can be apps or libraries. There is certainly nothing stopping you from attempting to create a single Android Studio project consisting of hundreds of modules. However, they would all be the equivalent of open projects in Eclipse (actionbarsherlock and com.exposure.0 in your screenshot). I would expect Android Studio's performance to be worse than Eclipse's with hundreds of open projects, assuming that Android Studio did not flat-out crash due to running out of memory.
I was able to do it just fine without any issues. I was able to set two projects as Android projects in the settings.gradle file and just choose which one I want to launch. Hopefully over 300 of these doesn't start a performance issue. If it does I will just need to remove the modules and add the correct ones when exporting a new APK.
settings.gradle
include ':comexposure0', ':comexposure5', 'exposurelibrary'
Working under Linux Ubuntu I have made a script which automates the creation and build of new "Hello World" android projects in the workspace of Eclipse and/or Intellij Idea .
The script also inserts my own icons into the different res/drawable directories and adjusts the AndroidManifest.xml to reflect this .
Alas none of these 2 ides recognizes the new project , I still have to import the project (which is already in the workspace ) via "import project " working through a multitude of screens ?
( I'm new to Android and Ides , used to make C-programs all via command-line tools .)
Has anyone a suggestion ?
T.I.A
I can answer your question specifically for IntelliJ IDEA and generally for other IDEs such as Eclipse and NetBeans.
The IDE needs configuration information beyond what's in the project's source code. It needs to know what JDK version to use, where the JDK is, what Android SDK to use, where it is, etc. In the case of IntelliJ IDEA, this is all stored in the either 1) the .idea directory (and its content) and an *.iml file for each module or 2) an *.ipr and *.iws file and an *.iml file for each module. Eclipse and NetBeans likewise use several configuration files. These files are very IDE specific (although IntelliJ IDEA can use and maintain eclipse configuration files.) The specifics of these files frequently change between versions. So even if you spent the hours (or more likely days or weeks) it would take to modify your script to create these configuration files, it would be one more thing to maintain.
My suggestion would be that instead of using your script, use the maven-android-plugin. It has several Archetypes available which can auto generate android projects. You can write your own Archetype that would include your files/icons and manifest modifications. You can run the Archetype from the command line (via mvn) or in IDEA, you can Select File > New Project > Maven Module and then select your Archetype. This would create your project and import it into the IDE in a single step. Plus using maven to manage your projects will make development much easier. Of course, there is an initial learning curve to learning maven, but it is so worth it.
Just starting with Phonegap and having some trouble understanding the directory structure and setup (on Windows).
I have been able to install and setup phonegap, jdk, android sdk, ant, etc. Using the command line I can now create a new project, edit the source files in www , build it and run it on my phone, Android Emulator and even Genymotion .
But the one thing that I just can not seem to understand is how I could edit and run the Phonegap project from within Intellij IDEA. All examples and how-tos I can find use the older Phonegap 2.9 structure, which is quite different from 3.0.
I enabled and configured all plugins, etc. I then try to import the existing project folder as a new project in IDEA, but it says "Source files for your project not found".
But when I build the project first with phonegap build android using the CLI, and then try to import it in IDEA, source files are found and I can continue the import of the project. But the Project Structure then seems to point to source files in platforms/android (platforms/android itself and also platforms/android/gen and platforms/android/src , I have no idea what to choose, so I choose all). I then click Next a couple of times until the Android project is created. After changing Project Language Level to 5 (no idea what this means) , I can now run the project from within IDEA.
But... changes that I make in www (in the root) don't end up in the compiled project!
So do I have to copy all files manually to platforms/android/assets then ? (the command line phonegap builder did not require this). Or do I have to edit the files in platforms/android/assets/www directly ? (which seems odd, since I would like to be able to only maintain the same code for all different platforms).
What do I need to do to achieve this in IDEA?
Somehow I think some things in Project Structure are wrong, but I have no idea what all this means (Modules, Libraries, Facets....).
Where should the manifest file be located, and the resources, and assets and libs?!
Could anyone point me in the right direction?
After phonegap create & build , there is a whole Android project located in %my_project_root%\platform\android
if you don't have the Android SDK at left, use the green icon to add one.
That's all
We don't need to modify manually the code under %my_project_root%/platforms/* but only under the %my_project_root%/www/* and %my_project_root%/merges/*
After running
phonegap build android
it automatically replaces platform specified code.
I found solution for me the next way:
After importing source code to IDEA, I added new web module which points to the %my_project_root% to be able to see all needed directories.
Also I created new IDEA command line tool with alias phonegap and tool path /usr/local/share/npm/bin/phonegap.
So before running default android running configuration I run phonegap build android just directly from IDEA (I think it's more convenient) and then run usual android run command to deploy the app to emulator or real device.
I hope this stuff will help you.
I use two computer for coding. My desktop pc and the notebook. I sync the two computers with dropbox. How can I import/load a project on each of this two computers? The project base folder is different on each computer. When I try to load/import a project which is created on the other computer it loads the project but I got a error with a wrong path.
"Gradle "Test2Project" project refresh failed:
Could not fetch model of type "IdeaProject" using Gradle distribution "http://services.gradle.org/distributions/gradle-1.6.zip".
Project directory "C:\Users\thomas\AndroidStudioProjects\Test2Project" does not exist."
The wrong pfad is the right pfad on the other computer. How can I import Android Studio projects so that it works even on another computer with a different folder structure?
Like the others i agree, that using a VCS would be the best solution. Even though you can try to filter all android studio related files (like *.iml, .idea folder and local.properties). I don't know if you can do this with dropbox or if you need some kind of 3rd software.
After that you should be able to make source code changes on both computers without greater problems. (You may have to declare project dependencies changes for the android studio twice)
Builds depending on the build.gradle files should work to. But again: using a VCS is the better way to go.
Go for git, you can use bitbucket.com as a free remote repository.
This is a problem I have ran into when trying to store Android projects in a Dropbox folder. What happens is that Machine 1's IDE is mapping system resources (like the SDK) as being in that machine's filesystem. When you go to Machine 2, everything will work EXCEPT for what you expect--because the SDK will probably be in a different spot!
One way to get around this is to use your VCS (dropbox, git, whatever) as a repository for JUST your source files, and then have a local project created on each machine that reads from the Dropbox folder. This requires two separate projects that are mapped differently, but that have the same source folder.
I discovered this problem when I tried to load up an Android project on a new install on a Mac machine:
Do you see what's happening there? My Mac Android Studio is saying, "Hey, I don't see where "C:\Android\SDK is, but I do see that you have an Android SDK in a different folder, so I'm going to update your project files to reflect the actual location of the SDK."
In my opinion, the only way around this is to create your project on both machines, and version control your source and assets folder. If you don't create the project separately on each machine and use VCS for just the source and assets, the only way to get around build and filepath errors is to store your SDK in the same folder on each machine. This worked for me when I was building on a Windows desktop and Windows laptop, but no longer works for me since I am using a Macbook Pro.
I know this was questioned about 4 years ago, but this is up to now still an issue. Using a VCS seems like a good solution, but for me it is simply more overhead than i want to have. I also use Dropbox to synchronize my folders and the history they provide is for my private programming needs good enough. So i think, it would be good, if android studio simply uses relative paths.
I know it needs some system paths and it does a good job in looking at the local.properties and setting it to the correct place when the project is loaded.
The main problem with using Dropbox are the build-directories. There are many many references to fully qualified paths in the files within these directories. So my solution was to exclude the build-directories from Dropbox-synchronisation.
When you work at your laptop, build the app, create new files, change files or delete files, the build on your pc will be completely outdated when you switch back to it. but android studio will recognize this and do a fresh build when you start your project for the first time after working on the laptop.
so the biggest problem at this point is the file local.properties and this is handled correctly by android studio. it may be a good idea (or a really bad one, i don't know the drawbacks) when the build system wouldn't write fully qualified paths in the files within the build directory.
But up to now this is my solution for using Dropbox and not using a VCS:
exclude build-paths from Dropbox synchronisation
i hope this helps somebody.
I am new to both Java development and Android development. Did a couple of regular Java projects in NetBeans and liked the IDE. Then tried Eclipse and did not like it. I am trying to develop for Android using the NBandroid plugin but ran into a strange problem.
All I want is to add an external JAR to the project. Say, I have a jar in c:\foo\bar.jar (I am on WinXP by the way). For a regular project in Netbeans, all you do is right-click on Libraries, select Add Jar/Folder and you're good to go.
I can't do it in my Android project. I click on Libs but nothing happens. If I am doing something wrong, what is it?
If I am doing it right, can I manually override this by entering the JAR info into the build file(s)? I tried this by looking at the build files for a regular project in NetBeans but could not map it easily into the Android project since the build file structure seems to be different.
If I can't figure this one out, I will have to abandon NetBeans and go back to Eclipse, but I want to give it a shot. Can you provide any advice? Thank much in advance!
This is an old question, but in case anyone stumbles over it, you can manually drag .jar files into the "/libs" subfolder of your Android project's folder using an operating system file manager like Windows Explorer, and they will show up inside NetBeans under "Libraries" as if you added them the usual way.