Find import package for class in intellij idea - android

I have started using Android studio (intellij idea) for Android development (on Ubuntu 18.05) so I am very new to how it works and more used to visual studio :)
When I type a class name from Android API I note that ide mostly won't have suggestion as to which package to include. I find this to be a complete pain. For example if I type " ApiException aex;" IDE won't have any suggestions for what to include and will just report compile error.
I have various android libraries included in gradle and in the imports list so farily sure this class could be discovered by IDE (shouldn't this be java.lang.* or Google play services/GM's which I have in gradle?)
What is the easiest way to find which import I need for a class eg ApiException and is there a shortcut within Intellij to help with this?
Thank you

Related

cannot find symbol class DiskInfo and some other packages despite being present in SDK folder

I have an activity in which i have imported android.os.storage.DiskInfo and some other packages. Android Studio gives errors when trying to make the project saying:
error: cannot find symbol class DiskInfo
When i tried to resolve this problem i found out that all packages are present in folder $SDK-HOME\sources\android-24\android\os\storage but i don't know why Studio couldn't import them properly.
Is there anybody who have experienced problems in import and have solved it?
Thanks
p.s: i am using Android API 24
That is because of #hide in android source code. Actually Android is not allowing developers to use some classes. A solution is to use modified SDK which contains hidden classes. you can find it here https://github.com/anggrayudi/android-hidden-api
Check out : TargetSdk version and support package version.

Cannot import the SimpleCallback class

I want to use the SimpleCallback class from the ItemTouchHelper class as seen below, but somehow the import fails. Android Studio says "cannot resolve symbol ItemTouchHelper".
I looked into the android developer site, but I couldn't find any deprecated marker or something like that.
It seems as if it can still be used.
Android Studio is up to date (2.2.3) and the installed APIs too.
The Android Support Plugin is also activated.
I hope someone can help me. Feel free to ask me for details.
Update: Android Studio can't find the helper class. "...widget.helper".
See below:
import android.support.v7.widget.
That "Android Support" plugin says "yes, this IDE can develop Android apps".
It is not literally the Android Support Library.
Please see how to set that up.
And make sure your gradle file contains
dependencies {
...
compile "com.android.support:appcompat-v7:(pick a version)"
}

How to import "android.support.wearable.watchface" in Eclipse for Android Wear?

I'm doing my best to figure out how to develop apps in Eclipse for Android Wear (I really don't like Android Studio). I have made a couple of apps so far for Android Wear in Eclipse that work perfectly fine, but I'm running into a big problem when trying to create a Watch Face.
I can't import the following:
import android.support.v7.graphics.Palette;
import android.support.wearable.watchface.CanvasWatchFaceService;
import android.support.wearable.watchface.WatchFaceService;
import android.support.wearable.watchface.WatchFaceStyle;
I have added the wearable-1.0.0.aar as a library as discussed here. I have tried adding as an external jar the "android-support-v7-appcomapt.jar" file located at "...sdk\extras\android\support\v7\appcompat\libs", but still no luck.
I am using the "Watchface" example given by google. When using it in Android Studio it works perfectly fine. The exact error I'm getting is:
CanvasWatchFaceService cannot be resolved to a type
Also, in my project under Android Private Libraries I have "classes.jar" and "android-support-v4.jar".
Does anyone have a fix? I figure it has something to do with external libraries and/or a jar I've missed.
Managed to figure it out. For anyone else who comes across this thread, the answer lies in the wearable-1.0.0 library in that it does not contain CanvasWatchFaceService. After looking through some of the other wearable projects, I found that the later versions have it. Just go to ...sdk\extras\google\m2repository\com\google\android\support\wearable. I chose the wearable-1.4.0 version.
Also, I added the external jar "android-support-v7-palette.jar" from the Android tools folder.
Now everything works perfectly for me.

android.support.v13.dreams.BasicDream cannot be resolved

I'm trying to work on extending BasicDream which exists in package: android.support.v13.dreams. I have tried downloading all most all android version (just trying luck to get it working) but I'm unable to import it. i.e. On
import android.support.v13.dreams.BasicDream; statement I'm getting an error:
The import xxxxxx... cannot be resolved.
I tried copying my sdk/extras/libs/../android-support-v13.jar in my libs folder and added to build path but found this package does not show dreams. While typing import statement I'm able to see v13 i.e. I can write import android.support.v13.app.*; but it does not have dreams/basicdream.
Tried google and do found the source code of this class but no idea why my jar file does not have these classes or how to use it. Please suggest what am I missing here.
Update: Finally I figured out that BasicDream was part of Android Support Library version 13 Link: BasicDream source codeshipped with android 4.1.2 however latest Android Support Library version 13 does not have Basic Dream.support library v13 class list
As I'm working on some native functionality, I downloaded BasicDream source code from the link mentioned above and included in same folder where I have my other source files. Updated the package to my application package
In your case probably the best way to get it is to check code of this class on GrepCode and manually resolve (copy) all dependencies. Good luck!

android Programming by using Eclipse Indigo Service Release 2

I'm a beginner of Android Application development need to practice by examples and samples given in the book "Beginning with Android" by Wei Meng Lee, but whenever I try to follow those steps I come across a few errors unable to clean them. The Error seems like this:
" setContentView(R.layout.activity_main);" Don't know what type of error is it. In my computer I've installed SDK API level 16 that is for Android 4.1 What to do? Please guide me through appropriate answer.
Remove import
import android.R;
Than clean build your project also check xml layout file name in
setContentView(R.layout.activity_main);
than it'swork fine.
You should get the latest version of eclipse. Its now Eclipse Juno.
And check your import.
Remove
import android.R;
Instead put
import android.packagename.R;

Categories

Resources