Search code examples
androidkotlinandroid-renderscript

Add BlurringView in project


Added next dependencies:

defaultConfig {
    renderscriptTargetApi 21
    renderscriptSupportModeEnabled true

Also:

implementation 'com.fivehundredpx:blurringview:1.0.0'

In repo:

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

And get error when tried to inflate:

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

In my code i have:

minifyEnabled true

If i change on false, all works fine. Also tried fix with this solution.

I added in my file proguard-rules.pro:

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

Also u can check some code from my build(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
        }
    }

My error when minifyEnabled is true:

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


Solution

  • Solved my problem with next solution:

    1) Added in proguard-rules.pro:

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

    2) Modified build.gradle(app):

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