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.
Related
I have downloaded the CustomView.zip from developer android page.
I've tried to import this into Android Studio 2.2.0.12. But I am NOT able to do it.
I have also tried to create a empty project in order to import only the sources and XML. It does´t work either, I get a lot of duplicates XML definitions and even after resolving the duplicates the App crashes with some inflate exception.
So, i´m wondering, How can I import this into Android Studio in order to have a working project and run it to see the behavior and also to debug it
Thanks in advance.
Looking at the sample file, stupidly, it doesnt include any of the standard android framework files (gradle, manifest etc), so Android Studio will not be able to automatically import it.
To get round this you should create a new blank project, leave the mainactivity that is generated.
Then go in to the file structure of the new project and copy in the files from the sample in to the corresponding files. Make sure you overwrite the files in the new project.
Then go in to the code base in Android Studio and delete any imports that cant be found due to incorrect package names. Re import these (alt + enter on mac) with the correct package names and then build and you should be good to go.
I need to share an android project with another pc and still be able to edit it on both sides.
For some reason I can't get this to work. I have tried a lot of different combinations to import it and still be able to edit and push changes.
When I try to import the project into my workspace, there is a lot of errors like this:
the type java.lang.object cannot be resolved. it is indirectly referenced from required .class files
Then I tried importing the JRE System library (JRE 7)
After doing this I still get errors. for example this:
Activity cannot be resolved
Then I imported the Android library to the project (API 18). But after doing this, there is a red cross on the project, but not in any classes, files or like..
Therefore I tried to clean the project, which removed the "R.java" and gave me a bunch more errors.
I don't know exactly what I am doing wrong here so I hope someone can help me out.
What is the "right" way to import eclipse projects and still be able to edit and push/pull?
(Btw. I am using BitBucket and SourceTree and trying to import it into my eclipse workspace. )
Found out what was wrong.
By navigating to "Window > Show view > Problems", I found out that the necessary API wasn't available at that eclipse version. So I downloaded it the software and it worked.
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.
My friend created an android application using phonegap, jquery and facebook sdk in eclipse. I wanted to run the application in my computer. So I imported the whole project into eclipse. I downloaded all the necessary APIs. Initially I got a lot of errors, but I solved most of them.
Now I am stuck with just one error. And it is in the src/com.facebook.android./FbDialog.java file. One particular line
Drawable crossDrawable = getContext().getResources().getDrawable(R.drawable.close);
gives the error R cannot be resolved to a variable.
I have gone through a lot of similar questions on this website as well as other websites. I have cleaned the project innumerable times. The R.java file builds successfully. Also, my friend is not getting any error when he runs the same project in his laptop. So I don't think there is any problem with the coding part.
I am definitely missing some important setting or download. Please help. This one error is giving me a lot of headaches.
I am a new user her so cant upload a screenshot.
1st. res/drawable folders (ldpi, mdpi, hdpi) must contain an image named close, if not add it. I doesn't really mater, in order to overcome the error, in which of them the file exist.
But in order to use resourses properly see the Android documentation here
2nd. File FbDialog.java must have an import of the R.java sometimes the R imports get mixed with clean & built and instead of import your.package.com.R; it is included the import android.R;
Depending on the dependency libraries or related projects of main project the close file resource may be a part of an other library in that case you will need import that.package.com.R;. So if it is part of Facebook SDK then you will need import com.facebook.android.R;
I hope you get the logic of how R imports work.
Update: Lets force it to work, change line to:
Drawable crossDrawable = getContext().getResources().getDrawable(your.package.com.R.drawable.close);
Basically, I need help importing downloaded source or creating a project from sample source programs. I'm looking for step by step instructions for both if anyone can point me there or post the steps.
I'm very new to Android/Eclipse. I have the environments installed and have successfully written a very minor app that works on the emulator and my real Droid X. I cannot, however, get any of the Android samples into a project without errors. I've tried importing, creating from existing source, and etcetera and it's all a mess with errors everywhere.
I have, however, successfully created a new empty project, then brought the components into the project one at a time typing or pasting in code for every file. I'd hover over and import Android and other components as needed. The WiktionarySimple, for example, ran with only a couple of changes and several warnings that I left alone. (I had to add 'formatted="false" in the statements below...)
<string name="template_user_agent" formatted="false">"%s/%s (Linux; Android)"</string>
<string name="template_wotd_title" formatted="false">"Wiktionary:Word of the day/%s %s"</string>
But there has to be an easier way to import! I've done the intuitive and I've followed instructions that I've found, but to no avail. Can anyone give me a complete list as to how to import or create a project from existing source or from source I've downloaded from the web?
Step #1: Start a new Android project
Step #2: In the first page of the Android project wizard, choose the "Create project from existing source" radio button, then click the Browse button and find the directory containing the project
Step #3: Tweak settings to suit, then press Finish
Step #4: If needed (not sure if it is anymore), right-click over the project name, and choose Build Path > Configure Build Path from the context menu, and make sure the Android entry in the checklist is checked
Its quite possible that you are not importing these projects incorrectly and that you are simply running into common problems that occur when importing projects.
For instance your problem involving adding formatted="false" is quite common and due to a change in the strictness of aapt, which is explained in this question. It is likely that the sample project was created before the change and has not been updated since.
That error involving the formatted="false" can also cause many more errors, since any xml after that error is often not parsed and thus any resources declared after it are not known. So the error No resource found that matches the given name (at 'hint' with value '#string/search_hint') and others like it are often due to the formatted="false" error. I would suggest fixing all the % sign errors with the formatted="false" then letting it rebuild and see how many errors are left.
As for the String types not allowed (at 'layout_width' with value 'match_parent') a quick search on stackoverflow says that its caused because FILL_PARENT was replaced with MATCH_PARENT in Android 2.2. So you need to set your sdk for the project to be Android 2.2 or higher. Here is the link to that question as well.
This happened to me in importing the wiktionary sample and i found the solution.
Import the project through existing code
Right click project and choose properties
In 'Android' Tab the default choice is the minimum API. Changed it to the latest(highest API)
Click ok.
Clean and build your project and errors will be gone
(probably optional)
6. Change the target and Minimum SDK in the Android Manifest