nearby-sharing / android

Share files between android and PC via the Windows 10 / 11 built-in sharing functionality (Project Rome)
https://nearshare.shortdev.de
GNU General Public License v3.0
647 stars 33 forks source link

Android 13 reports invalid IP-Address through deprecated api #90

Closed Yoanndp closed 1 year ago

Yoanndp commented 1 year ago

Description

When using the application on my Android device and attempting to receive a file, the application crashes when I press the “receive” button (after setting the Bluetooth MAC address).

Steps to Reproduce

  1. Launch the file sharing application on an Android device.
  2. Press the “receive” button.
  3. The application crashes.

Expected Behavior

The application should be able to receive the file via Bluetooth without crashing when I press the “receive” button after setting the Bluetooth MAC address.

Actual Behavior

The application crashes when I press the “receive” button after setting the Bluetooth MAC address.

Additional Information

Logcat

FATAL EXCEPTION: main
Process: de.shortdev.nearby_sharing_windows, PID: 17774
android.runtime.JavaProxyThrowable: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'newAddress')
   at System.Net.IPAddress..ctor(Int64 newAddress)
   at Nearby_Sharing_Windows.AndroidNetworkHandler.GetLocalIp(Context context)
   at Nearby_Sharing_Windows.ReceiveActivity.InitializeCDP()
   at Nearby_Sharing_Windows.ReceiveActivity.OnRequestPermissionsResult(Int32 requestCode, String[] permissions, Permission[] grantResults)
   at Android.App.Activity.n_OnRequestPermissionsResult_IarrayLjava_lang_String_arrayI(IntPtr jnienv, IntPtr native__this, Int32 requestCode, IntPtr native_permissions, IntPtr native_grantResults)
   at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPILL_V(_JniMarshal_PPILL_V callback, IntPtr jnienv, IntPtr klazz, Int32 p0, IntPtr p1, IntPtr p2)
    at crc642138225d2d50e687.ReceiveActivity.n_onRequestPermissionsResult(Native Method)
    at crc642138225d2d50e687.ReceiveActivity.onRequestPermissionsResult(ReceiveActivity.java:51)
    at android.app.Activity.dispatchRequestPermissionsResult(Activity.java:8774)
    at android.app.Activity.dispatchActivityResult(Activity.java:8632)
    at android.app.ActivityThread.deliverResults(ActivityThread.java:5316)
    at android.app.ActivityThread.handleSendResult(ActivityThread.java:5362)
    at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:67)
    at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45)
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2307)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loopOnce(Looper.java:201)
    at android.os.Looper.loop(Looper.java:288)
    at android.app.ActivityThread.main(ActivityThread.java:7872)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
ShortDevelopment commented 1 year ago

@Yoanndp

Yoanndp commented 1 year ago

@ShortDevelopment • Android 13 • Yes • 192.168.1.12

ShortDevelopment commented 1 year ago

Might be, that the WifiInfo.IpAddress yields an invalid result on android 13+ as it's deprecated... https://github.com/ShortDevelopment/Nearby-Sharing-Windows/blob/af9248e3271efad2847e3a155d836ef88a1b2a73/Nearby%20Sharing%20Windows/AndroidNetworkHandler.cs#L25-L28

ShortDevelopment commented 1 year ago

@Yoanndp Would you like to test a version with a potential fix? The apk would have a different signing key so you would unfortunately have to uninstall the current version first...

Yoanndp commented 1 year ago

Yes. No problem for the signatures, I already had the case when I went from stable to beta

ShortDevelopment commented 1 year ago

@Yoanndp Here you go: https://cdn.shortdev.de/09855ced-b452-4206-8ef7-60bb749ced9c/nearshare-wifi-ip-test1.apk

Yoanndp commented 1 year ago

The application crashes at each startup: impossible to test. Here are the logs:

FATAL EXCEPTION: main
Process: de.shortdev.nearby_sharing_windows, PID: 1133
java.lang.NoSuchMethodError: no static method "Lio/sentry/android/core/SentryAndroid;.init(Landroid/content/Context;Lio/sentry/Sentry$OptionsConfiguration;)V"
    at crc642138225d2d50e687.MainActivity.n_onCreate(Native Method)
    at crc642138225d2d50e687.MainActivity.onCreate(MainActivity.java:42)
    at android.app.Activity.performCreate(Activity.java:8341)
    at android.app.Activity.performCreate(Activity.java:8320)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1417)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3622)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3778)
    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101)
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:138)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2303)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loopOnce(Looper.java:201)
    at android.os.Looper.loop(Looper.java:288)
    at android.app.ActivityThread.main(ActivityThread.java:7884)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
ShortDevelopment commented 1 year ago

Strange; I'll have a look...

ShortDevelopment commented 1 year ago

@Yoanndp Try this: https://cdn.shortdev.de/09855ced-b452-4206-8ef7-60bb749ced9c/nearshare-wifi-ip-test2.apk

Yoanndp commented 1 year ago

The app got installed successfully with no crashes. However I can't try with a computer right now, I'll let you know

Yoanndp commented 1 year ago

Alright, everything seems to work. I tried both sending and receiving ✅

ShortDevelopment commented 1 year ago

Nice, thank you very much for testing!