I am developing an application for the company I work for and I am running into an issue with Eclipse. I've been looking online all over and I cannot seem to find a fix for this specific issue. I have changed import android.R; to import com.company.projectname.R; however I get the error "The import com.company.projectname.R cannot be resolved" obviously I replaced company and projectname with the appropriate values.
Here is an example of what the imports should look like:
import android.os.Bundle;
import android.util.Log;
import android.app.ActionBar.Tab;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.app.ActionBar;
Notice I don't import com.company.projectname.R; Make sure your sdk is updated... After you have done that clean the project.. And rebuild it. You should be fine :D
-Monkey
Try to clean the project, sometimes clean my projects have solved my problems on Eclipse/Android.
If it doesn't work, you can see there if it corresponds with what you did:
Question like yours
Related
I want to make a login with Google+ login button like this Tutorial
I have copied the codes, set google_play_services libraries, added package name and SHA1 key in google api console, but there are some import errors :
This import is not an error :
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.common.SignInButton;
import com.google.android.gms.plus.model.people.Person;
But this import an error (cannot be resolved) :
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks;
import com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener;
import com.google.android.gms.common.api.ResultCallback;
import com.google.android.gms.common.api.Status;
import com.google.android.gms.plus.Plus;
Anybody have a solution ?
Add this in yourbuild.gradle(app) inside dependency
compile 'com.google.android.gms:play-services:8.1.0'
[Solved]
I try to download new version of google-play-services library and import error is gone.
So, always update/download newest version of google-play-services library..
You need to add the dependency to your app.
Instructions for eclipse here
http://developer.android.com/google/play-services/setup.html
You can also do this by right clicking on your app (if you're using Android Studio) selecting Open Module Settings, going to the dependency tab. Then Clicking the "plus" at the lower left, select library dependency, then find play-services
I'm trying to implement the google play services in my app. I have successfully imported BaseGameUtils library from GitHub, referenced the GooglePlayServicesLib to the library, but it has a really annoying error...
This is part of the GameHelper.java file :
import com.google.android.gms.appstate.AppStateManager;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.games.Games;
import com.google.android.gms.games.GamesActivityResultCodes;
import com.google.android.gms.games.multiplayer.Invitation;
import com.google.android.gms.games.multiplayer.Multiplayer;
import com.google.android.gms.games.multiplayer.turnbased.TurnBasedMatch;
import com.google.android.gms.games.request.GameRequest;
import com.google.android.gms.plus.Plus;
Everything is OK except the import com.google.android.gms.games.request.GameRequest; line which is underlined with the error message : com.google.android.gms.games.request cannot be resolved
I have no idea about how to solve this problem, and I see that the help community around google play games services is not as large as I would have bet...
any help would be welcome ! :)
I ran into the same problem. What fixed it for me was updating the google play-services library to a newer version.
Update the google play services library to the latest version. Thanks
I have imported a project from a book on Android development and I am currently getting warnings icons appearing next to a number of imports at the start of my project. When I hover over the warning icon the message that appears is as follows...
"The import java.io.IOException is never used"
I received these warning before on another project and when I imported a the necessary library the warning icons disappeared. My problem is that I do not know which library to import to resolve the warning symbol next to the following statements in my .java file...
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.text.ParseException;
import java.util.GregorianCalendar;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
I assume you're using Eclipse. Go to Source -> Organize Imports. The unnecessary imports should automatically be removed and only the ones really needed should remain.
Remove
import java.io.IOException;
this is not a problem and you don''t need to import any library to fix this.
All you need to do is "organize imports"
Option 1: right click in the editor ->Source->Organize Imports
Option 2: press [Ctrl]+[Shift]+o
"The import java.io.IOException is never used"
This warning means that you have imported a class java.io.IOException that you are not using in your code. This is not a compiling error so you don't have to fix it in order to run correctly your project.
Anyway if you wanna make the warning vanish there are many ways.The fastest one is to just eliminate this line. If you are using Eclipse and you have many warnings like this then the fastest fix is to put the mouse cursor over the yellow underlined text and wait the open of the quick-fix panel of Eclipse. In this panel you can chose both "remove unused import" or "Organize import". Both this system will remove all your unused import. There is also a third option: "#Suppress warnings". In this case you shouldn't use this option because it will only hide the warning not solving the problem.
Eclipse quick-fix is a powerful feature, using it will fast your code writing a lot so you should start practice it ^^
This kind of error are quiet often in project because many programmers doesn't care a lot for the "unused import warnings" and through the code change they forget to remove useless import
I've been looking far and wide for solutions to this but alas in my sample project I still get the following errors
"The method isDetached() is undefined for the type Fragment"
"The method detach(Fragment) is undefined for the type FragmentTransaction"
What is the matter here? I have the following imports
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
import android.widget.TabHost;
import android.widget.TabHost.TabContentFactory;
And I use SDK version 8
<uses-sdk android:minSdkVersion="8" />
Make sure that the jar file you're importing is the most recent one. There are a few android-support-v4.jar files and I've caught a few differences in the APIs they implement.
Download it again and make sure that you import the most recent file in eclipse.
I am trying to use Google's places API. I downloaded google-api-java-client-1.6.0-beta.zip library and I'm using source code from https://github.com/tuthan/Google-Place-Api-Demo
I import the external library in exactly the correct way, but the code still give me compile time errors on all imports of google-api-java-client-1.6.0-beta.zip.
e.g.
import com.google.api.client.googleapis.GoogleHeaders;
import com.google.api.client.http.GenericUrl;
import com.google.api.client.http.HttpRequest;
import com.google.api.client.http.HttpRequestFactory;
import com.google.api.client.http.HttpRequestInitializer;
import com.google.api.client.http.HttpResponseException;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.http.apache.ApacheHttpTransport;
import com.google.api.client.http.json.JsonHttpParser;
import com.google.api.client.json.jackson.JacksonFactory;
I've been working on this for a week, but have been unable to solve it.
The dependency jars are not in your classpath. Please add the jar from google-api-java-client-1.6.0-beta.zip to your sample project.