Android Resource.getValue 在我的 Google Play Dev console 中崩溃,没有更多信息

Android Resource.getValue crash in my Google Play Dev console without more info

所以我在 Google Play 上上传了一个 Android 应用程序,自从我几天前更新它以来,我遇到了 36 次崩溃,但我找不到它的来源。 当我测试应用程序时,它不会崩溃。这是我进入开发人员控制台时遇到的错误的堆栈跟踪:

   android.content.res.Resources$NotFoundException:
at android.content.res.Resources.getValue (Resources.java:2598)
  at android.support.v7.widget.AppCompatDrawableManager.loadDrawableFromDelegates (AppCompatDrawableManager.java:331)
  at android.support.v7.widget.AppCompatDrawableManager.getDrawable (AppCompatDrawableManager.java:198)
  at android.support.v7.widget.AppCompatDrawableManager.getDrawable (AppCompatDrawableManager.java:191)
  at android.support.v7.content.res.AppCompatResources.getDrawable (AppCompatResources.java:102)
  at android.support.v7.view.menu.MenuItemImpl.getIcon (MenuItemImpl.java:505)
  at android.support.v7.view.menu.ActionMenuItemView.initialize (ActionMenuItemView.java:126)
  at android.support.v7.widget.ActionMenuPresenter.bindItemView (ActionMenuPresenter.java:211)
  at android.support.v7.view.menu.BaseMenuPresenter.getItemView (BaseMenuPresenter.java:188)
  at android.support.v7.widget.ActionMenuPresenter.getItemView (ActionMenuPresenter.java:197)
  at android.support.v7.widget.ActionMenuPresenter.flagActionItems (ActionMenuPresenter.java:477)
  at android.support.v7.view.menu.MenuBuilder.flagActionItems (MenuBuilder.java:1182)
  at android.support.v7.view.menu.BaseMenuPresenter.updateMenuView (BaseMenuPresenter.java:96)
  at android.support.v7.widget.ActionMenuPresenter.updateMenuView (ActionMenuPresenter.java:230)
  at android.support.v7.view.menu.MenuBuilder.dispatchPresenterUpdate (MenuBuilder.java:298)
  at android.support.v7.view.menu.MenuBuilder.onItemsChanged (MenuBuilder.java:1069)
  at android.support.v7.view.menu.MenuBuilder.startDispatchingItemsChanged (MenuBuilder.java:1096)
  at android.support.v7.app.AppCompatDelegateImpl.preparePanel (AppCompatDelegateImpl.java:1631)
  at android.support.v7.app.AppCompatDelegateImpl.doInvalidatePanelMenu (AppCompatDelegateImpl.java:1869)
  at android.support.v7.app.AppCompatDelegateImpl.run (AppCompatDelegateImpl.java:230)
  at android.os.Handler.handleCallback (Handler.java:739)
  at android.os.Handler.dispatchMessage (Handler.java:95)
  at android.os.Looper.loop (Looper.java:148)
  at android.app.ActivityThread.main (ActivityThread.java:7325)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1230)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1120)

在上次更新中,我添加了一个新的 activity 打开一个屏幕,其中包含有关该应用程序的更多信息,因此 InfoActivity:

private TextView rateApp;
    private TextView contactUs;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_info);

        rateApp = findViewById(R.id.rateAppTv);
        contactUs = findViewById(R.id.sendEmailTv);
        rateApp.setMovementMethod(LinkMovementMethod.getInstance());
        rateApp.setPaintFlags(rateApp.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
        contactUs.setPaintFlags(contactUs.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);

        contactUs.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
                emailIntent.setData(Uri.parse("mailto:natasa.andzic1@gmail.com"));
                emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Rick and Morty soundboard app feedback");
                if (emailIntent.resolveActivity(getPackageManager()) != null)
                    startActivity(emailIntent);
            }
        });

        rateApp.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                openAppRating(InfoActivity.this);       }
        });
    }

    public static void openAppRating(Context context) {
        // you can also use BuildConfig.APPLICATION_ID
        String appId = context.getPackageName();
        Intent rateIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appId));
        boolean marketFound = false;

        // find all applications able to handle our rateIntent
        final List<ResolveInfo> otherApps = context.getPackageManager()
                .queryIntentActivities(rateIntent, 0);
        for (ResolveInfo otherApp: otherApps) {
            // look for Google Play application
            if (otherApp.activityInfo.applicationInfo.packageName.equals("com.android.vending")) {

                ActivityInfo otherAppActivity = otherApp.activityInfo;
                ComponentName componentName = new ComponentName(otherAppActivity.applicationInfo.packageName, otherAppActivity.name
                );
                // make sure it does NOT open in the stack of your activity
                rateIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                // task reparenting if needed
                rateIntent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
                // if the Google Play was already open in a search result
                //  this make sure it still go to the app page you requested
                rateIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                // this make sure only the Google Play app is allowed to
                // intercept the intent
                rateIntent.setComponent(componentName);
                context.startActivity(rateIntent);
                marketFound = true;
                break;

            }
        }

        // if GP not present on device, open web browser
        if (!marketFound) {
            Intent webIntent = new Intent(Intent.ACTION_VIEW,
                    Uri.parse("https://play.google.com/store/apps/details?id="+appId));
            context.startActivity(webIntent);
        }
    }
}

和activity_info.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
    android:orientation="vertical"
    android:background="@color/colorAccent"
    tools:context=".InfoActivity">

    <View
        style="@style/info_separator_style"
        android:background="@color/colorPrimaryLight" />

    <TextView
        android:id="@+id/rateTv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:textStyle="bold"
        android:layout_marginTop="20dp"
        android:text="Rate this app"
        android:textColor="#000000"
        android:textSize="36sp" />


    <TextView
        android:autoLink="web"
        android:textStyle="italic"
        android:id="@+id/rateAppTv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:text="Click here"
        android:textColor="#000000"
        android:textSize="24sp" />
    <View
        android:layout_marginTop="20dp"
        style="@style/info_separator_style"
        android:background="@color/colorPrimaryLight" />

    <TextView
        android:layout_marginTop="20dp"
        android:layout_gravity="center"
        android:text="Contact us!"
        android:textStyle="bold"
        android:textSize="36sp"
        android:layout_width="wrap_content"
        android:textColor="#000000"
        android:layout_height="wrap_content" />

    <TextView
        android:layout_gravity="center"
        android:textSize="24sp"
        android:textColor="#000000"
        android:textStyle="italic"
        android:id="@+id/sendEmailTv"
        android:text="Click here to send us an email!"
        style="@style/RtlUnderlay.Widget.AppCompat.ActionButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <View
        android:layout_marginTop="20dp"
        style="@style/info_separator_style"
        android:background="@color/colorPrimaryLight" />

    <TextView
        android:layout_marginTop="20dp"
        android:layout_gravity="center"
        android:text="About"
        android:textStyle="bold"
        android:textSize="36sp"
        android:layout_width="wrap_content"
        android:textColor="#000000"
        android:layout_height="wrap_content" />

    <TextView
        android:layout_gravity="center"
        android:textSize="24sp"
        android:textColor="#000000"
        android:textStyle="italic"
        android:id="@+id/jaTv"
        android:text="Made by Nataša Andžić"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <View
        android:layout_marginTop="20dp"
        style="@style/info_separator_style"
        android:background="@color/colorPrimaryLight" />

    <TextView
        android:layout_marginTop="20dp"
        android:layout_gravity="center"
        android:text="Thanks"
        android:textStyle="bold"
        android:textSize="36sp"
        android:layout_width="wrap_content"
        android:textColor="#000000"
        android:layout_height="wrap_content" />

    <TextView
        android:layout_gravity="center"
        android:textSize="24sp"
        android:textColor="#000000"
        android:textStyle="italic"
        android:id="@+id/thanksTv"
        android:text="Icons - Material Design"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

</LinearLayout>

问题与可绘制文件有关。如果您将任何可绘制文件放在 drawable-v24 中,那么它将在 API 以下版本中给出错误。

查看 也许它会对你有所帮助