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

Resolved Looking to create debug symbols in an exported android project (2020.3)

Discussion in 'Android' started by bencoPB, Mar 10, 2022.

  1. bencoPB

    bencoPB

    Joined:
    Jul 13, 2018
    Posts:
    14
    According to the Manual here,
    https://docs.unity3d.com/2020.3/Documentation/Manual/android-symbols.html

    If you enable Export Project in the Android Build Settings, Unity doesn’t build the project or generate symbols when you run the build process. Instead, it exports the project for Android Studio and creates an empty directory at unityLibrary/symbols in the output directory. When you build your exported project from Android Studio, Gradle generates the libil2cpp symbol file and places it within the unityLibrary/symbols/<architecture>/ directory.
    I have not found it to be true that a symbols directory is created in the unityLibrary directory, nor do I see debug symbols generated when the android project is built.

    I've tried building the exported android project, but I do not see the generation of debug symbols happening.

    My team has been generating the symbols in Unity 2019, so I would like to continue doing so in Unity 2020.

    Could anyone offer information or help?

    Thank you!
     
    Last edited: Mar 10, 2022
  2. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,663
    Is your scripting backend set to il2cpp? I can confirm unityLibrary\symbols\armeabi-v7a\libil2cpp.so is being created when gradle build is invoked.

    libunity.so symbol in <unity_project>Temp\StagingArea\symbols\armeabi-v7a if Strip Engine Code On.
     
    bencoPB likes this.
  3. bencoPB

    bencoPB

    Joined:
    Jul 13, 2018
    Posts:
    14
    Thank you. That was the issue... how silly of me.

    In the correctly set IL2CPP build, I do see the symbols folder and the
    .so
    files. It is just the zip folder that is no longer created as of 2020.
     
  4. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,663
    it's because when you export gradle project, il2cpp library is compiled from gradle, thus there's no point in creating zip package, since it would be missing libil2cpp.so symbols. I understand it's might be inconvenient for you, since it forces you to manually gather symbols like libunity.so, in 2021.2 unityLibrary/symbols will contain libunity.so/libmain.so when you'll do Export Project, thus you won't need to gather them manually.
     
  5. bencoPB

    bencoPB

    Joined:
    Jul 13, 2018
    Posts:
    14
    Good to know!

    Thank you again for the information.
     
  6. sandeepsmartest

    sandeepsmartest

    Joined:
    Nov 7, 2012
    Posts:
    138
    hi @Tomas1856 i was able to see libil2cpp.dbg.so, libil2cpp.sym.so, libunity.sym.so.
    Exported as Android studio project. However i couldnot see libmain symbol file??
    Im using unity 2019.4.8.
    And can we upload all these symbols to unity CD programatically via Jenkins CI? and what exactly libil2cpp.dbg.so means?(i believe it is a debug symbol file then what is libil2cpp.sym.so -public symbol? CMIIW ).
    Generating these files using EditorUserBuildSettings.androidCreateSymbols api could cause any performance impact on the builds on Android devices???
    please pointe me in right direction.
    Thanks in advance
     
  7. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,663
    2019 is no longer supported, the symbol exporting in 2019 had not been done fully correctly, that's why some files were missing and extensions are incorrect. You would need to manually rename libil2cpp.sym.so -> libil2cpp.so, you can get libmain.so from Unity installation directory in Android folder
     
    sandeepsmartest likes this.
  8. sandeepsmartest

    sandeepsmartest

    Joined:
    Nov 7, 2012
    Posts:
    138
    Thanks for the quick information. Could you please throw some light on below points
    1. Can we upload all these symbols to unity CD programatically via Jenkins CI - Not supported I believe - pls CMIIW
    2. Generating these files using EditorUserBuildSettings.androidCreateSymbols api could cause any performance impact on the builds on Android devices???
     
  9. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,663
    1. Is CD stand for cloud diagnostics? Is it Unity's Cloud Diagnostics? I think that's done automatically whenever you produce a build from Unity, meaning the symbols are uploaded automatically to Unity Cloud Diagnostics.
    2. The runtime/performance isn't affected in any way, no matter what EditorUserBuildSettings.androidCreateSymbols value is set.
     
  10. sandeepsmartest

    sandeepsmartest

    Joined:
    Nov 7, 2012
    Posts:
    138
    Thanks again for the quick response.
    1. Yes il2cpp symbols were uploaded to unity cloud diagnostic(CD) and i could see the stack trace resolved but not for libunity or libmain
    2. Thanks for confirming on the second point
     
  11. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,663
    Regarding 1. you could try asking here - https://forum.unity.com/forums/unity-cloud-diagnostics.83/, but I doubt they'll fix it, since Unity 2019 is no longer supported.
     
  12. anguha

    anguha

    Joined:
    May 4, 2023
    Posts:
    23
    I have one confusion @Tomas1856. Using Unity 2021.3.14f1. On the Unity Android export, I can see two .so files inside unityLibrary/symbols/<arch>. And according to the manual, libil2cpp.so is created by the gradle invocation. Does that mean, I explicitly do not have to copy the libil2cpp.dbg.so ? Also, after building the gradle project I dont see libil2cpp.so anywhere. Can anyone please clear this confusion?
     
  13. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,663
    If you're using Unity 2021.x, then no - you don't need to copy libil2cpp.dbg.so

    Just to be sure, your selected scripting backend is Il2Cpp and not Mono? And you build gradle project from Android Studio ?
     
  14. anguha

    anguha

    Joined:
    May 4, 2023
    Posts:
    23
    Yes I am using Il2Cpp as Scripting Backend. And yes, I am getting the Android export from Unity and building the gradle project using Android Studio. I don't see the libil2cpp.so anywhere under unityLibrary/symbols/.. Not sure if I am missing something here.

    I can only see libmain.so and libunity.so
     
    Last edited: May 17, 2023
  15. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,663
    The code piece which copies the il2cpp symbols is in unityLibrary/build.gradle, locate
    BuildIl2Cpp task, there are lines like these:

    Code (CSharp):
    1.     delete workingDir + "/src/main/jniLibs/" + abi + "/libil2cpp.sym.so"
    2.     ant.move(file: workingDir + "/src/main/jniLibs/" + abi + "/libil2cpp.dbg.so", tofile: workingDir + "/symbols/" + abi + "/libil2cpp.so")
     
  16. anguha

    anguha

    Joined:
    May 4, 2023
    Posts:
    23

    Yes so now since in Unity 2021.x `libil2cpp.dbg.so` does not need to be explicitly copied, the `libil2cpp.so` should be be at this path correct? -->`.../unityLibrary/symbols/armeabi-v7a/libil2cpp.so`

    However, the gradle build does not seem to create it at that location or anywhere else for that matter. What could be the reason behind this?
     
  17. anguha

    anguha

    Joined:
    May 4, 2023
    Posts:
    23
    Code (CSharp):
    1. workingDir + "/src/main/Il2CppOutputProject/IL2CPP/build/deploy/il2cpp",
    2.             "--compile-cpp",
    3.             "--libil2cpp-static",
    4.             "--platform=Android",
    5.             "--architecture=" + architecture,
    6.             "--configuration=" + configuration,
    7.             "--outputpath=" + workingDir + targetDirectory + abi + "/libil2cpp.so",
    8.             "--cachedirectory=" + workingDir + "/build/il2cpp_"+ abi + "_" + configuration + "/il2cpp_cache",
    9.             "--additional-include-directories=" + workingDir + "/src/main/Il2CppOutputProject/IL2CPP/external/bdwgc/include",
    10.             "--additional-include-directories=" + workingDir + "/src/main/Il2CppOutputProject/IL2CPP/libil2cpp/include",
    11.             "--tool-chain-path=" + android.ndkPath,
    12.             "--map-file-parser=" + workingDir + "/src/main/Il2CppOutputProject/IL2CPP/MapFileParser/MapFileParser.exe",
    13.             "--generatedcppdir=" + workingDir + "/src/main/Il2CppOutputProject/Source/il2cppOutput",
    14.             "--baselib-directory=" + workingDir + "/src/main/jniStaticLibs/" + abi,
    15.             "--dotnetprofile=unityaot"

    This is the command I am using. Could there be anything missing/wrong here @Tomas1856?
     
  18. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,663
    Let's forget about symbol file for a moment, does shared library libil2cpp.so is created in src/main/jniLibs directory? And does your app run fine on the device?

    And do you see BuildIl2CppTask being called during gradle build ?
     
  19. anguha

    anguha

    Joined:
    May 4, 2023
    Posts:
    23
    I am upgrading to Unity 2021.3.14f1 from Unity2020. Yes `BuildIl2CppTask` is correctly called in build.gradle. But `':unityLibrary:BuildIl2CppTask'`. failing because the .so file is not found

    No I do not see `libil2cpp.so` inside src/main/jniLibs.
     

    Attached Files:

    Last edited: May 17, 2023
  20. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,663
    Can you share the logs, maybe there was a compilation error, because the script first produces libil2cpp.so shared library and only then tries to copy symbols
     
  21. anguha

    anguha

    Joined:
    May 4, 2023
    Posts:
    23
    This is log from gradle build
    Code (CSharp):
    1.  
    2. Executing tasks: [:launcher:assembleDebug, :launcher:assembleDebugUnitTest, :launcher:assembleDebugAndroidTest] in project /Users/anguha/Desktop/active_export/TT.apk
    3.  
    4.  
    5. > Configure project :launcher
    6. WARNING: The option setting 'android.enableR8=false'//developer.android.com/r/studio-ui/ndk-dir
    7. NDK was located by using ndk.dir property. This method is deprecated and will be removed in a future release. Please use android.ndkVersion or android.ndkPath in build.gradle to specify the NDK to use. https://developer.android.com/r/studio-ui/ndk-dir
    8. setting ANDROID_SDK_ROOT
    9. Either unknown arguments were used or one or more assemblies could not be found :
    10. --map-file-parser=/Users/anguha/Desktop/active_export/TT.apk/unityLibrary/src/main/Il2CppOutputProject/IL2CPP/MapFileParser/MapFileParser
    11.  
    12. > Task :launcher:checkDebugAarMetadata UP-TO-DATE
    13. > Task :launcher:generateDebugResValues UP-TO-DATE
    14. > Task :launcher:generateDebugResources UP-TO-DATE
    15. > Task :launcher:mergeDebugResources UP-TO-DATE
    16. > Task :launcher:createDebugCompatibleScreenManifests UP-TO-DATE
    17. > Task :launcher:extractDeepLinksDebug UP-TO-DATE
    18. > Task :launcher:processDebugMainManifest UP-TO-DATE
    19. > Task :launcher:processDebugManifest UP-TO-DATE
    20. > Task :launcher:processDebugManifestForPackage UP-TO-DATE
    21. > Task :launcher:mergeDebugJniLibFolders UP-TO-DATE
    22. > Task :launcher:mergeDebugShaders UP-TO-DATE
    23. > Task :launcher:compileDebugShaders NO-SOURCE
    24. > Task :launcher:generateDebugAssets UP-TO-DATE
    25. > Task :launcher:processDebugJavaRes NO-SOURCE
    26. > Task :launcher:mergeDebugJavaResource UP-TO-DATE
    27. > Task :launcher:checkDebugDuplicateClasses UP-TO-DATE
    28. > Task :launcher:desugarDebugFileDependencies UP-TO-DATE
    29. > Task :launcher:validateSigningDebug UP-TO-DATE
    30. > Task :launcher:preDebugUnitTestBuild UP-TO-DATE
    31. > Task :launcher:javaPreCompileDebugUnitTest UP-TO-DATE
    32. > Task :launcher:processDebugUnitTestJavaRes NO-SOURCE
    33. > Task :launcher:preDebugAndroidTestBuild SKIPPED
    34. > Task :launcher:compileDebugAndroidTestAidl NO-SOURCE
    35. > Task :launcher:processDebugAndroidTestManifest UP-TO-DATE
    36. > Task :launcher:compileDebugAndroidTestRenderscript NO-SOURCE
    37. > Task :launcher:generateDebugAndroidTestBuildConfig UP-TO-DATE
    38. > Task :launcher:javaPreCompileDebugAndroidTest UP-TO-DATE
    39. > Task :launcher:checkDebugAndroidTestAarMetadata UP-TO-DATE
    40. > Task :launcher:generateDebugAndroidTestResValues UP-TO-DATE
    41. > Task :launcher:generateDebugAndroidTestResources UP-TO-DATE
    42. > Task :launcher:mergeDebugAndroidTestResources UP-TO-DATE
    43. > Task :launcher:mergeDebugAndroidTestShaders UP-TO-DATE
    44. > Task :launcher:compileDebugAndroidTestShaders NO-SOURCE
    45. > Task :launcher:generateDebugAndroidTestAssets UP-TO-DATE
    46. > Task :launcher:processDebugAndroidTestJavaRes NO-SOURCE
    47. > Task :launcher:mergeDebugAndroidTestJavaResource UP-TO-DATE
    48. > Task :launcher:mergeDebugAndroidTestJniLibFolders UP-TO-DATE
    49. > Task :launcher:checkDebugAndroidTestDuplicateClasses UP-TO-DATE
    50. > Task :launcher:desugarDebugAndroidTestFileDependencies UP-TO-DATE
    51. > Task :launcher:validateSigningDebugAndroidTest UP-TO-DATE
    52. > Task :unityLibrary:generateDebugRFile UP-TO-DATE
    53. > Task :unityLibrary:compileDebugJavaWithJavac UP-TO-DATE
    54. > Task :unityLibrary:bundleLibCompileToJarDebug UP-TO-DATE
    55. > Task :unityLibrary:mergeDebugShaders UP-TO-DATE
    56. > Task :unityLibrary:compileDebugShaders NO-SOURCE
    57. > Task :unityLibrary:generateDebugAssets UP-TO-DATE
    58. > Task :launcher:processDebugResources UP-TO-DATE
    59. > Task :launcher:compileDebugJavaWithJavac UP-TO-DATE
    60. > Task :launcher:compileDebugSources UP-TO-DATE
    61. > Task :launcher:bundleDebugClasses UP-TO-DATE
    62. > Task :launcher:compileDebugUnitTestJavaWithJavac NO-SOURCE
    63. > Task :launcher:compileDebugUnitTestSources UP-TO-DATE
    64. > Task :launcher:assembleDebugUnitTest UP-TO-DATE
    65. > Task :launcher:processDebugAndroidTestResources UP-TO-DATE
    66. > Task :launcher:compileDebugAndroidTestJavaWithJavac UP-TO-DATE
    67. > Task :launcher:compileDebugAndroidTestSources UP-TO-DATE
    68. > Task :unityLibrary:packageDebugAssets UP-TO-DATE
    69. > Task :unityLibrary:bundleLibRuntimeToJarDebug UP-TO-DATE
    70. > Task :launcher:mergeDebugAssets UP-TO-DATE
    71. > Task :launcher:compressDebugAssets UP-TO-DATE
    72. > Task :launcher:dexBuilderDebug UP-TO-DATE
    73. > Task :launcher:multiDexListDebug UP-TO-DATE
    74. > Task :launcher:mergeDexDebug UP-TO-DATE
    75. > Task :launcher:mergeDebugAndroidTestAssets UP-TO-DATE
    76. > Task :launcher:compressDebugAndroidTestAssets UP-TO-DATE
    77. > Task :launcher:dexBuilderDebugAndroidTest UP-TO-DATE
    78. > Task :launcher:multiDexListDebugAndroidTest UP-TO-DATE
    79. > Task :launcher:mergeDexDebugAndroidTest UP-TO-DATE
    80.  
    81. FAILURE: Build failed with an exception.
    82.  
    83. * Where:
    84. Build file '/Users/anguha/Desktop/active_export/TT.apk/unityLibrary/build.gradle' line: 264
    85.  
    86. * What went wrong:
    87. Execution failed for task ':unityLibrary:BuildIl2CppTask'.
    88. > Process 'command '/Users/anguha/Desktop/active_export/TT.apk/unityLibrary/src/main/Il2CppOutputProject/IL2CPP/build/deploy/il2cpp'' finished with non-zero exit value 2
    89.  
    90. * Try:
    91. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
    92.  
    93. * Get more help at https://help.gradle.org
    94.  
    95. BUILD FAILED in 10s
    96. 111 actionable tasks: 1 executed, 110 up-to-date
     
  22. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,663
    il2cpp process has exited with error, that means it didn't produce neither a shared library, neither a symbol file, thus there's nothing to copy

    I think there should be an output from il2pp tool somewhere in Android Studio, try to locate it.
     
  23. anguha

    anguha

    Joined:
    May 4, 2023
    Posts:
    23
    Ok. So I removed this from the command.
    Code (CSharp):
    1. --map-file-parser=" + workingDir + "/src/main/Il2CppOutputProject/IL2CPP/MapFileParser/MapFileParser
    And everything worked fine including the symbol file generation. Build succeeded. The reason it failed is because it's unable to find `MapFileParser`. The Unity Android Export did not seem to have it. Any idea why this can go missing from the unity export? Any workaround to include it in the export?
     
  24. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,663
    You might be hitting a bug, I just checked locally and my gradle script doesn't have flag for MapFileParser, I'll ask around to see which setting in Unity project causes this entry to appear
     
  25. anguha

    anguha

    Joined:
    May 4, 2023
    Posts:
    23
    Oh so let me explain again, I explicitly added that flag in the command inside
    `BuildIl2Cpp` task in the gradle build script. Is it not required? I read something about that its optional, but without it stack traces can get messed up, which is not feasible at all.
     
  26. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,663
    As far I know MapFileParser was removed in some Unity version, maybe even Unity 2021. Unity will add the necessary command line flags, so you shouldn't need to add any flags yourself.
     
  27. anguha

    anguha

    Joined:
    May 4, 2023
    Posts:
    23
    I see. I am ignoring this flag for now.
    One more issue I am seeing is this in logs only when I enabled verbose login in the gradle build.

    Code (CSharp):
    1. file or directory '/../unityLibrary/GooglePlayGamesManifest.plugin/bin', not found
    2.  
    3. file or directory '/../unityLibrary/GooglePlayGamesManifest.plugin/libs', not found
    Getting similar errors for other .androidlibs as well inside Assets/Plugins/Android. I did not get any warning or exception, just found it from verbose logging. And I verified, google play login is not working. My confusion, is Unity Android export did not create this. And earlier, these two directories were not there. So is Unity supposed to create the libs and bin in that path. Or am I supposed to use some tool to generate it?
     
  28. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,663
    Sorry, I am not sure what those errors are, do they prevent you from doing a successful build?
     
  29. anguha

    anguha

    Joined:
    May 4, 2023
    Posts:
    23
    No it does not block me from getting builds. But I checked that Google Play login is not working. It must be related to this.
     
  30. anguha

    anguha

    Joined:
    May 4, 2023
    Posts:
    23
    I am seeing an issue
    Code (CSharp):
    1. Thread 0x70000823a000 may have been prematurely finalized    0x7fff20856443 - /usr/lib/system/libsystem_pthread.dylib : thread_start
    2. 01:14:27.212 #8  0x007fff20856443 in thread_start
    This happens in non-development builds where we are using the Asset or Prefab Utility api to do certain things. I dont see anything in release notes/ changelog. Can you point me to any related threads for this @Tomas1856 ?
     
  31. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,663
    Sorry, I don't know what this error message is about. If it's causing a crash for you, could you submit a bug with repro project attached? Thank you