Reputation: 55
I am a newbie to both Android Programming and StackOverflow. This is my first question, however I have used the StackOverflow platform before for solutions here and there. Now, to my question. I have an Android app that used to run fine on all android devices from SDK 11. However, on an update to SDK 25 it crashes on pre-lollipop devices.
My log cat is as follows:
Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering
I have included vectorDrawables.useSupportLibrary = true
in my gradle. My minSdkVersion = 11
, targetSdkVersion = 25
, supportLibraryVersion = 25.2.0
I have tried all the suggestions I could find here but none works. So please guys I need your help. I am eager to learn so that I can fix this problem.
Thanks.
Upvotes: 3
Views: 391
Reputation: 55
Debugging can be a pain sometimes and the question above was a result of a simple mistake in my original code. Humans are to err ...
Now to the solution. My initial code was as follows and if you look keenly you will note that the initialization code between the if statement that checks the Build.Version
does not run if the device is below version 23.
if(Build.VERSION.SDK_INT >= 23) {
if(checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
// Storage permissions is already available, save profile photo
initialization();
} else {
// Providing additional rational to the user if permission was not granted
if(shouldShowRequestPermissionRationale(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
Toast.makeText(this, "Storage permission is needed to save your profile photo.", Toast.LENGTH_LONG).show();
}
requestPermissions(new String[] {Manifest.permission.READ_CONTACTS}, WRITE_EXTERNAL_STORAGE);
}
}
This is the initialization method. In devices with Android version lower than 23, it did not run thereby triggering the Could not find class
error. However I still haven't figured out how this is related to Ripple Drawable because am not using Vector Drawables anywhere in my code. So anyone who gets to read this might shed some light onto the cause
private void initialization() {
hoverView = (View) findViewById(R.id.hoverView);
hoverView.setVisibility(View.GONE);
mExitAppDialog = new HookUpDialog(this);
mExitAppDialog.setMessage(getString(R.string.exit_app_message));
mExitAppDialog.setOnButtonClickListener(HookUpDialog.BUTTON_OK,
new OnClickListener() {
@Override
public void onClick(View v) {
mExitAppDialog.dismiss();
if (WallActivity.getInstance() != null) {
WallActivity.getInstance().finish();
}
sInstance.finish();
/* Informing the user, to press back again to exit */
Toast.makeText(getApplicationContext(),
R.string.press_back_again_to_exit,
Toast.LENGTH_SHORT).show();
}
});
mExitAppDialog.setOnButtonClickListener(HookUpDialog.BUTTON_CANCEL,
new OnClickListener() {
@Override
public void onClick(View v) {
mExitAppDialog.dismiss();
}
});
mLlRecentActivity = (LinearLayout) findViewById(R.id.llRecentActivity);
mNoActivitiesView = (TextView) findViewById(R.id.tvNoRecentActivities);
}
And now to the full code including an else if fix for devices with Android version 23 and below.
if(Build.VERSION.SDK_INT >= 23) {
if(checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
// Storage permissions is already available, save profile photo
initialization();
} else {
// Providing additional rational to the user if permission was not granted
if(shouldShowRequestPermissionRationale(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
Toast.makeText(this, "Storage permission is needed to save your profile photo.", Toast.LENGTH_LONG).show();
}
requestPermissions(new String[] {Manifest.permission.READ_CONTACTS}, WRITE_EXTERNAL_STORAGE);
}
} else if (Build.VERSION.SDK_INT < 23 ) {
// Storage permissions is already available, save profile photo
initialization();
}
Thanks to @Anurag Singh, I was able to see this after hours and hours of testing and re-testing. Googling and googling.
Upvotes: 2