Mutiple dependency declarations to missing classes in 'SQLiteDatabase' class - android

I imported the 'SQLiteDatabase' class present in 'android.database.sqlite' package, into my project.I went into the class declaration to find the opendatabase function, but i noticed that the class was full of errors and was importing certain undefined/undeclared classes, like:
import android.annotation.IntDef;
import android.annotation.IntRange;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.database.sqlite.SQLiteDebug.DbStats;
import android.os.SystemProperties;
These classes are used throughout the 'SQLiteDatabase' class.
I tried to invalidate caches and restart the AS IDE, but the error still persisted.
I went into the sdk manager and downloaded all the required core android packages, but still nothing changed.
Finally, I checked out the documentation to see if something was wrong with my sdk. The documentation too did'nt recognize these import calls. like, android.annotation package does'nt even declare a IntDef or IntRangeclass, which has been imported in SQLiteDatabase. It gives the same, could resolve symbol error.

After doing research for a while, I found an answer to my own question. I'm answering just in case it might help others stuck in this error/problem. The classes that were imported are hidden classes, tagged with annotation #hide.
Refer to this article for more.
Hidden classes (even if they are public in the Java sense) are removed from android.jar file containing specific platform API dependencies, like API level 27. Hence you get the error when you try to import something like Nonnull, service manager, etc . Hidden classes are those that Google does not want to be part of the documented public API.

Related

android.media package missing few classes in sdk-platforms[android.jar]

I am trying to build a FM Radio kind of application and I cloned this Google Respository for the reference.
However There are few classes in the imports which are missing in android sdk. I tried changing compileSdkVersion from 18 to 24 but android.jar seems to be missing these Following imports:
import android.media.AudioManager.OnAudioFocusChangeListener;
import android.media.AudioManager.OnAudioPortUpdateListener;
import android.media.AudioMixPort;
import android.media.AudioPatch;
import android.media.AudioPort;
import android.media.AudioPortConfig;
import android.media.AudioDevicePort;
import android.media.AudioDevicePortConfig;
Where exactly are these classes and how can i import them ?
The Strange thing about them is they are present as .java files in sources/android-xx but not in actual .jar file.
The sample is showing errors and I am not able to proceed. Please guide me how to resolve this issue.
You can see from the Android source code that these classes are "hidden" from the jar using the "pseudo-annotation":
/* #hide */
For example, see here and here.
This annotation controls what will appear in the runtime Android.jar.
Note, sometimes these hidden classes are later included as part of the official SDK.
Refer to:
https://commonsware.com/blog/2018/01/18/think-hard-about-hide.html
What does #hide mean in the Android source code?
What exactly does Android's #hide annotation do?

Imported library package does not exist in Java project

I created an Android project and imported a library using its source code. I added it as an existing module.
When my project referenced a library class, the IDE offered me to import the package. It did it without problem. I compiled the library and it was okay.
I used this import:
import eu.janmuller.android.simplecropimage.CropImage;
When I compiled again, the source code shows no errors, yet I get these errors:
java: package eu.janmuller.android does not exist java: package
eu.janmuller.android.simplecropimage does not exist
So the IDE offered me the package as it knows it. On second thoughts, it does not.
What should I set?
I renamed the imported module once so when I restarted the IDE, it was marked with a number (CropImage1) but it compiles now. If I rename it again, it won't compile.
NEVER rename anything when dealing with modules!

How can I import com.android.internal.telephony?

I downloaded an Android Project and got some errors.
How can I use this imports in Android?
import com.android.internal.telephony.IccSmsInterfaceManager;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneFactory;
import com.android.internal.telephony.SMSDispatcher;
When I import this, I got errors like these:
The import com.android.internal.telephony cannot be resolved
The import com.android.internal.telephony cannot be resolved
The import com.android.internal.telephony cannot be resolved
The import com.android.internal.telephony cannot be resolved
Later in the code there are:
Phone phone = PhoneFactory.getDefaultPhone();
With the error:
Multiple markers at this line
- Phone cannot be resolved to a type
- PhoneFactory cannot be resolved
And so on...
I tried to fix it with the https://stackoverflow.com/a/16377968/3203914
but I did not work for me.
Can please someone tell me how to fix it?
Thanks!
How can I use this imports in Android?
Those are not part of the Android SDK. If you are editing the Android source code, the build process for it should resolve those imports. If you are trying to write an Android app, you cannot directly reference them. In fact, com.android suggests they are part of a separate app, not yours and not the Android framework.
CommonsWare is correct, its not in the SDK so you cannot directly reference them. You will either have to
Import all of the android source code, which will resolve these issues
Import the specific project containing this code, then set up your code as a dependency
Stop using those packages

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!

"The import net cannot be resolved"

I have an Android project in Eclipse that previously had one library imported, zbar. And now something peculiar happened when I added a second library, one which I put together myself. At first, the project wouldn't build because of android-support-v4 mismatch. So I updated the minSDK of my application project to reflect the one in my library. That seems to have worked.
Next, I wanted to make use of my new library, so I created an object of a type defined inside it, and thus had to import the code. What happened next was Eclipse started to complain about one of the imports to zbar.
import net.sourceforge.zbar.Symbol;
And what i don't understand is, it says "The import net cannot be resolved", and only the word "net" is underlined in red. As if it didn't see the period following "net". What's going on here?
I have tried removing the library and then adding it, as well as changing the minSDK version back. Nothing has worked so far.
edit: I think removing the android-support-v4 from my custom library solved this.

Categories

Resources