Skip to content
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

Android device cannot detect others by flutter_nearby_connections #56

Open
i19harada1a opened this issue Jan 17, 2024 · 5 comments
Open

Comments

@i19harada1a
Copy link

i19harada1a commented Jan 17, 2024

I want to connect between several devices, so I tried sample code provided by Flutter on debug mode.
As a result, I succeeded to connect between ios, but I didn't succeed between Android.Browser device couldn't detect Advertiser devices.

The Android device conditions used are as follows↓

Galaxy SC-02L (OS version: Android 10)
Google pixel 5a (OS version: Android 12)

Why don't I succeed to connect between Android? The diffence of OS version?? Please tell me the reason, and what should I do. Thank you for your help.

android/app/src/main/AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.sample_record_audioplayer">
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission 
           android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
    <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
    <application
        android:label="myapp"
        android:name="${applicationName}"
        android:icon="@mipmap/ic_launcher">
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>
</manifest>
@paulkastel
Copy link

paulkastel commented Jan 21, 2024

Same issue - I didn't managed to connect 2 physical Android phones: Xiaomi MI 6 (Android 13, rooted) with Samsung Galaxy A72 (Android 13, non-root). I also didn't managed to connect Samsung A72 with iPhone 13 (iOS 17.1.2) although I am not sure if this is possible with this package?

Mine settings in android were: compileSdkVersion 34, minSdkVersion 28, targetSdkVersion 34, I am on Flutter 3.13.8 and I am using flutter_nearby_connections: 1.1.2

This ticket is related to #49, #48, #39, #36, #34, #29, #25, #19

@i19harada1a
Copy link
Author

i19harada1a commented Jan 22, 2024

@paulkastel

Thanks for your comment!

I seem that you have same issue.

My settings in android were: compileSdkVersion 34, minSdkVersion 21, targetSdkVersion 34, Flutter version 3.16.7 and I 'm using flutter_nearby_connections:1.1.2

By the way, if we want to connect between iPhone and Android, we have to use UDP-TCP-Flutter?(https://github.com/VNAPNIC/UDP-TCP-Flutter)
(please cf. #25)

As far as I can see, this is not possible with this package.

@champeauxr
Copy link

I have created a fix for this and a pull request has been created:
#62

The fix was to upgrade to the latest version of the Google Nearby Connections library and to add new permissions that are required by Android 12 and above.

I'm not sure how actively this package is being maintained, so until this PR is merged, you can find a working version of it at my fork: https://github.com/champeauxr/flutter_nearby_connections

Reference this in your flutter app with the following:

dependencies:
  flutter_nearby_connections:
    git:
      url: https://github.com/champeauxr/flutter_nearby_connections
      ref: master

@i19harada1a
Copy link
Author

@champeauxr

Thanks for fix the issue!

I don't try it now, but I will do it.

@Ingressbanners
Copy link

I have created a fix for this and a pull request has been created: #62

The fix was to upgrade to the latest version of the Google Nearby Connections library and to add new permissions that are required by Android 12 and above.

I'm not sure how actively this package is being maintained, so until this PR is merged, you can find a working version of it at my fork: https://github.com/champeauxr/flutter_nearby_connections

Reference this in your flutter app with the following:

dependencies:
  flutter_nearby_connections:
    git:
      url: https://github.com/champeauxr/flutter_nearby_connections
      ref: master

Thank you very much, was wondering why my app wasn't detecting other devices on andriod14, your fix worked.

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

4 participants