I have been using Eclipse for about 6 months now, and I noticed that I rarely can import someone else's project into Eclipse. I get so many errors in many files. For example, I tried to import a friend's project that I know works just fine, but I get a lot of "R" errors, like Eclipse can't recognize "R" as a field, and then other weird ones like ActionBarActivity is not recognized or an entire imports like android.support.v4.app.Fragment that visually are in the library but are not being recognized by Eclipse as being there, and I check them and they are definitely marked "Is library" and added properly to the project. Anyone know why this is or how to fix? It's frustrating because to learn, sometimes you need to see someone else's app run first, then look at their code, but you can't. Thanks in advance.
My usual way of importing a project is to do File -> Import -> General -> Existing Projects into Workspace. Also, I have tried cleaning the project, but it doesn't work.
try this File -> Import -> Android -> Existing Android Code into WorkSpace ->then browse-> select your project->make sure the checkBox"copy the project into workSpace" is marked
Check your Build Path. In the Android Section, try using some other API level click on Apply and after your project finishes with the building workspace, again revert back to the original API and click on OK.
Also check for any Build Path errors.
So thanks to the help of everyone of this post, and others on another post, the problem was finally fixed and took several steps.
Turns out that the ActionBarActivity error had a quick fix (hover over it, you get quick fix options) of importing the appcompat_v7 library. I never chose that before, because I thought it was already installed, hence the conflict with android-support-v4.jar (meaning there were doubles of that library), but I chose to import it anyway and that error went away.
But I discovered that android-support-v4.jar was actually a component of appcompat_v7, so that was causing the "Jar mismatch!" error in the console. So I deleted android-support-v4.jar from the libs folder, and the jar mismatch went away.
Lastly, my layout files were all not being recognized, even though I knew the variable names were all correct. So the error was from when I tried to refresh my imports in the very beginning of the problem (using shift+command+O), thinking it was an import problem (which it was), but at that time, refreshing did nothing. BUT... Eclipse took away import com.laurengariepy.android.gridimagesearch.R; and replaced it with android.R;, which is what was causing all the layout errors. So once I put that com.laurengariepy.android.gridimagesearch.R; back, then all errors went away.
So the take-away to this story, is be careful with Eclipse version 22.6. The auto-import of the appcompat_v7 library will cause a lot of trouble when you try to import other people's projects, because they were likely not created in an IDE with appcompat_v7 already there.
Related
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.
I know this has been asked like a hundred times but the solutions aren't working for me. I want to import PagerSlidingTabStrip into my project. I am running Android Studio 0.3.7. I have tried adding it through the project structure and manually adding the files and editing the build.gradle. Both times it gave me the same error :
A problem occurred evaluating project ':test'. Project with path ':libraries:PagerSlidingTabStrip:PagerSlidingTabStrip' could not be found in project ':test'.
Since both times it gave me the same error I feel it has something to do with the library itself. How do I fix this?
Oh! Also I was struggled into while several days.
I solve this problem and solve it by using this way.
please follow this guide line.
How to import external library in android studio?
after finish your steps, just go to PagerSlidingTapStrip module -> src -> AndroidMenifest.xml
then just add 1 line
then all of things go well. If you have other question, commnet here.
Ok I fixed it! Or did I.. I am really unsure as to what is going on here but I will explain what I did anyway... Just in case someone else going through this.
So when I went to add my library in project structure this is what I saw (ignore the error for now, you shouldn't see it):
This is not what you should be seeing. Anyway I tried adding in dependencies but it did not work. It would just create a folder inside my project but not do anything with it. I couldn't find anywhere to delete that folder so I went and did it manually through explorer. After I came back and tried to make it gave me an error saying it couldn't find the folder I deleted. I restarted Android Studio and went back in to Android Structure to be greeted with a very similar error (instead it was saying it couldn't find the folder). I clicked on the go to source and it took me to the ACTUAL project structure page:
I feel like I might have done something stupid to cause this but I can't get back into those settings again... but on the bright side my library is added.
I'm trying to build Google's open-source Calendar app for Android (source here: https://github.com/android/platform_packages_apps_calendar), so that I may pick apart its code a little bit. When I import the freshly-cloned project into eclipse, I get a bunch of ____ cannot be resolved to a type errors. Looking closely at the types that aren't resolved, the root cause seems to be:
The import com.android.common cannot be resolved
The import com.android.ex cannot be resolved
I've been googling and I can't seem to figure out what's going on? I must be missing some library? I have everything in the Android SDK Manager installed, even the optional libraries. I've tried cleaning and fixing build path properties, etc. The errors remain.
Anyone have any idea what I can do to get this thing to compile?
I have managed to add almost all the required dependencies and now i got an almost-running version.
Kindly, check it out from here
You can also check the last commit, it contains all what i did to get this running version.
Have a nice day :)
If I make a new Android project in Ecplipse and I try, to open one of the samples from android SDK, I have got an error, look like this:
R cannot be resolved
What can I do, to be able, to run these files? I tried to delete import android.R; but nothing changed.
Thanks
First thing you might try is "clean" your project (option in the menu). If it persists:
There should be an error that stops R from being generated. Check the "problems" tab (?) in eclipse to see what that problem is, and solve that. It could be missing libs, or various other stuff.
You possibly got error in building resources.
Possible fixes:
-refresh your project (F5)
-clean you project and refresh
-see "Console" tab, sometimes the problem is shown there
-reload the Android SDK
-restart the Eclipse IDE
Check your XML-Layout files. The problem come here half a time.
If you are sure it is note your layout file, check in your java build path if the google librarys are well set. (Google APIs)
(sorry for my bad english)
I've downloaded the android source code for CallLog, Contacts, Dialing from here.
But now, when I try to import this package on Eclipse, imports like:
com.google,
com.android.internal.Telephony,
com.android.internal.R,
com.google.android.collect,
android.provider.ContactsContract.Intents.UI,
android.provider.ContactsContract.SearchSnippetColumns,
android.provider.ContactsContract.ProviderStatus,
android.provider.ContactsContract.ContactCounts,
android.content.IContentService,
android.provider.ContactsContract.Intents.UI
And many other imports, show errors saying it cannot be resolved.
So my question is, why it shows this errors? Why I cant implement it without this errors? I use the Google APIs, I've created the project from an existing source code, but I dont know why this happens.
If you're sure that you have set up the Android SDK correctly, you should try to 'clean' your Eclipse project.
This usually solves import related errors in Eclipse for me.
Try right clicking the solution / project in the project explorer and choose "fix" near the bottom.