Android Studio doesn't see these annotations, now I can't make my AsyncTask works. What's wrong?
import android.annotation.MainThread;
import android.annotation.Nullable;
import android.annotation.WorkerThread;
You have to add the support-annotations dependency in your build.gradle e.g
dependencies {
compile 'com.android.support:support-annotations:24.2.0'
}
See here Improve Code Inspection with Annotations
Try to replace using of android.annotation.* by android.support.annotation.*
see https://developer.android.com/studio/write/annotations.html
The problem is because you are incorrectly using import code.
Instead of this:
import android.annotation.MainThread;
import android.annotation.Nullable;
import android.annotation.WorkerThread;
It should be:
import android.support.annotation.Nullable;
import android.support.annotation.Nullable;
import android.support.annotation.WorkerThread;
Related
I have a problem in my android studio(macosx) :
in InetAddress.java some import have problem
import sun.net.util.IPAddressUtil;
import android.system.GaiException;
import android.system.StructAddrinfo;
import libcore.io.Libcore;
editor says
cannot resolve symbol IPAddressUtil
I think those classes are not in Android SDK (IpAddressUtil, Libcore). Also, it is discouraged to use classes from sun.* package in your programs.
I'm trying to get the metadata of a file in my Google Drive through the fileID but I'm running into some problems using files().get and getRequestFactory().
Specifically I'm looking at this and on the sample it shows the line
File file = service.files().get(fileID).execute(); and
HttpResponse resp = service.getRequestFactory().buildGetRequest(new GenericUrl(file.getDownloadUrl())).execute();
I used these:
import com.google.api.client.http.GenericUrl;
import com.google.api.client.http.HttpResponse;
import com.google.api.services.drive.model.File;
as stated in the sample and loaded the com.google.apis:google-api-services-drive:v2-rev168-1.20.0 dependency. But it's still resulting in Cannot resolve method files() and Cannot resolve method getRequestFactory(),
Can anyone shed some light on this?
I have recently run my project with these imports / dependencies without problems, try to double-check your situation
import com.google.api.client.extensions.android.http.AndroidHttp;
import com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential;
import com.google.api.client.googleapis.extensions.android.gms.auth.UserRecoverableAuthIOException;
import com.google.api.client.googleapis.json.GoogleJsonResponseException;
import com.google.api.client.http.FileContent;
import com.google.api.client.http.GenericUrl;
import com.google.api.client.json.gson.GsonFactory;
import com.google.api.services.drive.Drive;
import com.google.api.services.drive.DriveScopes;
import com.google.api.services.drive.model.File;
import com.google.api.services.drive.model.FileList;
import com.google.api.services.drive.model.ParentReference;
com.google.api.services.drive NEEDS
com.google.apis:google-api-services-drive:v2-rev105-1.17.0-rc
com.google.api.client NEEDS
com.google.api-client:google-api-client-android:1.20.0
com.google.api.client.json.gson NEEDS
com.google.http-client:google-http-client-gson:1.20.0
The chunk above is pulled from this GitHub test / demo. You're welcome to use it (replace the GDAA referencies in MainActivity with 'REST').
Good Luck
i'm getting the error
"import android.media.image cannot be resolved" I searched the web for solution but couldn't find any thing
would you tell me what to do in order to fix this problem
thanks
I think you cannot import android.media; because it is a package, try to add this line
import android.media.*;
or
import android.media.MediaPlayer; // if you want to import MediaPlayer
import android.media.Ringtone;`
Import as
import android.media.*;
i added this line.but it gives error.how to import it?
import org.andengine.opengl.texture.atlas.TextureAtlas;
TextureAtlas is an abstract class, try importing
import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlas;
or
import org.andengine.opengl.texture.atlas.bitmap.BuildableBitmapTextureAtlas;
depending on which one you are using
If you using Eclipse and it is configured properly, you should be able to just delete that line and Eclipse will add the correct import statements - at least it does on my system.
i try create my first android application for android 2.1 api level 7 in ADT. I wrote the following line to the default view and eclipse says, that android.media cannot be resolved:
import android.media;
how come, that this doesn't work?
thanks a lot
you cannot import android.media; because it is a package, try using:
import android.media.*;
or
import android.media.MediaPlayer; // if you want to import MediaPlayer
import android.media.Ringtone; // if you want to import Ringtone