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 · 12 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.

@isaanyoha
Copy link

How do we connect between iPhone and Android? Has it worked for anyone here recently?

@ssss500
Copy link

ssss500 commented Dec 31, 2024

@isaanyoha Unfortunately, it is not possible to connect between Android and iPhone via Wi-Fi. The only solution is Bluetooth to transfer data, but it is not practical with large data.

@isaanyoha
Copy link

Thanks! @ssss500 for reply.

Any other remedy (or any other flutter package) to send large data via wifi between iPhone and Android locally without internet?

@ssss500
Copy link

ssss500 commented Jan 3, 2025

@isaanyoha
I have been working on this topic for about 8 months. I am trying to send data between devices. There are two options. The first, if the data is large as I mentioned, is via a wifi network without the Internet, and the two devices connect to it. This is the easiest and they can easily recognize each other. The other solution is Bluetooth, but this is very slow and you send the data in parts and then collect it again. The iPhone can cancel the connection at any time. Until now, there is no other way. The European Union has filed a lawsuit against Apple in court to open this feature to developers, and it refuses.

@isaanyoha
Copy link

Thanks @ssss500, I appreciate your reponse.

One more thing...
So, for the first option: You mean, hotspot can be created on an Android device and then you connect an Iphone to the android's hotspst via wifi and then data can be sent back and forth between the 2 devices using this package. Will it work that way?

@ssss500
Copy link

ssss500 commented Jan 3, 2025

@isaanyoha
Exactly this can be done and it can be done through a Wi-Fi device as an intermediary and this depends on the number of devices connected at the same time. If there are about 7-8 devices, it is appropriate to open a hotspot from Android. More than this, the router is better. This is if the Android device has approximately 6 RAM.

@isaanyoha
Copy link

isaanyoha commented Jan 13, 2025

@ssss500
Ok, noted. Thank you!

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

6 participants