I have a problem with the import of my company's project into Android Studio.
First of all, we have a project which contains desktop clients (Java) and mobile clients (Android). The project structure under Eclipse runs fine.
But since Eclipse and ADT is not longer supported by Google, I thought it is time to switch to Android Studio (I am the first one, who is trying this).
Our project (trunk) has a structure like this:
10 Folders which doesn't contain relevant code for the Android Client
mobile (Android based code)
projects (Android xmls, manifest and all other non-Java stuff)
sharedContent (pure Java)
"mobile" contains all the specific source code for the Android client.
The "projects" folder contains a folder "android", which contains all necessary xml-files and the manifest.
The "sharedContent"-folder contains a "sharedME" folder. The code from the "mobiles"-folder uses some code from the "sharedME"-folder.
This three directories are required for the Android client.
The main problem is, that I am not allowed to change the project structure to one, which is more suitable for Android Studio. The reason is, that at first the package declarations wouldn't be correct anymore, and secondly other important code from the project will have problems with the changed structure.
Since we used to import the trunk with SVN, everything worked fine under Eclipse. But I can't integrate the code successfully in Android Studio. I tried many different ways (and tutorials), but none of them worked for me. Note, that the import into the workspace seems to be no problem. But when I am trying to build the project, Android Studio shows me several errors.
I won't show you, what errors I am receiving, because they would be from many different approaches.
I want to start from scratch by asking you, how you would import this project structure with given setting into Android Studio. Maybe I tried the right way, but just made something wrong.
The most favourable solution would be, when the project is connected to the SVN, so that we are able to commit or checkout changes from the SVN directly from Android Studio. But since this doesn't seem to work either, it is ok to commit them manually from the workspace.
I am glad for any suggestions. Just post your ideas, and I will responed with the error output I get or if the solution was successful.
EDIT:
I imported the three most important directories with SVN into Android Studio. Now I have three modules: "android", "mobile", and "sharedContent"
The only error I get is "cannot find symbol, symbol: class R". R is located in android->gen->com->...->project->R. The error is created by the files from the module "mobile", to be exact from mobile->android->com->...->project->A random Class.
Is there a way to point to the R-class, which is located in another module?
Android Studio shows the error at first in the import, like "import com. ... .project.R". I set them as sources, but it didn't work, yet.
currently I'm exploring on using the Android Studio. It's been a while since I last developed on Android and this is really exciting for me having a new tool to develop in Android. Now I already setup the Android Studio successfully and already tested to create a new sample project last week but today after I opened it a message appears saying that "the folders below are removed from gradle..." it has a checkbox and I don't know why it's checked by default. Since I'm not yet that familiar with the environment I pressed ok then all the src and other folders are now missing. Although I can still access the src folder as well as the classes I created through the use of the navigator on the top part but I can't run the app and it acts really strange compared from before.
Also when I try to create a new project a message appers saying:
"Failed to import new Gradle project: Could not fetch model of type 'IdeaProject' using Gradle distribution 'http://services.gradle.org/distributions/gradle-1.6-bin.zip'.
Unable to start the daemon process."
Not sure on what to do about this one. Well I know this is still in beta and bugs happen but I hope there's already a workaround for this.
Anyway, here's a screenshot on what happens to my project:
So I tried searching answers based on the error message I got from creating a new project and found out about this one:
Failed to import new Gradle project: Could not fetch model of type 'IdeaProject'
works like charm indeed.
If you read:
http://developer.android.com/tools/testing/testing_android.html#TestProjectPaths
It will tell you to create your tests inside your project at the same level as src. What it doesn't tell you is how to do it.
I checked out a post on here about this (http://stackoverflow.com/questions/5395216/creating-an-android-junit-test-project-in-eclipse) and found that it no longer seems to work on newer versions of Eclipse (Indigo for example).
So, how can you set up the project as they suggest so that the test directory is inside of the original project?
Note that if you do as the link suggests and uncheck the use default location, then Eclipse will prevent you from going forward as it gripes that you overlap the location of an existing project. If you try to add a sub-directory manually to place your project, then you can go on but you will get an error later saying "An internal error occurred while refreshing workspace" and no test project gets created.
Surely there is a way to do this isn't there or should I just disregard the suggested package structure and go with what Eclipse seems to want to do?
If I change some code, save, and Run, it runs the last version of the program, not what I just saved. The only way I can make it update is if I Clean the project, Build the project, and then Run the project. Is there some way to avoid this tedium?
I spent some time create two dummy projects (one Android and one Java) and have a play with it, and finally come up with a workaround which is not used very often but able to solve your requirements.
First, I will explain your question a bit more (based on my understanding and what I have tried) so that other people can have a more clear understand about what is happened here.
According to the conversation in comments:
could you tell me what you have in following setting: project->properties->Builder ? – Sudar Nimalan
#SudarNimalan: I am not sure this is what you are asking, but: there's text that says "Configure the builders for this project", and under it is a single option, "Java builder", which is selected (checked). – shino
for android project, there should be, "Android Resource Manager", "Android Pre Compiler", "Java Builder", "Android Package Builder" in this order, chould you add those and try? – Sudar Nimalan
#SudarNimalan: I owe you an apology; I do have those four components. My "project" is split into 4 projects - "core", "core-android", "core-desktop", and "core-html". It's a little weird because I set it up with the libGDX project setup UI, and I was looking at the 'core' project when I answered your question. My 'core-android' project has all four (in that order), and it is the one that has the problem in my question. – shino
Scenario:
You have 4 project:
core: a regular java project (common pure java code here)
core-android: an Android application project.
core-desktop: not related to question so ignored.
core-html: not related to question so ignored.
The core-android project has dependency on core project, by adding core to core-android's build path (Properties -> Java Build Path -> Projects -> Add ...) and export list (Properties -> Java Build Path -> Order and Export).
Problem (Not Really):
Change some code in core and save it, run core-android, eclipse install last compiled apk, not the new one with change.
Reason:
The is the expected behavior, the way you used to reference core project in core-android only create a weak link (or something sort of) between core and core-android, the core-andorid's auto-build script doesn't aware any changes made in core. You have to clean the project (only need clean core-android project) so that Eclipse can delete the existing apk (under bin directory) and re-generate the apk (with the latest code changes from core).
See Xav's comments below, Android SDK tools should aware changes from plain Java project under project build path, and it does not behaviour this feature normally at the moment.
Note that if core is an Android Library project, then there is no problem and your core-android project will aware any changes in core project (java code, android resource and etc), if core is only used in core-android, this could also be a workaround: turn Java project core into Android library project.
Workaround (Eclipse Link Source):
There is another way (not commonly used) for adding soft link between projects:
First, you need remove core project from core-android's build path, this will also remove it from Export and Order list.
Right click core-android, choose Build Path -> Link Source ... Add ../core/src as Linked Folder Location and src-lib1 as Folder Name,see screen screen in the end.
This create a symbolic link src-lib1 under core-android in Package Explorer windows point to core's src foder, in the file system, you still have two separate project folder. Now if you change some code in core and run core-android, Eclipse will build and install latest apk. No need to clean core-android project.
Link Source Window:
Final look in Package Explorer:
You should always consider the normal approach as first option, after all, manual clean project is not a big deal compare to the unusual approach I described above.
Please follow this steps..
1. Project--> Build Automatically been checked??
2. Please following setting: project->properties->Builder like that?
Check below image.
And Also Check Below Settings.
Also Check Below Image
IF problem continues then please Update your ADT & SDK.
Hope it works for you .
Navigate to Windows->Preferences->Android->Build. Make sure that the checkbox "Skip packaging and dexing..." is NOT checked.
The Problem is the In your Eclipse, go to Project Properties - Builder, There is one CheckBox with AndroidPackageBuilder that is required to be Checked True. Now everytime you will do any changes in you project that will be reflected in your build and the Compiler will never say that
"Application Already Deployed, No need to Reinstall"
This will work evenif you dont have selected Build Automatically, Because everytime you run by clicking Run icon or Ctrl+F11 that will first Build the Project and Then Run it. So The requirement is just to Enable the Android Package Builder
You won't believe how easy and silly is the solution
On Eclipse,
go to Window-Prefences->run/debug ->launching
And then, on Save required dirty editors before launching :
choose the Prompt option,
Apply and OK
I am using InteliJ Idea Community edition to develop android apps. I was trying to write UnitTests for a HelloWorld App as described in link text
. However I keep on getting an error
Found main project package: com.example.helloandroid
Found main project activity: .HelloAndroid
Error: Unable to load the main project's default.properties
On going through the files that were created by InteliJ Idea, I saw that all the files as mentioned in d.android.com/guide/developing/other-ide.html#CreatingAProject are being created except for defaul.properties and build.properties.
Is there any way we can create these files?
I had the same problem you're describing as I'm also developing using IntelliJ and these are the steps I followed to create a valid default.properties
1) Create a project using Android (with no IDE) the instructions are here. I created using exactly the same information than in my original IntelliJ project but looking at the resulting file it was not that important.
2) Copy the default.properties to your own project
In order to create the project you will have to know the id of the target you are using, you can obtain the list by executing android list targets.
Once I created the project I opened the default.properties file and the only thing important there was the target, in my case Project target.target=android-8
Hope this helps although your question is stackoverflow since a long time already.
Regards
PS: if I knew how to attach a file you wouldn't require to follow the above steps as the resulting file has no project specific information except for the target (if you want me to send it to you just tell me)
This is a bug and has been fixed but the fix has not been released yet:
http://youtrack.jetbrains.net/issue/IDEA-69343?projectKey=IDEA&query=android+default.properties