Search Unity

Error when building and deploying project to Android phone

Discussion in 'Android' started by grovemaster, Oct 14, 2018.

  1. grovemaster

    grovemaster

    Joined:
    Jan 29, 2016
    Posts:
    5
    A few weeks ago, my project was able to build on both desktop and Android. Now, I can build a desktop build successfully, but the Android build encounters an error when attempting to deploy onto my phone. The project fails to deploy to my phone regardless of using Unity3D to make the deployment or using Android Studio to deploy the built SDK or using Android Studio to build and deploy the exported project. After some digging, I found the error message is:

    Error while executing: am start -n "com.MyPersonalProject.BoardGameApp/com.unity3d.player.UnityPlayerActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
    Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.MyPersonalProject.BoardGameApp/com.unity3d.player.UnityPlayerActivity }
    Error type 3
    Error: Activity class {com.MyPersonalProject.BoardGameApp/com.unity3d.player.UnityPlayerActivity} does not exist.

    That error message is the message Android Studio displays when attempting to deploy the project to my phone. I did not find a specific error message in Unity3D.

    To verify this is not my Unity3D installation, I created a brand new 2D Unity project with nothing in it. I was able to successfully build and deploy that blank project to my Android phone without issue.

    Does anyone have any suggestions on how to fix this?

    I already verified that the classes.jar is inside my Unity3D Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Variations\il2cpp\Release\Classes folder. My Unity3D version is 2018.2.12f1, although my project was created from an earlier version of Unity. I don't remember which version, but I installed Unity3D and started that project in July of this year.

    My source code is on Github. I can supply the link and instructions to build the project if anyone requires it.
     
  2. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    I've never faced such an issue, but the error says means it cannot find the app's main activity (UnityPlayerActivity).
    This is usually added by Unity itself as part of the build so this is pretty weird.

    Can you make sure this class exists in your built APK? (you can do this in Android studio, Analyze APK)
     
  3. grovemaster

    grovemaster

    Joined:
    Jan 29, 2016
    Posts:
    5
    I located the class in the classes.dex under com.unity3d. However, I also noticed a number of .xml and .smali files (such as AndroidManifest.xml file) that refernce the UnityPlayerActivity class, and those references are in red text because the class is unresolved.

    Example xml:
    Code (csharp):
    1.  
    2. <activity
    3.     android:label="@ref/0x7f030000"
    4.     android:name="com.unity3d.player.UnityPlayerActivity"
    5.     android:launchMode="2"
    6.     android:screenOrientation="10"
    7.     android:configChanges="0x40003fff"
    8.     android:hardwareAccelerated="false">
    What are your thoughts?
     
  4. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    Not sure, i never faced such an issue myself.
    Right now i don't have any ideas how to resolve this. if i think of anything i'll let u know.

    Please note i provide (paid) help where i remote control into your machine to look into it (in my signature below)
     
  5. grovemaster

    grovemaster

    Joined:
    Jan 29, 2016
    Posts:
    5
    To anyone else who encounters this problem, I'm not sure of the cause, but I started a new project & copied over the following file/folders:
    * .gitignore
    * .gitmodules
    * Assets/
    Then the mobile build worked.

    If anyone knows what could have caused this problem in the first place, please voice your thoughts.
     
    Last edited: Oct 16, 2018
  6. grovemaster

    grovemaster

    Joined:
    Jan 29, 2016
    Posts:
    5
    Update: To anyone else who encounters this problem, I found the problem and the solution.
    Problem: When I "uninstalled" the Unity3D app, my phone merely disabled it, instead of removing it completely.
    Solution: Manually ensure the Unity3D app is uninstalled and removed from the phone in question.

    When the app was disabled, but not removed, Unity3D could not properly install an updated version of that app and problems arose.
     
    JuliusM likes this.