Reputation: 1752
I was learning android notification tutorial using this link but when I started using
Notification notification = new NotificationCompat.Builder(this, App.CHANNEL_1_ID);
this code, I can't import android.support.v4.app. NotificationCompat , how to do that? It only imports
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;
import android.app.Notification;
Upvotes: 0
Views: 7085
Reputation: 698
androidx is new support library for the replacement v4.support library. And androidx is recommended. I suggest you to use search filter to find tutorial later than 2020~2021.
However you can still use v4.support library by checking "Use legacy android.support library" option while creating a project.
While this is not enough, because latest build tools will not support deprecated libraries, you have to keep compleSdkVersion 28 or below. You are also required to downgrade your Android Gradle Plugin to 3.6.4 and gradle wrapper to 6.0
Make sure these lines are not present in gradle.properties
android.useAndroidX=true
android.enableJetifier=true
Now you can follow the above tutorial.
Use
android.arch.core:core
android.arch.core:common
instead of
androidx.arch.core:core-common
androidx.arch.core:core
Here is the full list of equivalent artifacts of support library to androidx
I do not recommend you to follow above tutorial find latest tutorial. Tech is rapidly changing, following an outdated tutorial might slow your learning process and keep you behind.
Upvotes: 1