flutter_blue icon indicating copy to clipboard operation
flutter_blue copied to clipboard

Bluetooth adapter is not available

Open bobosette opened this issue 4 years ago • 24 comments

Hi everybody. I'm trying the flutter blue example on an Android 10 device but when I open the app i get this msd: "the bluetooth adapter is not available"! If I debug that I see that the FlutterBlue.instance.state is null! But if i open the app in an older Android device it works fine! Can somebody help me?

bobosette avatar Nov 17 '20 18:11 bobosette

I am getting the same issue in my project but only when do a release build.

I have run it on Android 10 & 11 same issue.

Android Manifiest <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.flutter_base"> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.RECORD_AUDIO" /> <uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> <uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> </manifest>

build.gradle `android { compileSdkVersion 29

lintOptions {
    disable 'InvalidPackage'
}

defaultConfig {
    applicationId "com.x.x"
    minSdkVersion 24
    targetSdkVersion 29
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}`

Hoopstr42 avatar Nov 18 '20 00:11 Hoopstr42

I didn't think about it but I also have this issue only in a release build. How is it possible??

bobosette avatar Nov 18 '20 08:11 bobosette

I have the same issue

Flutter version 1.22.3

JimmyLee05 avatar Nov 18 '20 10:11 JimmyLee05

Please try to role back to 0.7.2 and also make sure you have removed these permissions because these are already there in the plugin.

android.permission.ACCESS_FINE_LOCATION
android.permission.BLUETOOTH
android.permission.BLUETOOTH_ADMIN

ch-muhammad-adil avatar Nov 18 '20 16:11 ch-muhammad-adil

Just FYI, we found a workaround by rolling back to v0.7.2. So if you don't need the protobuf-lite fix. Just roll back and you will be good to go.

Hoopstr42 avatar Nov 18 '20 16:11 Hoopstr42

Ok i'm gonna try this and i'll let u know

Il Mer 18 Nov 2020, 17:17 Jody Holmes [email protected] ha scritto:

Just FYI, we found a workaround by rolling back to v0.7.2. So if you don't need the protobuf-lite fix. Just roll back and you will be good to go.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/pauldemarco/flutter_blue/issues/726#issuecomment-729787253, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADEWB4KNEBODED3WGHJ6MZLSQPXP3ANCNFSM4TY6Y3GQ .

bobosette avatar Nov 18 '20 16:11 bobosette

You're right. Now the app works correctly. Thank you.

bobosette avatar Nov 18 '20 21:11 bobosette

Please try " flutter build apk --no-shrink " to build your release build.

v0.7.3 works good.

JimmyLee05 avatar Nov 19 '20 01:11 JimmyLee05

Yes, 0.7.3 with "flutter build apk --release" is not working. With "flutter build apk --no-shrink " indeed works. Looks like R8 is messing up.

bufolab avatar Nov 19 '20 18:11 bufolab

Just FYI, we found a workaround by rolling back to v0.7.2. So if you don't need the protobuf-lite fix. Just roll back and you will be good to go.

I just hit this, only release build is affected. Is there an other issue involved? Can your reference? I don't need or use protobuf.

MrCsabaToth avatar Nov 20 '20 21:11 MrCsabaToth

Ok, I think this is a protobuf issue @Hoopstr42 mentions: https://github.com/pauldemarco/flutter_blue/issues/717 I saw the "WARNING: This version of flutter_blue will break your Android build if it or its dependencies aren't compatible with AndroidX.".

MrCsabaToth avatar Nov 20 '20 22:11 MrCsabaToth

We should mention this as a breaking change.

ayushin avatar Dec 02 '20 05:12 ayushin

Guys, I nuked my whole android port and re-created it because of https://github.com/miguelpruivo/flutter_file_picker/issues/545 and I tested and now 0.7.3 does not produce the release-only error for me. This means that this problem is not with flutter_blue but because of the complexity and interference of this system with many moving parts.

MrCsabaToth avatar Dec 16 '20 07:12 MrCsabaToth

Lately even nuking and recreating the android port doesn't solve this.

MrCsabaToth avatar Dec 27 '20 20:12 MrCsabaToth

https://github.com/pauldemarco/flutter_blue/issues/662 helped

MrCsabaToth avatar Dec 28 '20 06:12 MrCsabaToth

I have same issue

JAICHANGPARK avatar Jan 05 '21 07:01 JAICHANGPARK

flutter_blue: ^0.7.3

I've the same issue building the APK release with "flutter build apk --release" in Android 7.1.1 (Samsung Tablet) and Phone (Motorola Android 10).

But the workaround "flutter build apk --no-shrink" works for me.

chanum avatar Jan 07 '21 18:01 chanum

flutter build apk --no-shrink

this is not works for me (android 8.1)

JAICHANGPARK avatar Jan 08 '21 00:01 JAICHANGPARK

Seems to be happening on IOS as well, and none of the work arounds function.

GuruJohn avatar Jan 15 '21 18:01 GuruJohn

For flutter_blue v0.8.0 :

Try this during release build : https://github.com/pauldemarco/flutter_blue/issues/772#issuecomment-827404250

shobhit14gupta avatar May 11 '21 14:05 shobhit14gupta

@MrCsabaToth Hey small world I saw you at Google Dev Fest in Fresno.. maybe like 2017?

anthonyorona avatar Jul 06 '21 19:07 anthonyorona

@MrCsabaToth Hey small world I saw you at Google Dev Fest in Fresno.. maybe like 2017?

Oh yes, Valley DevFest!

MrCsabaToth avatar Jul 07 '21 04:07 MrCsabaToth

       Work-around for https://github.com/pauldemarco/flutter_blue/issues/772

add the below two lines in buid.gradle(app) -> buildTypes -> release shrinkResources false minifyEnabled false

image

works like magic

myogesh7 avatar Jan 17 '22 17:01 myogesh7

buildTypes { release { // TODO: Add your own signing config for the release build. // Signing with the debug keys for now, so flutter run --release works. signingConfig signingConfigs.debug proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' shrinkResources false minifyEnabled false } }

Note:- Run flutter build apk --no-shrink

Working :)

Githubsaveme avatar Jul 21 '22 14:07 Githubsaveme