Change Plugin platforms by scripting

I am making an Android game for both Google Play Store and Amazon Store.

I am using a user-defined scripting symbol “UNITY_AMAZON” and pre-processing to do the store specific scripting, but I also need to exclude some plugins when building for each target.
I don’t want some of the play-services .arr files in the Amazon build and I don’t want the Amazon .jars in the GooglePlay build.

Of course, I can always manually select and deselect the files I want from the editor. I am asking if this can be done by scripting to automate the process as there are quite many files to change.

Yes. Get its importer and then change settings on that. For example, this turns off the Android platform on a native library:

((PluginImporter)PluginImporter.GetAtPath("Assets/Plugins/Android/libs/armeabi-v7a/")).SetCompatibleWithPlatform(BuildTarget.Android, false);

I found some related discussion Check this if you haven’t


You have to adjust the settings on the library asset in the inspector to choose on which platform(s) this library should be included and used.

@a96andrei: We use this code to disable plugins like Firebase (since some features depend on Google Play Services):

    public static void ToggleFirebaseRemoteConfigDependencies(bool supportsGooglePlayServices)
        Debug.LogFormat("[ToggleFirebaseRemoteConfigDependencies]  Platform supports Google Play Services: {0}", supportsGooglePlayServices);
        const string remoteConfigPath = "Assets/Firebase/Plugins/Firebase.RemoteConfig.dll";
        TogglePluginEnabledOrDisabled(remoteConfigPath, supportsGooglePlayServices, BuildTarget.Android);

    private static void TogglePluginEnabledOrDisabled(string filePath, bool enableFile, BuildTarget buildTarget)
        var pluginImporter = AssetImporter.GetAtPath(filePath) as PluginImporter;

        if (!pluginImporter)
            Debug.LogWarningFormat("[TogglePluginEnabledOrDisabled] Aborting: Couldn't find plugin importer for File Path: {0}", filePath);
        pluginImporter.SetCompatibleWithPlatform(buildTarget, enableFile);
        Debug.LogFormat("[TogglePluginEnabledOrDisabled] Target State: {0}; Platform: {1}; File Path: {2}",
            enableFile, buildTarget, filePath);