在项目中添加 BlurringView

Add BlurringView in project

添加了下一个依赖项:

defaultConfig {
    renderscriptTargetApi 21
    renderscriptSupportModeEnabled true

还有:

implementation 'com.fivehundredpx:blurringview:1.0.0'

回购中:

repositories {
    maven { url 'https://github.com/500px/500px-android-blur/raw/master/releases/' }

尝试充气时出错:

    init {
    inflate(context, R.layout.view_authorization_content,this)
    blurringView?.setBlurredView(blurredView)
    blurringView?.invalidate()
}

在我的代码中我有:

minifyEnabled true

如果我更改为 false,一切正常。 还尝试用这个 solution.

修复

我在我的文件中添加了 proguard-rules.pro:

-keep class android.support.v8.renderscript.** { *; }

你也可以从我的构建(app)中检查一些代码:

buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
            lintOptions {
                disable 'MissingTranslation'
                // google services plugin is causing missing translation issue
            }
            testCoverageEnabled false
            debuggable false
        }
        debug {
            lintOptions {
                disable 'MissingTranslation'
                // google services plugin is causing missing translation issue
            }
            testCoverageEnabled true
        }
    }

minifyEnabledtrue 时我的错误:

Binary XML file line #122: Binary XML file line #122: Error inflating class com.fivehundredpx.android.blur.BlurringView Caused by: android.view.InflateException: Binary XML file line #122: Error inflating class com.fivehundredpx.android.blur.BlurringView Caused by: java.lang.reflect.InvocationTargetException

使用下一个解决方案解决了我的问题:

1) 添加于 proguard-rules.pro:

-keep class androidx.renderscript.** { *; }

2) 修改 build.gradle(app):

release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'