I got a problem Slider (Seekbar) doesn't working for me on Android. I got this error:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.tutorme, PID: 16570
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.tutorme/com.example.tutorme.activities.FilterTutorActivity}: android.view.InflateException: Binary XML file line #26 in com.example.tutorme:layout/activity_filter_tutor: Binary XML file line #60 in com.example.tutorme:layout/content_filter_tutor: Error inflating class com.google.android.material.slider.Slider
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3270)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Caused by: android.view.InflateException: Binary XML file line #26 in com.example.tutorme:layout/activity_filter_tutor: Binary XML file line #60 in com.example.tutorme:layout/content_filter_tutor: Error inflating class com.google.android.material.slider.Slider
Caused by: android.view.InflateException: Binary XML file line #60 in com.example.tutorme:layout/content_filter_tutor: Error inflating class com.google.android.material.slider.Slider
Caused by: java.lang.ClassNotFoundException: com.google.android.material.slider.Slider
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:454)
at android.view.LayoutInflater.createView(LayoutInflater.java:815)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1006)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:961)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1123)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1084)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1126)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1084)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1126)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1084)
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:1263)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1119)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1084)
at android.view.LayoutInflater.inflate(LayoutInflater.java:682)
at android.view.LayoutInflater.inflate(LayoutInflater.java:534)
at android.view.LayoutInflater.inflate(LayoutInflater.java:481)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
at com.example.arch.BaseActivity.onCreate(BaseActivity.kt:24)
at android.app.Activity.performCreate(Activity.java:7802)
at android.app.Activity.performCreate(Activity.java:7791)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1299)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3245)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.material.slider.Slider" on path: DexPathList[[zip file "/data/app/com.example.tutorme--82CKvkCUOgphFA8Gwf4Hw==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.tutorme--82CKvkCUOgphFA8Gwf4Hw==/lib/x86, /system/lib, /system/product/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 35 more
And this is how my styles look like:
<resources>
<!-- Base application theme. -->
<style name="Theme.App" parent="Theme.MaterialComponents.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryVariant">@color/colorPrimaryDark</item>
<item name="colorSecondary">@color/colorSecondary</item>
<item name="colorSecondaryVariant">@color/colorSecondaryDark</item>
<item name="colorError">@color/colorError</item>
<item name="colorOnPrimarySurface">@color/colorSecondaryDark</item>
<item name="colorSurface">@color/white</item>
<item name="switchStyle">@style/Widget.App.Switch</item>
</style>
<style name="Theme.App.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="Theme.App.AppBarOverlay" parent="ThemeOverlay.MaterialComponents.Dark.ActionBar" />
<style name="Theme.App.PopupOverlay" parent="ThemeOverlay.MaterialComponents.Light" />
<style name="dialog_image_option_container">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_marginTop">@dimen/basic_indentation</item>
</style>
<style name="dialog_image_option_image">
<item name="android:layout_width">25dp</item>
<item name="android:layout_height">25dp</item>
<item name="android:tint">@android:color/black</item>
</style>
<style name="dialog_image_option_text">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textAppearance">@style/TextAppearance.MaterialComponents.Body1</item>
<item name="android:layout_marginLeft">@dimen/basic_indentation</item>
<item name="android:textColor">@android:color/black</item>
</style>
<style name="Widget.App.Switch" parent="Widget.MaterialComponents.CompoundButton.Switch">
<item name="materialThemeOverlay">@style/ThemeOverlay.App.Switch</item>
</style>
<style name="ThemeOverlay.App.Switch" parent="">
<item name="colorOnSurface">@color/colorSecondaryDark</item>
<item name="colorSecondary">@color/colorPrimaryDark</item>
</style>
</resources>
I got dependency. I migrated to AndroidX. I am using AppCompatActivity(), etc. BUT... I am not able to find solution on Internet, so I'm asking you for first time guys to help me. Thank you.
UPDATE:
Here is layout:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activities.AddEditTutorActivity"
tools:showIn="@layout/activity_filter_tutor">
<androidx.core.widget.NestedScrollView
android:id="@+id/nestedScrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="?attr/actionBarSize"
app:layout_constraintTop_toTopOf="parent"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/half_indentation"
android:layout_marginEnd="@dimen/half_indentation"
android:layout_marginBottom="@dimen/half_indentation"
android:hint="@string/subject"
app:startIconDrawable="@drawable/ic_subject_color_primary_dark_24dp"
>
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/first_name"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/half_indentation"
android:layout_marginEnd="@dimen/half_indentation"
android:layout_marginBottom="@dimen/half_indentation"
android:hint="@string/place"
app:startIconDrawable="@drawable/ic_place_color_secondary_dark_24dp">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/place"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.slider.Slider
android:valueFrom="0.0"
android:valueTo="100.0"
android:stepSize="10.0" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/stars_layout"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:helperTextEnabled="true"
app:helperText="@string/range"
app:errorEnabled="true"
android:layout_marginStart="@dimen/half_indentation"
android:layout_marginEnd="@dimen/half_indentation"
android:layout_marginBottom="@dimen/half_indentation"
android:hint="@string/rating"
app:startIconDrawable="@drawable/ic_star_color_secondary_dark_24dp">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/stars"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="numberDecimal" />
</com.google.android.material.textfield.TextInputLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/half_indentation"
android:layout_marginEnd="@dimen/half_indentation"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/half_indentation"
android:drawableStart="@drawable/ic_computer_color_secondary_dark_24dp"
android:drawablePadding="@dimen/basic_indentation"
android:text="@string/online_class"
android:textColor="?attr/colorSecondaryVariant"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/onlineLecture"
style="@style/Widget.App.Switch"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:layout_marginEnd="@dimen/double_indentation"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/half_indentation"
android:layout_marginEnd="@dimen/half_indentation"
android:orientation="horizontal">
<com.google.android.material.textview.MaterialTextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/half_indentation"
android:drawableStart="@drawable/ic_group_color_secondary_dark_24dp"
android:drawablePadding="@dimen/basic_indentation"
android:text="@string/group_class"
android:textColor="?attr/colorSecondaryVariant"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/groupLecture"
style="@style/Widget.App.Switch"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:layout_marginEnd="@dimen/double_indentation"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/half_indentation"
android:layout_marginEnd="@dimen/half_indentation"
android:orientation="horizontal">
<com.google.android.material.textview.MaterialTextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/half_indentation"
android:drawableStart="@drawable/ic_home_color_dark_secondary_24dp"
android:drawablePadding="@dimen/basic_indentation"
android:text="@string/home_class"
android:textColor="?attr/colorSecondaryVariant"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/homeLecture"
style="@style/Widget.App.Switch"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:layout_marginEnd="@dimen/double_indentation"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
<com.google.android.material.button.MaterialButton
android:id="@+id/saveChanges"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorPrimary"
android:clickable="true"
android:focusable="true"
android:text="@string/save"
app:cornerRadius="0dp"
android:textColor="@color/white"
android:layout_margin="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:insetTop="0dp"
android:insetBottom="0dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
```