Android Ripple Drawable Error on Pre-Lollipop Devices - Android SDK 25

I am new to Android programming and StackOverflow. This is my first question, however I have used the StackOverflow platform for solutions here and there before. Now for my question. I have an Android app that works fine on all Android devices from SDK 11. However, when upgrading to SDK 25, it crashes on pre-leopted devices.

My log code looks like this:

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've tried all the suggestions I could find here but none seem to work. So please guys, I need your help. I really want to know that I can solve this problem.

Thank.

+3


source to share


1 answer


Debugging can be a pain at times, and the question above was the result of a simple error in my original code. People must be wrong ...

Now to the solution. My initial code was as follows, and if you look closely, you will notice that the initialization code between the if statement that checks 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. On devices with Android version lower than 23, it did not start, thus causing an error Could not find class

. However, I still haven't figured out how this relates to Ripple Drawable because I don't use Vector Drawables anywhere in my code. So anyone who reads this can shed some light on the reason



    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 complete code, including the else if the fix is ​​for devices running 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 retesting. Googling and googling.

+2


source







All Articles