NotificationCompat difficulties in Koitlin - android

I've been trying to follow
https://developer.android.com/training/notify-user/expanded
in order to create a media notification. My SDK target is 21+.
I got a basic notification working but when I got to doing the media one I've had this problem:
import android.support.v4.app.!NotificationCompat!
import android.support.v4.media.!app!.NotificationCompat as MediaNotificationCompat
The two exclamation marked items (NotificationCompat and app) turn red in the editor and I can't use them :(
What do I need to do to get to the media style?
Notes:
I have this implementation "com.android.support:support-compat:28.0.0" in my application build filee
It's underlined suggesting I move to androidx but I don't think that's an option?

I can't speak for where the old Android Support edition of NotificationCompat.MediaStyle might be hiding. In AndroidX, you can find it in the androidx.media:media artifact. Right now, the latest stable version is 1.1.0, so you can add:
implementation "androidx.media:media:1.1.0"
to your dependencies to pull that in.

Related

Suddenly after implementing firebase many import statements becomes unused and can't resolve many symbols

I'm new to Android, Was learning from youtube from following playlist
https://www.youtube.com/watch?v=d1T0ptCAs8A&list=PLraJmOvF9eeGyVClKdBaVU6O_XqQjNboS&index=5
In 4th video it was teaching to add Firebase, but it was old method as I got some new option on Firebase(Firebase was saying It needs only classpath 'com.google.gms:google-services:4.2.0')
suddenly after adding this line in build.graddel in project I saw that my previously working code have some errors
I tried Invalidate cashes and restart, cleaned projects and rebuild.
It seems you are mixing support library and androidx
either use androidx(recommended) or support library
follow https://developer.android.com/jetpack/androidx/migrate guide and after this make sure to make appropriate changes in layout xml files also.
Remove the dependencies with androidx starting. Because androidx is a different library than support library. You should only include one of them.

Flutter Android Support Library Not Recognized

I am writing a Flutter wallpaper app and am calling Android Specific code and I need to ask the user for some permissions, I need to import ContextCompat for that but there is not option to import in the quick menu, so I read online and manually did it.
import android.support.v4.content.ContextCompat
The problem is that Android Studio can't resolve the support symbol, I also read some forums online about that as well. The most common answer I found was to include add the android support library in the Gradle, which I have already tried but did not work.
Any help would be dearly appreciated.
com.android.support:appcompat-v7 should automatically take care of the dependency of ContextCompat
e.g. adding following in the dependency -
implementation 'com.android.support:appcompat-v7:26.1.0'
Here the version 26.1.0 would depend on your compile version.

setting library versions issue

Setting the right versions for Gradle dependencies has always seemed, to me, to be an arcane science. For instance take the following line . . .
implementation 'com.firebaseui:firebase-ui:+'
If I build the project with that line I get version 12.0.1 which should be the latest version. No?
If I place my cursor on the + and hit alt-enter and choose "Replace with specific version" I get version 2.1.0. I recall reading somewhere that I should get the latest version stated specifically instead of, in this case, 2.1.0.
So I guess the most dependable way to find the latest version of a library is to compile with + and look to see what I get.
When there is an update android studio show a warning and a mouse over is enough to show you the latest library.
This works great for all google-android components.
For other third party libraries I usually add a link comment in order to check regularly if there is something new.
Note that in the white theme the warnings are not so clear as in the black theme.

Error msg: using version 1.0.0-alpha2 of the constraint library which is obsolete

I am using android.support.constraint.ConstraintLayout in my layout file and I get the following error message. I am not able to find what is the right compile line to use in gradle.
My gradle file has this:
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha2'
I tried many version, but i couldn't solve the issue!
Finally i let Android Studio to solve this issue.
In the XML file, Beside error message you can see this option! Click on that to import reccomonded version
or you can press alt+enter placing your cursor on error line
I got constraint-layout:1.0.0-alpha8, when i pressed alt+enter
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha8'
Tactically, alpha7 works.
In the future, I would imagine that Android Studio will provide better indicators of what the latest version is, just as it does for the classic Android Support libraries. However, Android Studio 2.2 and ConstraintLayout are each in pre-release form at the moment, so we're subject to their limitations.

Action Bar for android < 3.0

I want use ActionBar for my application but i found it can't use for android < 3.0.
I found this https://github.com/johannilsson/android-actionbar to solved my problem but I get error at
import com.markupartist.android.widget.ActionBar;
import com.markupartist.android.widget.ActionBar.Action;
import com.markupartist.android.widget.ActionBar.IntentAction;
Give ActionBarSherlock a try. I use it for one of my projects and after some reading of the docs and the samples it just worked. The samples are easy and straight forward, you should be able to extract what you need from them.
To see what it's able of just download the sample app from the market: Sample App (requires at least Android 1.6)
You should add the code to a library, and add the library to your project.
To do this in Eclipse create a new project, using the same package name as the github project (so com.markupartist.android.widget). In the properties select the project to be a library under the Java Build Path tab. Then, in your project, go to its properties, and select the library.
I think your including files are missing (JAR libs) , Click on error icon and then select fix project setup.
I spent around 10 hours trying to fix this problem. All the above ans does not work. Actually what is missing is android support library. To fix this, right click on project, >Android Tool> Add Support Library. Hope this save alot of time for other who came across this. just add support library both on your ActionBar library and the current project.

Categories

Resources