Pun2 working in android mode debug. but not working mode production

When I work photon test mode works without problems, but when I generate the apk and install it it generates the following error:

https://drive.google.com/file/d/1LEhemHSI-7QQQrqxJO_cdGniSWxiU5uX/view?usp=sharing


apparently says that class 'photon.pun' does not exist

Comments

  • when I exported in 'Build an rund' mode I have no problems with photon, but when I export in 'Build' mode and install it manually I have the following problem
  • JohnTubeJohnTube mod
    edited September 6
    Hi @Jhoan_steve_1994,

    Thank you for your report!

    What PUN version are you using?
    What Unity version are you using?

    Could you share the whole stacktrace of the exception and the code snippet where you set PhotonNetwork.NickName.
    This is a tricky timing issue.
  • edited September 7
    Unity 2018.4.8.f1 LTS
    Pun2-FREE / Pun 2.12 photon lib:4.1.2.14


    El problem is PhotonNetwork.GameVersion, PhotonNetwork.NickName, PhotonNetwork.AutomaticallySyncScene , etc.

    I have problems with every photon in modo 'Build'

  • edited September 9
    // My code, error en PhotonNetwork.GameVersion.
    //Object reference not set to an instance of an object in .Photon.Pun.PhotonNetwork.set_GameVersion
    //

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using Photon.Pun;
    using Photon.Realtime;
    using UnityEngine.UI;
    using System;
    
    
    public class MenuNetworking : MonoBehaviourPunCallbacks
    {
        public Text NetworkClientState;
        public GameObject PanelCreate;
        public GameObject cargando;
        public InputField nameRoom;
        public Text scenaMap, ModeGame, MaxPlayer, MaxKills, errrror;
        int mapIndex = 0;
        int ModeGameIndex = 0;
        int MaxPlayerIndex = 2;
        int MaxKillsIndex = 0;
    
        void Start()
        {
          
            connect();
            load();
            cargando.SetActive(false);
            /*if (PhotonNetwork.NickName.Length <= 0)
                PhotonNetwork.NickName = "Player" + UnityEngine.Random.Range(1, 44);
            PlayerName.text = PhotonNetwork.NickName;*/
    
            
        }
    
    
        void load()
        {
          
    
            nameRoom.text = "Room" + UnityEngine.Random.Range(1, 100);
            scenaMap.text = Properties.Room.MapNames[mapIndex];
            ModeGame.text = Properties.Room.ModeGame.Names[ModeGameIndex];
            MaxPlayer.text =""+ Properties.Room.MaxPlayers.Names[MaxPlayerIndex];
            MaxKills.text = "" + Properties.Room.MaxKills.Names[MaxKillsIndex];
    
        }
    
        // Update is called once per frame
        void Update()
        {
    
            //if (NetworkClientState.text != "Disconnected")
              //  NetworkClientState.text = PhotonNetwork.NetworkClientState.ToString();
    
            if(NetworkClientState.text=="Disconnected")
                reconectar();
        }
    
        public void connect()
        {
    
            try
            {
                if (PhotonNetwork.IsConnected)
                    return;
    
                PhotonNetwork.GameVersion = "1";
                PhotonNetwork.PhotonServerSettings.AppSettings.FixedRegion = "us";
    
                PhotonNetwork.AutomaticallySyncScene = true;
                PhotonNetwork.ConnectUsingSettings();
            }
            catch (Exception e)
            {
                errrror.enabled = true;
                errrror.text = e.ToString();
    
            }
    
           
        }
       
        void reconectar()
        {
            PhotonNetwork.Reconnect();
        }
        //btn clisks
        public void BtnInventary()
        {
            if (!PhotonNetwork.IsConnected)
                connect();
    
            if (NetworkClientState.text != "JoinedLobby")
                return;
    
            Application.LoadLevel("Inventary");
        }
    
    
        public void btnCreate()
        {
            if (!PhotonNetwork.IsConnected)
                connect();
    
            if (NetworkClientState.text != "JoinedLobby")
                return;
            PanelCreate.SetActive(true);
        }
        public void BtnCerrarApp()
        {
            Application.Quit();
        }
    
        public void BtnCreateCancel()
        {
            PanelCreate.SetActive(false);
        }
    
        public void BtnCreateRoom()
        {
            if (nameRoom.text.Length == 0)
                nameRoom.text = "Room" + UnityEngine.Random.Range(1, 100);
    
            Properties.Room.Create(
                nameRoom.text,
                int.Parse(MaxPlayer.text),
                int.Parse(MaxKills.text),
                scenaMap.text,
                 ModeGameIndex
            );
            cargando.SetActive(true);
            Application.LoadLevel(scenaMap.text);
        }
    
        public void RandonGame()
        {
            if (NetworkClientState.text != "JoinedLobby")
                return;
            Properties.Room.joinOrCreate();
            Application.LoadLevel("SampleScene");
        }
    
    
        public void BtnNextMap()
        {
            if ((mapIndex + 1) >= Properties.Room.MapNames.Length)
                return;
    
            mapIndex++;
            scenaMap.text = Properties.Room.MapNames[mapIndex];
        }
        public void BtnBeforeMap()
        {
            if ((mapIndex - 1) < 0)
                return;
            mapIndex--;
            scenaMap.text = Properties.Room.MapNames[mapIndex];
        }
        /** **/
        public void BtnNextModeGame()
        {
            if ((ModeGameIndex + 1) >= Properties.Room.ModeGame.Names.Length)
                return;
    
            ModeGameIndex++;
            ModeGame.text = Properties.Room.ModeGame.Names[ModeGameIndex];
        }
        public void BtnBeforeModeGame()
        {
            if ((ModeGameIndex - 1) < 0)
                return;
            ModeGameIndex--;
            ModeGame.text = Properties.Room.ModeGame.Names[ModeGameIndex];
        }
        /** **/
        public void BtnNextMaxPlayer()
        {
            if ((MaxPlayerIndex + 1) >= Properties.Room.MaxPlayers.Names.Length)
                return;
    
            MaxPlayerIndex++;
            MaxPlayer.text =""+ Properties.Room.MaxPlayers.Names[MaxPlayerIndex];
        }
        public void BtnBeforeMaxPlayer()
        {
            if ((MaxPlayerIndex - 1) < 0)
                return;
            MaxPlayerIndex--;
            MaxPlayer.text = "" + Properties.Room.MaxPlayers.Names[MaxPlayerIndex];
        }
        /** **/
        public void BtnNextMaxKills()
        {
            if ((MaxKillsIndex + 1) >= Properties.Room.MaxKills.Names.Length)
                return;
    
            MaxKillsIndex++;
            MaxKills.text = "" + Properties.Room.MaxKills.Names[MaxKillsIndex];
        }
        public void BtnBeforeMaxKills()
        {
            if ((MaxKillsIndex - 1) < 0)
                return;
            MaxKillsIndex--;
            MaxKills.text = "" + Properties.Room.MaxKills.Names[MaxKillsIndex];
        }
    
        //photon
    
        public override void OnConnectedToMaster()
        {
            Debug.Log("OnConnectedToMaster");
            PhotonNetwork.JoinLobby();
        }
    
        public override void OnJoinedLobby()
        {
            Debug.Log("OnJoinedLobby");
        }
    
        public override void OnJoinedRoom()
        {
            Debug.Log("OnJoinedRoom");
            base.OnJoinedRoom();
        }
    
        public override void OnDisconnected(DisconnectCause cause)
        {
            NetworkClientState.text = cause.ToString();
           Debug.Log("Diconnect:"+ cause.ToString());
    
            //connect();
            //reconectar();
        }
    
        public override void OnLeftLobby()
        {
            Debug.Log("OnLeftLobby");
        }
    
        public override void OnCreateRoomFailed(short returnCode, string message)
        {
            cargando.SetActive(false);
            Debug.Log("OnCreateRoomFailed");
        }
    
        public override void OnJoinRoomFailed(short returnCode, string message)
        {
            cargando.SetActive(false);
            Debug.Log("OnJoinRoomFailed");
        }
    
        public override void OnJoinRandomFailed(short returnCode, string message)
        {
            cargando.SetActive(false);
            Debug.Log("OnPhotonRandomJoinFailed");
        }
        public override void OnLeftRoom()
        {
            Debug.Log("OnLeftRoom");
        }
    }
    
  • JohnTubeJohnTube mod
    edited September 9
    Hi @Jhoan_steve_1994,

    Even if there is no NullReferenceException, the following line code will not work as expected and the PhotonNetwork.GameVersion will not bet set and will be overridden by the PhotonNetwork.PhotonServerSettings.AppSettings.AppVersion inside PhotonNetwork.ConnectUsingSettings();
    PhotonNetwork.GameVersion = "1";
    
    PhotonNetwork.ConnectUsingSettings() no longer takes gameVersion parameter. Instead the AppVersion parameter set from the Unity Editor in the PhotonServerSettings, AppSettings section is used as PhotonNetwork.GameVersion. If you want to set the PhotonNetwork.GameVersion from code you could either:
    • set PhotonNetwork.GameVersion just after calling PhotonNetwork.ConnectUsingSettings()
    • set PhotonNetwork.PhotonServerSettings.AppSettings.AppVersion before calling PhotonNetwork.ConnectUsingSettings()
    [source]

    Otherwise, about the issue itself of the NullReferenceException in some PhotonNetwork properties, it looks like PhotonNetwork.NetworkingClient is still null while accessing those properties' getters or setters which is unexpected. We will investigate further.

    Also, I don't think you have NullReferenceException in PhotonNetwork.NickName or PhotonNetwork.AutomaticallySyncScene. Please provide full stack trace if you do. You can easily test this by adding those lines before PhotonNetwork.GameVersion = "1";.


  • I created a new scene and a new script, I'm still having problems:



    https://drive.google.com/file/d/1Fp9nVbcJcLmS1FhBmWBJSIKEqgfgKmqS/view?usp=sharing

  • edited September 10
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using Photon.Pun;
    using Photon.Realtime;
    using UnityEngine.UI;
    using System;
    
    public class DebugPhoton : MonoBehaviourPunCallbacks
    {
        public Text error,Status;
        void Start()
        {
            try
            {
                if (!PhotonNetwork.IsConnected)
                {
                    //PhotonNetwork.PhotonServerSettings.AppSettings.FixedRegion = "us";
                    PhotonNetwork.AutomaticallySyncScene = true;
                    PhotonNetwork.ConnectUsingSettings();
                    //PhotonNetwork.GameVersion = "1";
    
                }
            }
            catch (Exception e)
            {
                error.text = e.ToString();
    
            }
        }
    
        // Update is called once per frame
        void Update()
        {
            Status.text = PhotonNetwork.NetworkClientState.ToString();
        }
    
        public override void OnDisconnected(DisconnectCause cause)
        {
            Debug.Log("Diconnect:" + cause.ToString());
            error.text = error.text + "|" + cause.ToString();
            //connect();
            //reconectar();
        }
    
    }
  • JohnTubeJohnTube mod
    edited September 10
    Hi @Jhoan_steve_1994,

    Maybe the issue in the way you install the apk.
    How do you install it?
  • hey @Jhoan_steve_1994,

    any news regarding this?

    ---

    For me, it looks like there is an issue with your project or your machine or your device.
    This is unprecedented and we can't reproduce.

    Try:

    - Create a new empty fresh clean Unity project
    - Import only PUN2
    - properly setup PhotonServerSettings and make sure it's there
    - setup demo scenes
    - setup player settings for Android or whatever target platform
    - for the Build Settings, enable all debug options to be able to see whole stack trace (line numbers and methods chain calls), "Script Debugging", "Development Build" etc.
    - build and test demos scenes

    - build and test the demo scene + test script DebugPhoton

    If the issue persists:

    - try on different devices
    - try different Unity version
    - try different development machine
    - disable anti-virus software if any
  • already solved
  • Hi @Jhoan_steve_1994,

    Could you share with us how?
Sign In or Register to comment.