Skip to content

App icon visible in dubug mode but not in release #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
darshansatra1 opened this issue Jun 29, 2021 · 5 comments
Closed

App icon visible in dubug mode but not in release #4

darshansatra1 opened this issue Jun 29, 2021 · 5 comments

Comments

@darshansatra1
Copy link

As per flutter_foreground_task 2.0.0 update, foreground service is now able to run after killing of the application. But one issue I found was that the notification icon in release mode is shown as a white square box instead of the required icon. It would be very helpful if you can look into it.

@Dev-hwang
Copy link
Owner

@darshansatra1
As a result of checking, this problem occurs when using the resource shrinker when building the apk file.

You can solve this problem by setting the shrinkResources option to false in the /android/app/build.gradle file.
스크린샷 2021-06-30 오후 8 17 51

It seems that strict reference checking needs to be implemented to solve this problem without any setup.
I will check more and update.

@darshansatra1
Copy link
Author

I set shrinkResourses false as you said but then I'm getting this error. Help please.

A problem occurred evaluating project ':app'.

No signature of method: build_5idrlra61jow09g6rquzmmxk4.android() is applicable for argument types: (build_5idrlra61jow09g6rquzmmxk4$_run_closure2) values: [build_5idrlra61jow09g6rquzmmxk4$_run_closure2@79bbead]

build.gradle:

android {
    compileSdkVersion 30

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
        applicationId "com.example.app"
        minSdkVersion 21
        targetSdkVersion 30
        multiDexEnabled true
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
            storePassword keystoreProperties['storePassword']
        }
    }

    buildTypes {
        release {
            shrinkResourses false
            minifyEnabled true
            signingConfig signingConfigs.release
        }
        debug{
            shrinkResourses false
            minifyEnabled true
        }
    }
}

@Dev-hwang
Copy link
Owner

Dev-hwang commented Jul 1, 2021

Most likely the method was not found as the code was encrypted by the minifyEnabled option. Try adding proguard-rules.pro.

  1. Create the file /android/app/proguard-rules.pro and enter the following contents.
-keep class io.flutter.app.** { *; }
-keep class io.flutter.plugin.**  { *; }
-keep class io.flutter.util.**  { *; }
-keep class io.flutter.view.**  { *; }
-keep class io.flutter.**  { *; }
-keep class io.flutter.plugins.**  { *; }
-keep class com.pravera.** { *; }
-dontwarn io.flutter.embedding.**
  1. Add the code below to the /android/app/build.gradle file.
android {
    compileSdkVersion 30

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        applicationId "com.example.app"
        minSdkVersion 21
        targetSdkVersion 30
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile file(keystoreProperties['storeFile'])
            storePassword keystoreProperties['storePassword']
        }
    }

    buildTypes {
        release {
            shrinkResources false
            minifyEnabled true
            signingConfig signingConfigs.release
            proguardFiles getDefaultProguardFile(
                    'proguard-android-optimize.txt'),
                    'proguard-rules.pro'
        }

        debug {
            minifyEnabled false
            proguardFiles getDefaultProguardFile(
                    'proguard-android-optimize.txt'),
                    'proguard-rules.pro'
        }
    }
}

@Dev-hwang
Copy link
Owner

@darshansatra1
Notification icon are now displayed properly even when using the shrinkResources option. Update the plugin and check the readme.

@darshansatra1
Copy link
Author

Thank you @Dev-hwang , now the issue is gone after adding the proguard-rules.pro file and doing the required configuration in the build.gradle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants