Closed AlexQiulin closed 1 year ago
Something related happens to me, a debug build behaves like a charm, in release builds the app fails to discover services on the peripheral device. Happens specifically on Samsung s22 Ultra (Android 12).
I have just fixed this in my own project.
You can still use shrinkResources
and minifyEnabled
as shown here in this snippet from my build.gradle
:
...
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
but you need to make sure to update your Proguard rules in android/proguard-rules.pro
:
...
# flutter_blue_plus rules
-keep class com.boskokg.flutter_blue_plus.** { *; }
-keepclassmembernames class com.boskokg.flutter_blue_plus.* { *; }
This will prevent the classes and relevant members from being minified which means that they can be invoked as normal.
It's working in my case, thank you
I dont have the "proguard-rules.pro" file on me android folder, were can I found it?
I dont have the "proguard-rules.pro" file on me android folder, were can I found it?
You have to manually create the file if it doesn't exist yet.
buildTypes { release { signingConfig signingConfigs.release
minifyEnabled true shrinkResources true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } }
but you need to make sure to update your Proguard rules in `android/proguard-rules.pro`:
...
flutter_blue_plus rules
-keep class com.boskokg.flutter_blue_plus.* { ; } -keepclassmembernames class com.boskokg.flutter_blue_plus. { ; }
Thank you so much for this information.
Without a doubt, this information should appear prominently in the README.md for this plugin.
good issue , thank every one i used -keep class com.boskokg.flutter_blue_plus.* { ; } -keepclassmembernames class com.boskokg.flutter_blue_plus. { ; }
For Android 12, the APK file after the official package (Build APK) release cannot be searched for Bluetooth devices and the system Bluetooth solution cannot be opened