Pun2 working in android mode debug. but not working mode production
The whole answer can be found below.
Try Our
Documentation
Please check if you can find an answer in our extensive documentation on PUN.
Join Us
on Discord
Meet and talk to our staff and the entire Photon-Community via Discord.
Read More on
Stack Overflow
Find more information on Stack Overflow (for Circle members only).
Pun2 working in android mode debug. but not working mode production
Jhoan_steve_1994
2019-09-04 04:11:21
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
Jhoan_steve_1994
2019-09-06 01:11:02
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
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.
Jhoan_steve_1994
2019-09-07 02:53:52
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'
Jhoan_steve_1994
2019-09-08 02:59:54
My configuration @JohnTube mod
https://drive.google.com/file/d/1iEdR6O3QhG63f3DJdz82tLvLT0oU2lxL/view?usp=sharing
https://drive.google.com/file/d/1HFbb6tBINd78VCXVnfCFrnmErC9mRzFS/view?usp=sharing
https://drive.google.com/file/d/1Wjv79R0ztmRrsWm2xtpBvEGNCoj6M-Qz/view?usp=sharing
Jhoan_steve_1994
2019-09-08 21:14:35
// 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");
}
}
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";
- set PhotonNetwork.GameVersion just after calling PhotonNetwork.ConnectUsingSettings()
- set PhotonNetwork.PhotonServerSettings.AppSettings.AppVersion before calling PhotonNetwork.ConnectUsingSettings()
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";
.
Jhoan_steve_1994
2019-09-10 01:23:59
I created a new scene and a new script, I'm still having problems:
https://drive.google.com/file/d/1Fp9nVbcJcLmS1FhBmWBJSIKEqgfgKmqS/view?usp=sharing
Jhoan_steve_1994
2019-09-10 01:24:12
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();
}
}
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
Jhoan_steve_1994
2019-09-20 17:26:34
already solved
Hi @Jhoan_steve_1994,
Could you share with us how?
Back to top