The above error can occur if the working library is not cleared properly before compiling your files. To avoid the error, clear any previous simulation data and then compile your files.
Right-click on the working library
Select Delete simulation data
Add the adel command after the mapping of each library.
adel -lib <library_name> -all
So in your script, when you create a library (alib command), map the specify library (amap command), then you need to refresh the contents of library. So with adel command you can just delete the library and its contents. Then it will compile the specific files for the library.