前棒棒糖设备上的Android纹波可绘制错误 - Android SDK 25

问题描述:

我是Android编程和*的新手。这是我的第一个问题,但是我之前使用过*平台来解决这个问题。现在,我的问题。我有一个Android应用程序,可以在SDK 11中的所有Android设备上正常运行。但是,在SDK 25的更新中,它会在预棒棒糖设备上崩溃。前棒棒糖设备上的Android纹波可绘制错误 - Android SDK 25

我的日志猫如下:

Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering 

我已经包含在我的gradle这个vectorDrawables.useSupportLibrary = true。我的minSdkVersion = 11targetSdkVersion = 25,supportLibraryVersion = 25.2.0

我试过了所有的建议,我可以在这里找到,但没有作品。所以请大家,我需要你的帮助。我渴望学习,以便我可以解决这个问题。

谢谢。

+0

您使用哪种gradle版本? –

+0

我使用的是Gradle版本3.3和插件版本2.3 –

+0

这是正确的。你可以通过删除所有其他代码来分享项目吗?除非试图引用导致此异常的图像 –

有时调试可能是一种痛苦,上面的问题是我原始代码中一个简单错误的结果。人类会犯错......

现在来解决。我最初的代码如下,如果你看看敏锐,你会注意到,如果该设备是低于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); 
     } 
    } 

版这是初始化方法检查Build.Version if语句之间的初始化代码不运行。在Android版本低于23的设备中,它没有运行,从而触发Could not find class错误。不过,我仍然没有弄清楚这是如何与Ripple Drawable相关的,因为我的代码中没有使用Vector Drawables。因此,任何人谁可以阅读这可能会提供一些线索到原因

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); 
} 

现在到了完整的代码,包括与Android版本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); 
     } 
    } else if (Build.VERSION.SDK_INT < 23) { 
     // Storage permissions is already available, save profile photo 

     initialization(); 

    } 

感谢@Anurag Singh,经过数小时的测试和重新测试,我能够看到这一点。谷歌搜索和谷歌搜索。