Error when importing com.google, com.android.internal.Telephony, etc - android

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.

Related

Errors when importing someone else's projects - Android/Eclipse

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.

Adding google maps library to existing project creates confusing error

I am building an Android app that I want to open google maps with the click of a button. I want the app to find the current location of the user and give them directions to a predefined address. I started building the application before I realized there were special steps that you have to take to include this functionality. To add this feature to my project I followed the directions on these two sites:
https://developer.android.com/google/play-services/setup.html
https://developer.android.com/tools/projects/projects-eclipse.html#ReferencingLibraryProject
The problem is on the second site, when i added the library to my already existing project it caused all of my code that has findViewById(R.id.whatever) or setContentView(R.layout.whatever) to become errors. It is now telling me that i need to import the class R. If I do that it then gives me error messages on the names of all my xml files.
For example in my MainActivity it is telling me that i should change setContentView(R.layout.activity_main) to setContentView(R.layout.activity_list_item) and does this for all references to my xml files for the entire project.
I tried going back and removing the google play services library from the project and starting over but when I removed it the errors still persists. I also tried using the "fix project setup" option in Eclipse but it didn't fix the problem.
I'm wondering if anyone here has experienced this problem before? If so, how can I fix it? The application had no errors before I tried to include the google play services library. I am new to Android development so a lot of the information I have found has been either confusing to understand or doesn't seem to include enough details for me to figure it out. Thanks for your help!
Look at your imports, and check if you are importing the correct R.java from your application package, not from the android package.
Check also if your XMLs don't contain errors, otherwise R.java won't be generated.
In my case android-maps-library had to errors in two files (I have forgotten their names), I edited the two files removing errors my self. And finally I was able to used it quite nice.
i think you have correct yout Project build target, and this how:
right click on your project folder in the package explorer->propreties->Android
then porject build target and choose you Android target (Android x.xx)
but before that you need to remove import android.R;

Importing and using a library in android studio

I am using android studio to import this project called https://github.com/Pixate/pixate-freestyle-android. However when I import it into android studio the folder under samples, freestyleshowcase doesnt seem to build. The other 2 samples buld correctly. There is a red circle around the java file with a J (error) but there is no error in the file itself. COuld someone please help me out?
You are obviously missing some libraries but it is going to be hard for anyone to tell you which since we do not know the libraries the project needs.You can try Build-->Rebuild Project or Build-->Clean Peoject if it still doesn't work, close and open Android Studio.
If that doesn't work also then you have to go the hard way of identifying the libraries need by the project samples you imported and see if you have them.
When in doubt, you can try the Library Dependency option (using Maven) as demonstrated here:
https://www.youtube.com/watch?v=6BUcx9gGQ3o
That way, you won't have to manually edit the build.gradle file.

Android ADT Eclipse: com.android.common and com.android.ex imports could not be resolved

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 :)

What can I do with R cannot be resolved problem?

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)

Categories

Resources