У меня возникают проблемы с зависанием моего приложения, когда оно пытается отобразить домашний фрагмент. Он проходит мимо экрана spla sh, но мгновенно падает с журналом cra sh:
time: 1585930432086
msg: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 2: TypedValue{t=0x2/d=0x7f0400c1 a=-1}
stacktrace: android.view.InflateException: Binary XML file line #7: Error inflating class com.google.android.material.card.MaterialCardView
Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class com.google.android.material.card.MaterialCardView
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
at android.view.LayoutInflater.createView(LayoutInflater.java:647)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790)
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:965)
at EdHooker_.hook(Unknown Source:165)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:859)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at EdHooker_.hook(Unknown Source:156)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at com.vanced.manager.HomeFragment.onCreateView(HomeFragment.kt:27)
at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2698)
at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:320)
at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1187)
at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1356)
at androidx.fragment.app.FragmentManager.moveFragmentToExpectedState(FragmentManager.java:1434)
at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1497)
at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:447)
at androidx.fragment.app.FragmentManager.executeOps(FragmentManager.java:2169)
at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1992)
at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1947)
at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1849)
at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:2629)
at androidx.fragment.app.FragmentManager.dispatchActivityCreated(FragmentManager.java:2577)
at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:247)
at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:541)
at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:201)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1391)
at android.app.Activity.performStart(Activity.java:7165)
at android.app.ActivityThread.handleStartActivity(ActivityThread.java:2972)
at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:180)
at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:165)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:142)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1813)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6672)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:495)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:860)
Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 2: TypedValue{t=0x2/d=0x7f0400c1 a=-1}
at android.content.res.TypedArray.getColorStateList(TypedArray.java:546)
at android.content.res.XResources$XTypedArray.getColorStateList(XResources.java:1317)
at androidx.cardview.widget.CardView.<init>(CardView.java:127)
at com.google.android.material.card.MaterialCardView.<init>(MaterialCardView.java:118)
at com.google.android.material.card.MaterialCardView.<init>(MaterialCardView.java:114)
вот код, который я нашел полезным:
AndroidManifest.xml
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.vanced.manager">
<application
android:allowBackup="true"
android:fullBackupContent="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true">
<activity
android:name=".SplashScreenActivity"
android:label="@string/app_name"
android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ui.MainActivity"
android:label="@string/app_name"
android:theme="@style/Theme.MaterialComponents.DayNight.NoActionBar">
</activity>
<activity
android:name=".ui.AboutActivity"
android:parentActivityName=".ui.MainActivity"
android:theme="@style/Theme.MaterialComponents.DayNight.NoActionBar">
</activity>
<meta-data
android:name="preloaded_fonts"
android:resource="@array/preloaded_fonts" />
</application>
</manifest>
small part of home_fragment
:
<layout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto">
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:cardCornerRadius="@dimen/eightdp"
app:cardBackgroundColor="?colorSurfaceVariant"
app:cardElevation="0dp"
app:cardPreventCornerOverlap="true">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/exo_bold"
android:text="@string/title"
android:textColor="?colorPrimary"
android:textSize="24sp"
app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="@dimen/thtdp"
app:layout_constraintTop_toTopOf="parent"
tools:layout_editor_absoluteX="47dp" />
<com.google.android.material.button.MaterialButton
android:id="@+id/installbtn"
style="@style/Widget.AppCompat.Button.Borderless.Colored"
app:backgroundTint="?colorPrimary"
android:layout_width="116dp"
android:layout_height="40dp"
android:text="@string/install"
android:textAllCaps="false"
android:layout_marginEnd="@dimen/eightdp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintHorizontal_bias="1.0"
tools:layout_editor_absoluteY="0dp"
android:fontFamily="@font/exo_semibold"
app:icon="@drawable/outline_cloud_download_24"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
</layout>
Поиск в Google сказал, что проблема в темах, но я использую материальные темы внутри своих тем. xml file themes.xml
<resources>
<style name="LightMode" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<item name="colorPrimary">#1490D7</item>
<item name="colorPrimaryVariant">#2C7EB9</item>
<item name="colorSecondary">#3E78AF</item>
<item name="colorSecondaryVariant">#803E78AF</item>
<item name="colorSurface">#ffffff</item>
<item name="colorSurfaceVariant">#F3F3F3</item>
<item name="colorSurfaceSurfaceVariant">?colorSurface</item>
<item name="colorOnPrimary">#F9F9F9</item>
<item name="colorOnPrimaryVariant">#e8e8e8</item>
<item name="colorOnSecondary">#F9F9F9</item>
<item name="colorOnBackground">?colorOnSurface</item>
<item name="colorError">#CC0047</item>
<item name="colorOnError">#F9F9F9</item>
<item name="colorOnSurface">#444444</item>
<item name="colorOnSurfaceVariant">#BF444444</item>
<item name="colorDisabled">#808080</item>
<item name="colorDisabledVariant">#66808080</item>
<item name="iconColor">?colorPrimaryVariant</item>
</style>
</resources>
I Я пытался добавить тему в <application>
тоже внутри манифеста, но не повезло. Любая помощь?