Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  4. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Android game crashes when attempting to start WiFi hotspots

Discussion in 'Connected Games' started by ahmadian, Jun 8, 2017.

  1. ahmadian

    ahmadian

    Joined:
    Nov 24, 2015
    Posts:
    44
    I have two methods that will try to start the WiFi hotspot on the android device so that others can connect and play the game. The problem is both method have problems and don't work.

    The first method:
    Code (CSharp):
    1.  
    2. public void ConnectWiFi()
    3. {
    4.     try
    5.     {
    6.  
    7.         using (AndroidJavaObject activity = new AndroidJavaClass("com.unity3d.player.UnityPlayer").GetStatic("currentActivity"))
    8.         {
    9.             using (var wifiManager = activity.Call("getSystemService", "wifi"))
    10.             {
    11.                 AndroidJavaObject wifiConfiguration = new AndroidJavaClass("android.net.wifi.WifiConfiguration");
    12.                 wifiConfiguration.Set("SSID", meSSID); // string
    13.                 wifiConfiguration.Set("preSharedKey", mePassword); // string
    14.                 wifiManager.Call("setWifiApEnabled", wifiConfiguration, enabled);
    15.             }
    16.         }
    17.     }
    18.     catch (System.Exception E)
    19.     {
    20.         T.text += "\nE - " + E.Message;
    21.         T.text += "\n\t" + E.StackTrace+"\n";
    22.     }
    23. }
    24.  
    it crashes the game and I can't debug it. here is the log for it:
    Code (CSharp):
    1.  
    2.     W/ActivityManager(  550): mDVFSHelper.acquire()
    3.     W/ActivityThread(17070): Application com.thenightafterdoomsday.nomercy can be debugged on port 8100...
    4.     I/Unity   (17070): splash_mode = 0 (integer)
    5.     I/Unity(17070): useObb = False(bool)
    6.     I/Unity(17070): onResume
    7.     I/Unity(17070): windowFocusChanged: true
    8.     W/ActivityManager(  550): mDVFSHelper.release()
    9.     E/Unity(17070): GLSL: unsupported array parameter 'unity_WorldToShadow'
    10.     E/Unity(17070): Stacktrace is not supported on this platform.
    11.     E/Unity   (17070): (Filename: ./Runtime/GfxDevice/opengles/GpuProgramParamsGLES.cpp Line: 246)
    12.     E/Unity   (17070):
    13.     E/Unity   (17070): GLSL: unsupported array parameter 'unity_WorldToShadow'
    14.     E/Unity   (17070): Stacktrace is not supported on this platform.
    15.     E/Unity   (17070): (Filename: ./Runtime/GfxDevice/opengles/GpuProgramParamsGLES.cpp Line: 246)
    16.     E/Unity   (17070):
    17.     E/Unity   (17070): -------- GLSL link error: ERROR:LEX/PARSE-2 (line 38) Undefined identifier
    18.     E/Unity   (17070):
    19.     E/Unity   (17070):
    20.     E/Unity   (17070): Stacktrace is not supported on this platform.
    21.     E/Unity   (17070): (Filename: ./Runtime/GfxDevice/opengles/ApiGLES.cpp Line: 685)
    22.     E/Unity   (17070):
    23.     E/Unity   (17070): GLSL: unsupported array parameter 'unity_LightColor'
    24.     E/Unity   (17070): Stacktrace is not supported on this platform.
    25.     E/Unity   (17070): (Filename: ./Runtime/GfxDevice/opengles/GpuProgramParamsGLES.cpp Line: 246)
    26.     E/Unity   (17070):
    27.     E/Unity   (17070): GLSL: unsupported array parameter 'unity_LightPosition'
    28.     E/Unity   (17070): Stacktrace is not supported on this platform.
    29.     E/Unity   (17070): (Filename: ./Runtime/GfxDevice/opengles/GpuProgramParamsGLES.cpp Line: 246)
    30.     E/Unity   (17070):
    31.     I/DEBUG   (15581): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    32.     I/DEBUG   (15581): Build fingerprint: 'samsung/baffinxx/baffin:4.2.2/JDQ39/I9082XXUBNC1:user/release-keys'
    33.     I/DEBUG   (15581): Revision: '5'
    34.     I/DEBUG   (15581): pid: 17070, tid: 17086, name: UnityMain  >>> com.thenightafterdoomsday.nomercy
    35.     I/DEBUG   (15581):
    36.     I/DEBUG   (15581): stack:
    37.     I/DEBUG   (15581):          56b4d1c8  41c0f648  /dev/ashmem/dalvik-heap (deleted)
    38.     I/DEBUG   (15581):          56b4d1cc  41c0f648  /dev/ashmem/dalvik-heap (deleted)
    39.     I/DEBUG   (15581):          56b4d1d0  4103b3b8
    40.     I/DEBUG   (15581):          56b4d1d4  4103b460
    41.     I/DEBUG   (15581):          56b4d1d8  4103b3b8
    42.     I/DEBUG   (15581):          56b4d1dc  40991ebf  /system/lib/libdvm.so (dvmReleaseTrackedAlloc+30)
    43.     I/DEBUG   (15581):          56b4d1e0  56b4d20c
    44.     I/DEBUG   (15581):          56b4d1e4  4ca4a564  /dev/ashmem/dalvik-LinearAlloc (deleted)
    45.     I/DEBUG   (15581):          56b4d1e8  49334a40
    46.     I/DEBUG   (15581):          56b4d1ec  00000000
    47.     I/DEBUG   (15581):          56b4d1f0  4ca4a564  /dev/ashmem/dalvik-LinearAlloc (deleted)
    48.     I/DEBUG   (15581):          56b4d1f4  4098723f  /system/lib/libdvm.so (dvmDecodeIndirectRef(Thread*, _jobject*)+34)
    49.     I/DEBUG   (15581):          56b4d1f8  00000000
    50.     I/DEBUG   (15581):          56b4d1fc  4ca4a564  /dev/ashmem/dalvik-LinearAlloc (deleted)
    51.     I/DEBUG   (15581):          56b4d200 df0027ad
    52.     I/DEBUG   (15581):          56b4d204  00000000
    53.     I/DEBUG   (15581):     #00  56b4d208  49334a40
    54.     I/DEBUG   (15581):          56b4d20c  4103b3b8
    55.     I/DEBUG   (15581):          56b4d210  4ca4a564  /dev/ashmem/dalvik-LinearAlloc (deleted)
    56.     I/DEBUG   (15581):          56b4d214  409885a7  /system/lib/libdvm.so
    57.     I/DEBUG   (15581):          56b4d218  00000000
    58.     I/DEBUG   (15581):          56b4d21c  49334a40
    59.     I/DEBUG   (15581):          56b4d220  56b4d22c
    60.     I/DEBUG   (15581):          56b4d224  55fe752c  /mnt/asec/com.thenightafterdoomsday.nomercy-1/lib/libunity.so (AndroidJNI_CUSTOM_SetStringField(void*, void*, ICallString)+284)
    61.     I/DEBUG   (15581):     #01  56b4d228  49588ee0
    62.     I/DEBUG   (15581):          56b4d22c  50c7396c
    63.     I/DEBUG   (15581):          56b4d230  20c0000d
    64.     I/DEBUG   (15581):          56b4d234  41135c00
    65.     I/DEBUG   (15581):          56b4d238  49334a40
    66.     I/DEBUG   (15581):          56b4d23c  4984fd20
    67.     I/DEBUG   (15581):          56b4d240  56948d9c
    68.     I/DEBUG   (15581):          56b4d244  49591ed8
    69.     I/DEBUG   (15581):          56b4d248  55527c20  /mnt/asec/com.thenightafterdoomsday.nomercy-1/lib/libmono.so
    70.     I/DEBUG   (15581):          56b4d24c  56b4da70
    71.     I/DEBUG   (15581):          56b4d250  00000001
    72.     I/DEBUG   (15581):          56b4d254 ffffffff
    73.     I/DEBUG   (15581):          56b4d258  50c29170
    74.     I/DEBUG   (15581):          56b4d25c  50c95048
    75.     I/DEBUG   (15581):     #02  56b4d260  00000000
    76.  
    I filtered it to what I thought would be helpful...
    The Second method:
    Code (CSharp):
    1.  
    2. public void ConnectWiFiHardWay()
    3. {
    4.    try
    5.    {
    6.  
    7.        using (AndroidJavaObject activity = new AndroidJavaClass("com.unity3d.player.UnityPlayer").GetStatic("currentActivity"))
    8.        {
    9.            using (var wifiManager = activity.Call("getSystemService", "wifi"))
    10.            {
    11.  
    12.                using (AndroidJavaObject classObj = wifiManager.Call("getClass"))
    13.                {
    14.                    using (AndroidJavaObject wifiConfiguration = new AndroidJavaObject("setWifiApEnabled"))
    15.                    {
    16.                        wifiConfiguration.Set("SSID", meSSID); // string
    17.                        wifiConfiguration.Set("preSharedKey", mePassword);
    18.                        using (AndroidJavaObject wifiCfgClass = wifiConfiguration.Call("getClass"))
    19.                        {
    20.                            using (AndroidJavaObject booleanObj = new AndroidJavaObject("java.lang.Boolean"))
    21.                            {
    22.                                using (AndroidJavaObject booleanClass = booleanObj.Call("getClass"))
    23.                                using (AndroidJavaObject methodObj = classObj.Call("getMethod", "setWifiApEnabled", wifiCfgClass, booleanClass))
    24.                                {
    25.                                    methodObj.Call("invoke", wifiManager, wifiConfiguration, enabled);
    26.                                }
    27.                            }
    28.                        }
    29.                    }
    30.                }
    31.            }
    32.        }
    33.    }
    34.    catch (System.Exception E)
    35.    {
    36.        T.text += "\nH - " + E.Message;
    37.        T.text += "\n\t" + E.StackTrace+"\n";
    38.    }
    39.  
    this one throws an exception that says setWifiApEnabled Cannot be found I can post the complete error text if that helps.
     
  2. ahmadian

    ahmadian

    Joined:
    Nov 24, 2015
    Posts:
    44
    If it is too messy just ignore the log I sent
     
  3. GLeBaTi

    GLeBaTi

    Joined:
    Jan 12, 2013
    Posts:
    41
    Do you solve this problem?