How to use Assembly Definitions properly?

Hello,

I am new to Unit Testing. I was trying to enable Test Runner in existing project. So I created “Tests” folder with assembly definition (AD) file and checked only “Editor” in “Included Platforms”. Then to be able to access the scripts, I added another AD to “Scripts” folder and this time checked “Editor, Andorid, iOS”. Then I got couple of missing references so I had to create two more “GoogleMobileAds.asmdef” and “PlayerPrefsEditor.asmdef” with the same three platforms and reference them from “Scripts.asmdef”. That resolved the issues in Unity Editor and I was able to create couple of Test/UnityTests.

However, when I tried to compile project for Andorid platform, I got different errors. They were all related to “Editor” subfolders inside “GoogleMobileAds” and “PlayerPrefsEditor” folders. So I created another AD inside those “Editor” folders and checked only “Editor” as “Included Platforms”.

**Question #1: Is that proper way to do it? (**for every “Editor” folder)
Answer: Yes, that’s how it should be done.

Then I finally compiled app and uploaded it to device, everything worked fine with exception of AdMob ads. I was using TestAds (ca-app-pub-3940256099942544/5224354917) so they should work all the time. However, I was getting “OnAdFailedToLoad” with “No fill” error message. I tried to manually add “Google.Play.Common.asmdef” to “Assembly Definition References” for “GoogleMobileAds.asmdef” but it did not help.

Question #2: How should I fix the issue with AdMob?
Answer: Using assemblies do not cause this bug. The test ads are not working in both Development Build and Release. The real ads are working ONLY in Release but not in Development Build. I tried to use both Mono and IL2CPP as Scripting Backend and to do “Android Resolver / Force Resolve”. Nothing helped but since actual ads are working, I am skipping this for now.

Question #3 (optional): How to check what other features stopped working?
Answer: As far as I understood, if some script is missing for some platform (you may not see error in Editor), you will get an error message when you will start building for that platform. If app was successfully built then everything is fine with assemblies and if issue remains it could be related to something else.

Thank you in advance for your tips and help

1 Like

UPD1: For strange reason, yesterday I was not able to notice error in logcat:

E/dalvikvm(11749): Could not find class ‘com.google.android.gms.ads.internal.util.o’, referenced from method com.google.android.gms.ads.nonagon.a.b

Seems like com.google.android.gms.ads assembly is missing. I can see that it’s located in Assets/Plugins/Android/GoogleMobileAdsPlugin/libs/unity-plugin-library.jar but how can I include it? The Unity manual states that when I will select jar plugins in editor, I should be able to select in which platforms it should be included. However, in my case editor show no options:

I tried to create new assembly from “Plugins” folder, including “Android” folder into Android platform and “iOS” for iOS but it did not help either.

At the same time I am able to see evens in Debug View of Firebase Analytics so it’s working properly (even though I have not included “Plugins/Android/Firebase” into build (or it’s automatically included by Unity?)

UPD2: I found answer for all three questions, in case someone will face the same issue.