That doesn't help in what I'm talking about. To continue the last bit of code you posted above...
If Starter.ClassChecker1.ClassExist("anywheresoftware.b4a.objects.SocketWrapper.ServerSocketWrapper") Then
Dim Svr1 as Server Socket ' Throws a warning of "Unknown type: serversocket" and, obviously, doesn't compile because (see next paragraph)
Svr1.Initialize(0,Null)
End If
The Networking library isn't loaded in this particular project. And doesn't need to be in this project. It isn't used. So, you're asking yourself: "Self, then why include the code that calls this library?" It's because this code is just a small utility sub along with a whole lot of other utility subs in a shared code module that gets used between several projects. If I don't need the Networking library in this project, then why include it (I'd be including a dozen libraries in every project that's likely not needed)? That shouldn't mean I have to have multiple shared code modules depending on which combination of libraries that are loaded in a given project.
Any way to tell if a library is loaded and have the compiler ignore the references from code?
As in ...
If ServerSocket then
Dim Server as ServerSocket
...
End If
... or ...
If LibraryLoaded("ServerSocket") then
...
End IF
I'd even take an #ignorewarnings for this and let it compile even though the library doesn't exist in the project.
My alternative is to create shared code modules based on libraries (ie: Network.bas, Audio.bas, Animation.bas, etc.) instead of just one shared code module. It'd sure be nice to just have a single call to see if a library is loaded, though.