![](/img/trans.png)
[英]Android Ripple button with curved background for Pre-Lollipop devices
[英]Android Ripple Drawable Error on Pre-Lollipop Devices - Android SDK 25
我是Android編程和StackOverflow的新手。 這是我的第一個問題,但我之前使用過StackOverflow平台來尋求解決方案。 現在,我的問題。 我有一個Android應用程序曾經在SDK 11的所有Android設備上正常運行。但是,在SDK 25的更新中,它會在棒棒糖前設備上崩潰。
我的日志貓如下:
Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering
我在vectorDrawables.useSupportLibrary = true
包含了vectorDrawables.useSupportLibrary = true
。 我的minSdkVersion = 11
, targetSdkVersion = 25
, supportLibraryVersion = 25.2.0
我已經嘗試了我在這里找到的所有建議,但都沒有效果。 所以,伙計,我需要你的幫助。 我渴望學習,以便我能解決這個問題。
謝謝。
調試有時會很痛苦,上面的問題是我原始代碼中的一個簡單錯誤的結果。 人類會犯......
現在來解決方案。 我的初始代碼如下,如果你看起來很敏銳,你會注意到,如果設備低於版本23,檢查Build.Version
的if語句之間的初始化代碼不會運行。
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);
}
}
這是初始化方法。 在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,經過數小時的測試和重新測試,我能夠看到這一點。 谷歌搜索和谷歌搜索。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.