-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crash: Resources.NotFoundException in AppIconCache #26
Comments
Yeah you're right! Thank you for reporting this. :) |
I looked into this. The method getDrawableForDensity() throws a Resources.NotFoundException when the given id does not exist or is invalid (id=0). This won't happen because we get the app icon id from the PackageManager and fall back to the default android icon (android.R.mipmap.sym_def_app_icon) when the app doesn't have an icon. getDrawableForDensity() - Throws NotFoundException if the given ID does not exist.: Default android icon fallback code: ArtistGui/app/src/main/java/saarland/cispa/artist/artistgui/applist/loader/AppListLoader.java Lines 118 to 119 in b444641
|
How is the state on this one? Is this resolved? |
It is not resolved. A Resources.NotFoundException is thrown on my phone. Can be fixed by catching the exception and returning a default icon. try {
Context mdpiContext = mContext.createPackageContext(packageEntry.packageName,
Context.CONTEXT_IGNORE_SECURITY);
appIcon = mdpiContext.getResources().getDrawableForDensity(packageEntry.appIconId,
DisplayMetrics.DENSITY_XHIGH, null);
put(packageEntry, appIcon);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
} catch (Resources.NotFoundException e) {
return mContext.getDrawable(android.R.mipmap.sym_def_app_icon);
} |
Could you provide a stack trace, please? (adb logcat) |
Don't worry I think I know what the problem is. We load all our icons with mdpiContext. Even if there is no app icon we try to load the default icon with the same context object. Low resolution devices don't have the needed resources. |
This is still a problem. My ArtistGui crashes while scrolling through the app list:
The fix suggested by @alexcekay solves this issue for me. |
(cherry picked from commit 5888ad5)
(cherry picked from commit 5888ad5) (cherry picked from commit f3830ab)
(cherry picked from commit 5888ad5) (cherry picked from commit f3830ab)
ArtistGui/app/src/main/java/saarland/cispa/artist/artistgui/packagelist/view/AppIconCache.java
Line 55 in efa7d3d
getDrawableForDensity
might throw a Resources.NotFoundException which causes the App to crash.
Since appIcon already can be null, just catch this Exception too. Might be nicer to return the default-Icon.
The text was updated successfully, but these errors were encountered: