So I have an Android app uploaded on Google Play, and since I updated it few days ago, I got 36 crashes but I cannot find the source of it. When I test the app, it doesn't crash. This is the stack trace of the error that I get when I go in my developer console:
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$2.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)
In the last update, I added a new activity that opens a screen with more information about the app, so 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);
}
}
}
And 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>
problem is related drawable file. if you placed any of your drawable files in drawable-v24 then it will give an error in below API versions.
see this answer maybe it will help you