Closed weeeBox closed 4 years ago
We worked around this by having AndroidPlugin.SetEnabled
retry in case it's unable to create an importer, which fixes the issue.
public static void SetEnabled(bool enabled, bool retrying = false)
{
if (retrying)
{
EditorApplication.delayCall -= s_onRetry;
s_onRetry = null;
}
var androidPathAAR = FileUtils.FixAssetPath(EditorConstants.EditorPathAndroidAAR);
if (androidPathAAR == null || !FileUtils.AssetPathExists(androidPathAAR))
{
Debug.LogErrorFormat("Can't {0} Android plugin: missing required file '{1}'. Re-install {2} to fix the issue.",
enabled ? "enable" : "disable",
androidPathAAR,
Constants.PluginDisplayName);
return;
}
var importer = (PluginImporter)AssetImporter.GetAtPath(androidPathAAR);
if (importer == null)
{
// mleenhardt: Added delayed retry attempt to fix error caused by the fact that importer is
// null the very first time the project is loaded when there is no Library folder yet.
if (!retrying)
{
s_onRetry = () => SetEnabled(enabled, true);
EditorApplication.delayCall += s_onRetry;
return;
}
Debug.LogErrorFormat("Can't {0} Android plugin: unable to create importer for '{1}'. Re-install {2} to fix the issue.",
enabled ? "enable" : "disable",
androidPathAAR,
Constants.PluginDisplayName);
return;
}
if (importer.GetCompatibleWithPlatform(BuildTarget.Android) != enabled)
{
importer.SetCompatibleWithPlatform(BuildTarget.Android, enabled);
importer.SaveAndReimport();
}
}
@mleenhardt, I've incorporated your changes into 1.6.3
release. Feel free to open a pull request in the future.
Hello, I am having the same issue. AssetImporter.GetAtPath(androidPathAAR) returns null even with a valid path: Packages/com.companyname.client.lunarconsole/Plugins/LunarConsole/Editor/Android/lunar-console.aar. Is there any known issue with having Lunar Console under the packages folder. We want it there in order to reuse across different games.
Mostly occurs on fresh installations