flutter_blue icon indicating copy to clipboard operation
flutter_blue copied to clipboard

not working in release

Open SamiraIhsan opened this issue 5 years ago • 33 comments

the prob in Stream to get the state and scan devices, it work fine on debug but in release doesn't work

SamiraIhsan avatar Feb 04 '21 11:02 SamiraIhsan

Make sure you added the right permissions

bdlukaa avatar Feb 04 '21 14:02 bdlukaa

No, I have already added the correct permissions and it was it works fine, and same case for the example existing in this plugin, and it appears in flutter 1.22.5

SamiraIhsan avatar Feb 04 '21 15:02 SamiraIhsan

Fix for this is discussed in #726

Use v0.7.2. In pubspec.yaml change to

 dependencies:
   flutter_blue: '0.7.2'

or for v0.7.3 compile with flutter build apk --no-shrink

sornen avatar Feb 08 '21 20:02 sornen

Thanks, yes I have fixed the issue by adding buildTypes { release { signingConfig signingConfigs.debug shrinkResources false minifyEnabled false } }

SamiraIhsan avatar Feb 09 '21 10:02 SamiraIhsan

@SamiraIhsan same issue i am facing i try to create apk in release mode but flutter blue not working can you please guide how u fixed this issue please where u add the following code

jimykhan avatar Feb 20 '21 19:02 jimykhan

@jimykhan add this code in [project_name]/android/app/build.gradle

    buildTypes {
        release {
            signingConfig signingConfigs.release
            shrinkResources false    // this line
            minifyEnabled false       // this line
        }
    }

SamiraIhsan avatar Feb 22 '21 09:02 SamiraIhsan

thank you sir for ur response i did this but it not work for me i am using flutter_blue 0.7.3 and flutter version 1.22.6 stable please let me know if u have solution

On Mon, 22 Feb 2021 at 01:24, SamiraIhsan [email protected] wrote:

add this code in [project_name]/android/app/build.gradle

buildTypes {
    release {
        signingConfig signingConfigs.release
        shrinkResources false    // this line
        minifyEnabled false       // this line
    }
}

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/pauldemarco/flutter_blue/issues/772#issuecomment-783229078, or unsubscribe https://github.com/notifications/unsubscribe-auth/AM7AZWFDK6HEIVFPQYAJWCLTAIPFNANCNFSM4XCUTXBA .

jimykhan avatar Feb 22 '21 12:02 jimykhan

I have the same issue Did you try with 0.7.2?

meridorkobi avatar Feb 23 '21 09:02 meridorkobi

i solved the issue by adding --no-shrink

to my build command

meridorkobi avatar Feb 23 '21 09:02 meridorkobi

Yes, I did. But not working

https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=icon Virus-free. www.avast.com https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=link <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Tue, Feb 23, 2021 at 1:30 AM Kobi [email protected] wrote:

I have the same issue Did you try with 0.7.2?

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/pauldemarco/flutter_blue/issues/772#issuecomment-784034306, or unsubscribe https://github.com/notifications/unsubscribe-auth/AM7AZWDF6ZTQ3LIICRDUM5LTANYUXANCNFSM4XCUTXBA .

jimykhan avatar Feb 23 '21 10:02 jimykhan

mDevices size: 1 brother i also face this issue when i connect device it not show in connected device

On Tue, 23 Feb 2021 at 02:01, Jamshed Khan [email protected] wrote:

Yes, I did. But not working

https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=icon Virus-free. www.avast.com https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=link <#m_-1689485638635840774_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Tue, Feb 23, 2021 at 1:30 AM Kobi [email protected] wrote:

I have the same issue Did you try with 0.7.2?

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/pauldemarco/flutter_blue/issues/772#issuecomment-784034306, or unsubscribe https://github.com/notifications/unsubscribe-auth/AM7AZWDF6ZTQ3LIICRDUM5LTANYUXANCNFSM4XCUTXBA .

jimykhan avatar Feb 23 '21 10:02 jimykhan

I made another issue with some proguard rules that work #784. They may be a bit too broad though.

jeroen1602 avatar Mar 16 '21 09:03 jeroen1602

@pauldemarco Tried 0.8.0 and still seeing the problem. Building just in release mode, with none of the mods mentioned above:

E/flutter ( 1455): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: PlatformException(startScan, Field androidScanMode_ for c.c.a.y not found. Known fields are [private int c.c.a.y.f, private c.a.c.b0$i c.c.a.y.g, private boolean c.c.a.y.h, private static final c.c.a.y c.c.a.y.i, private static volatile c.a.c.a1 c.c.a.y.j], java.lang.RuntimeException: Field androidScanMode_ for c.c.a.y not found. Known fields are [private int c.c.a.y.f, private c.a.c.b0$i c.c.a.y.g, private boolean c.c.a.y.h, private static final c.c.a.y c.c.a.y.i, private static volatile c.a.c.a1 c.c.a.y.j]
E/flutter ( 1455): 	at c.a.c.v0.n0(Unknown Source:72)
E/flutter ( 1455): 	at c.a.c.v0.T(Unknown Source:697)
E/flutter ( 1455): 	at c.a.c.v0.R(Unknown Source:12)
E/flutter ( 1455): 	at c.a.c.k0.e(Unknown Source:60)
E/flutter ( 1455): 	at c.a.c.k0.a(Unknown Source:49)
E/flutter ( 1455): 	at c.a.c.d1.d(Unknown Source:17)
E/flutter ( 1455): 	at c.a.c.d1.e(Unknown Source:4)
E/flutter ( 1455): 	at c.a.c.z$a.A(Unknown Source:9)
E/flutter ( 1455): 	at c.a.c.z$a.z(Unknown Source:4)
E/flutter ( 1455): 	at c.a.c.z$a.m(Unknown Source:0)
E/flutter ( 1455): 	at c.a.c.a$a.l(Unknown Source:2)
E/flutter ( 1455): 	at c.c.a.b.q(Unknown Source:10)
E/flutter ( 1455): 	at c.c.a.b.onMethodCall(Unknown Source:1583)
E/flutter ( 1455): 	at d.a.c.a.j$a.a(Unknown Source:17)
E/flutter ( 1455): 	at io.flutter.embedding.engine.e.b.d(Unknown Source:57)
E/flutter ( 1455): 	at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(Unknown Source:4)
E/flutter ( 1455): 	at android.os.MessageQueue.nativePollOnce(Native Method)
E/flutter ( 1455): 	at android.os.MessageQueue.next(MessageQueue.java:336)
E/flutter ( 1455): 	at android.os.Looper.loop(Looper.java:174)
E/flutter ( 1455): 	at android.app.ActivityThread.main(ActivityThread.java:7405)
E/flutter ( 1455): 	at java.lang.reflect.Method.invoke(Native Method)
E/flutter ( 1455): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:502)
E/flutter ( 1455): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:980)
E/flutter ( 1455): , null)
E/flutter ( 1455): #0      FlutterBlue.scan (package:flutter_blue/src/flutter_blue.dart:123)

spekary avatar Mar 23 '21 23:03 spekary

Same problem, and no-shrink doesn't solve the problem in 0.8.0

ayushin avatar Apr 23 '21 19:04 ayushin

I solved this by creating proguard rules on Android:

-keep class com.pauldemarco.flutter_blue.Protos* { *; }

Have yet to test on iOS though

spekary avatar Apr 23 '21 19:04 spekary

OK so for me the combination of --no-shrink and -keep class com.pauldemarco.flutter_blue.Protos* { *; } worked finally.

Would be great to at least document it.

ayushin avatar Apr 23 '21 19:04 ayushin

        shrinkResources false    // this line
        minifyEnabled false       // this line

@jimykhan add this code in [project_name]/android/app/build.gradle

    buildTypes {
        release {
            signingConfig signingConfigs.release
            shrinkResources false    // this line
            minifyEnabled false       // this line
        }
    }

This solves the problem for me with Version 0.8.0.

d-wolf avatar Apr 27 '21 08:04 d-wolf

I solved this by creating proguard rules on Android:

-keep class com.pauldemarco.flutter_blue.Protos* { *; }

Have yet to test on iOS though

  1. Does -keep class com.pauldemarco.flutter_blue.* { *; } rule cover -keep class com.pauldemarco.flutter_blue.Protos* { *; } as well? (I think yes)
  2. Aren't ProGuard rules Android only?

MrCsabaToth avatar May 11 '21 16:05 MrCsabaToth

@MrCsabaToth How do you create proguard rules in flutter? apologies, beginner question.

alexflav23 avatar May 19 '21 03:05 alexflav23

@alexflav23 sure, first you will need to create the proguards rules file at android/app/proguard-rules.pro. In this file add the proguard rules as described by ~@MrCsabaToth~ @d-wolf or in the issue #784. After this we will need to tell gradle that these rules exist. Go into the android/app/build.gradle file and add the proguardFiles option to the correct build type. For you that would probably be:

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

I've added them to my own project so you can copy what you need from there: https://github.com/jeroen1602/lighthouse_pm/tree/master/android/app

Edit: here is the same link at a specific commit in case it changes in the future and someone still needs help https://github.com/jeroen1602/lighthouse_pm/tree/10eeccbd2200f82dbbff5dee27c18f76ea9151ea/android/app

For more info you can check the developer documentation https://developer.android.com/studio/build/shrink-code

jeroen1602 avatar May 19 '21 06:05 jeroen1602

@jimykhan add this code in [project_name]/android/app/build.gradle

    buildTypes {
        release {
            signingConfig signingConfigs.release
            shrinkResources false    // this line
            minifyEnabled false       // this line
        }
    }

with flutter build apk --no-shrink worked for me.

ertandagdelen avatar Jul 18 '21 12:07 ertandagdelen

minifyEnable false
shrinkResources false

Will turn off minifaction for your entire code base, which is probably not want you want. Yes, it will work, but it will unnecessarily increase the size of your apk file. Using the proguard rules approach will only do this for flutter-blue, and so the rest of your code will minimize.

spekary avatar Jul 20 '21 02:07 spekary

the prob in Stream to get the state and scan devices, it work fine on debug but in release doesn't work

Please add your android app proguard-rules.pro file and paste the code inside to this file. -keep class com.pauldemarco.flutter_blue.** { *; } And paste this code to your build.gradle file: buildTypes { release { // TODO: Add your own signing config for the release build. // Signing with the debug keys for now, so flutter run --release works. proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' signingConfig signingConfigs.debug } debug { // debuggable true // shrinkResources true // minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } }

Nurdiyor avatar Aug 21 '21 11:08 Nurdiyor

I just encountered the same problem, and it took me quite some time to find this thread. Any idea on when #784 will be fixed?

DrumsnChocolate avatar Aug 24 '21 10:08 DrumsnChocolate

buildTypes { release { signingConfig signingConfigs.release shrinkResources false // this line minifyEnabled false // this line } }

Thanks **SamiraIhsan ** fixed the my problems

deepak-0811 avatar Aug 27 '21 10:08 deepak-0811

thank you sir for ur response i did this but it not work for me i am using flutter_blue 0.7.3 and flutter version 1.22.6 stable please let me know if u have solution On Mon, 22 Feb 2021 at 01:24, SamiraIhsan @.***> wrote: add this code in [project_name]/android/app/build.gradle buildTypes { release { signingConfig signingConfigs.release shrinkResources false // this line minifyEnabled false // this line } } — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#772 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AM7AZWFDK6HEIVFPQYAJWCLTAIPFNANCNFSM4XCUTXBA .

Strange, this solution seems to work on my application. I am also using flutter_blue: ^0.7.3 and flutter 1.22.6

tijanirf avatar Sep 05 '21 02:09 tijanirf

Issue: Not working in after build, app work properly in debug mode Hi devs, I have tried everything here, But still could not solve it. Please, someone, help me regarding this same issue. Feeling very bad after trying to solve this issue for the last 48 hours. flutter blue : ^0.8.0 flutter: ^2.2.3 Stable

My app: https://github.com/Emadul-Hasan/ble_splash_x

Emadul-Hasan avatar Oct 22 '21 14:10 Emadul-Hasan

@Emadul-Hasan I tried your app in release mode and I didn't encounter any crashes, so maybe you just need a clean build?

I also couldn't find anything suspicious causing it to not work.

jeroen1602 avatar Oct 22 '21 15:10 jeroen1602

Issue: Not working in after build, app work properly in debug mode Hi devs, I have tried everything here, But still could not solve it. Please, someone, help me regarding this same issue. Feeling very bad after trying to solve this issue for the last 48 hours. flutter blue : ^0.8.0 flutter: ^2.2.3 Stable

My app: https://github.com/Emadul-Hasan/ble_splash_x

@Emadul-Hasan So many questions:

  1. I'm on stable channel, version 2.5.1 Flutter and now there's a newer version. Is there any reason (related to this issue maybe) why you are on 2.2.3?
  2. Have you installed your production build on any of your test devices?
  3. What error messages you see in LogCat when you install your production build on your test device(s) and reproduce your issue?
  4. I see you have a proguard rule file in your source but it's only against the ProtoBuf classes. Does your issue reproducable if you put these two more generic rules -keep class com.pauldemarco.flutter_blue.* { *; } and -keep class com.pauldemarco.flutter_blue.Protos* { *; } instead of the ProtoBuf one? You don't need minifyEnable false or shrinkResources false when you try these.

Please provide answers to these questions.

MrCsabaToth avatar Oct 22 '21 20:10 MrCsabaToth

Issue: Not working in after build, app work properly in debug mode Hi devs, I have tried everything here, But still could not solve it. Please, someone, help me regarding this same issue. Feeling very bad after trying to solve this issue for the last 48 hours. flutter blue : ^0.8.0 flutter: ^2.2.3 Stable My app: https://github.com/Emadul-Hasan/ble_splash_x

@Emadul-Hasan So many questions:

  1. I'm on stable channel, version 2.5.1 Flutter and now there's a newer version. Is there any reason (related to this issue maybe) why you are on 2.2.3?
  2. Have you installed your production build on any of your test devices?
  3. What error messages you see in LogCat when you install your production build on your test device(s) and reproduce your issue?
  4. I see you have a proguard rule file in your source but it's only against the ProtoBuf classes. Does your issue reproducable if you put these two more generic rules -keep class com.pauldemarco.flutter_blue.* { *; } and -keep class com.pauldemarco.flutter_blue.Protos* { *; } instead of the ProtoBuf one? You don't need minifyEnable false or shrinkResources false when you try these.

Please provide answers to these questions.

  1. There is no specific reason to not updating the flutter version
  2. I have installed the realsed apk to my device. till scanning is working fine after minifying but data is not being received and application freezes. But in debug mode (In the same device) it working fine without any issue, there is not error shown.
  3. I did not used emulator for testing, I just used my real device for testing the apks. So i did not observed in longcat.
  4. I have tried both the way, using both of the proguard rules, but unfortunately, it did not work for me.

Emadul-Hasan avatar Oct 23 '21 01:10 Emadul-Hasan