Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question AndroidJavaException: java.lang.ClassNotFoundException

Discussion in 'Android' started by UnityProdS, Aug 3, 2023.

  1. UnityProdS

    UnityProdS

    Joined:
    Jan 11, 2014
    Posts:
    35
    I am on Unity version 2023.1.6f1
    Using GooglePlayGamesPlugin-0.11.01 to integrate Google Play services.


    My code looks as below.

    Code (CSharp):
    1.  
    2. private void Start()
    3.     {
    4.         PlayGamesPlatform.DebugLogEnabled = true;
    5.         PlayGamesPlatform.Activate();
    6.         Debug.Log("START CALLED");
    7.         PlayGamesPlatform.Instance.Authenticate(ProcessAuthentication);
    8.       }
    9.  
    10.     internal void ProcessAuthentication(SignInStatus status)
    11.     {
    12.         Debug.Log("UNITY AUTH " + status);
    13.         if (status == SignInStatus.Success)
    14.         {
    15.                Debug.Log("UNITY AUTH INSIDE SUCCESS "+status);
    16.         }
    17.         else
    18.         {
    19.             Debug.Log("UNITY AUTH INSIDE UNSUCCESSFUL " + status);
    20.         }
    21.     }
    I am able to compile the code and publish it on my Android phone. I get an error when the app is running on the device.

    AndroidJavaException: java.lang.ClassNotFoundException: com.google.android.gms.games.PlayGames

    I have deleted the Library folder and let Unity rebuild the folder again, I ran Android Resolver. Nothing worked.

    Any guidance/directions is greatly appreciated.

    Thanks!
     
  2. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,632
    Could be due to minification. Try using disabing it in Player Settings -> Publishing.
     
  3. UnityProdS

    UnityProdS

    Joined:
    Jan 11, 2014
    Posts:
    35
    I tried changing the path in GooglePlayGamesPluginDependencies.xml file as below
    from Packages/com.google.play.games/Editor/m2repository to Assets/com.google.play.games/Editor/m2repository

    As this seems to the correct path.

    I tried enabling and then disabling "Custom progaurd file"

    I tried enabling and disabling "Minify" to release and debug both

    Nothing seems to be working, I am unable to figure out what is missing
     
  4. UnityProdS

    UnityProdS

    Joined:
    Jan 11, 2014
    Posts:
    35
    Thanks for the response, I have tried already disabling it once, enabling and disabling "release" and "debug" as well.
     
  5. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,632
    Try exporting Android Studio project and using that class in any way from Java code.
     
  6. UnityProdS

    UnityProdS

    Joined:
    Jan 11, 2014
    Posts:
    35
    Never done that, is there a way you send a few links on how to do it? And interestingly why does it build successfully if it's an editor-level issue?
     
  7. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,632
    Unity always produces gradle project for Android. There is a checkbox in Build Settings window that makes this project in your chosen directory and does not build further.
    By using Android Studio you can determine if it's a problem with Unity integration, or with the project itself. If project is fine, you should be able to modify Java code and use the Java class you get an error for.
     
  8. UnityProdS

    UnityProdS

    Joined:
    Jan 11, 2014
    Posts:
    35
    Ok, looks like a way complicated solution for me, let me try and come back.
     
  9. UnityProdS

    UnityProdS

    Joined:
    Jan 11, 2014
    Posts:
    35
    This is way beyond my capability. I tried following the instructions and stopped as I couldn't continue.

    I tried using Unity 2022.3.5f1. Same issue. Looks like "GooglePlayGamesPlugin-0.11.01" for Unity is messed up.
    Is there a way I can download the previous versions of the google play services for Unity?

    The difficulty is I don't know where exactly is the problem.

    Please help a game I was developing is now stuck.