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 Native plugin is not updated in build unless I delete and build twice

Discussion in 'Editor & General Support' started by weiner_monkey, Oct 5, 2023 at 8:35 AM.

  1. weiner_monkey

    weiner_monkey

    Joined:
    Aug 1, 2022
    Posts:
    49
    This is very annoying, I'm working on a native library which has frequent changes, when I switch the library in the project and build, it runs the same old library. I need to delete the library, build without it, add it, and build it again for it to be updated. I believe this is cached somewhere but I dont know where. any solutions?
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    3,721
    The library is a DLL file placed somewhere in the Assets tree?
    What do you mean by "switch the library"? You mean you replace it with a newly built version?

    Try right-clicking the file after a change and choose Reimport. If the build then has the new version, the issue is because the AssetDatabase did not realize that the file has changed. This should not normally happen unless you have Auto-Refresh disabled.

    It can also happen if an editor script has a bug causing the AssetDatabase auto-refresh to be "stopped". This can happen for example if an editor script uses AssetDatabase.StartAssetEditing without the recommended try/catch/finally block that calls StopAssetEditing in the finally block.
     
  3. weiner_monkey

    weiner_monkey

    Joined:
    Aug 1, 2022
    Posts:
    49
    This is added in an empty project, its a native android library. I have not tried reimport but a dirty solution that works is going to the Library folder, searching for all instances of library, such as "libnative.so" and deleting them
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,283
    There should be a little yellow text warning to this effect when you select the DLL. This is just how Unity works: shared libraries mounted are not dismounted until the editor exits.

    Exit the editor when you update the library, then restart the editor.

    Not sure what's in your native library, but Unity can directly compile C / C++ code just by putting it into Assets/Plugins/ and marking it for inclusion in various platforms.

    Once I discovered this I was finally able to uninstall Jet-For-Brains Android Studio. Best uninstall I ever made. That thing took 14 minutes to compile my native libraries into an AAR, the same C / C++ code that Xcode built in 3 seconds.
     
  5. weiner_monkey

    weiner_monkey

    Joined:
    Aug 1, 2022
    Posts:
    49
    Since just deleting the library in the Library folder works without exit, I'll stick with that. Also I'm directly compiling on the command line with NDK, no Android Studio or Java so it takes less than 10 seconds
     
    Kurt-Dekker likes this.
  6. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,449
    That's how it works for editor libraries. He's using an Android library, it never gets loaded in the editor.

    Can we get a bug report on this?
     
    Kurt-Dekker likes this.
  7. weiner_monkey

    weiner_monkey

    Joined:
    Aug 1, 2022
    Posts:
    49
    Sure, I'll create a report