Skip to content

Commit 8db5456

Browse files
committed
Fix part of Mono.Posix build issue regarding MonoDroidSDK discovery.
We can build xamarin-android on Linux only because we somehow had a working monodroid setup with MONO_ANDROID_PATH. Hence, fresh build hits: bin/Debug/lib/xbuild/Xamarin/Android/Xamarin.Android.Common.targets: error : Error executing task ResolveSdks: Value cannot be null. Now that Mono.Posix and some other libs depends on existing SDK, MonoDroidSdkUnix needs to also deal with bootstrap build. So far, the SDK sanity check uses generator.exe which does not exist when we are building Mono.Posix, so use class-parse.exe which exists instead. Also we only build 6.0 and UseLatestSDK somehow tries to find 6.0.99 and fails, so use 6.0 instead.
1 parent 742e031 commit 8db5456

File tree

5 files changed

+9
-5
lines changed

5 files changed

+9
-5
lines changed

src/Mono.Posix/Mono.Posix.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@
1111
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
1212
<AndroidResgenClass>Resource</AndroidResgenClass>
1313
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
14-
<AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk>
1514
<AssemblyName>Mono.Posix</AssemblyName>
16-
<TargetFrameworkVersion>v5.0</TargetFrameworkVersion>
15+
<TargetFrameworkVersion>v6.0</TargetFrameworkVersion>
1716
</PropertyGroup>
1817
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1918
<DebugSymbols>true</DebugSymbols>

src/Xamarin.Android.Build.Tasks/Tasks/ResolveSdksTask.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ public override bool Execute ()
113113
Log.LogDebugMessage (" TargetFrameworkVersion: {0}", TargetFrameworkVersion);
114114
Log.LogDebugMessage (" UseLatestAndroidPlatformSdk: {0}", UseLatestAndroidPlatformSdk);
115115
Log.LogDebugMessage (" SequencePointsMode: {0}", SequencePointsMode);
116+
Log.LogDebugMessage (" MonoAndroidToolsPath: {0}", MonoAndroidToolsPath);
117+
Log.LogDebugMessage (" MonoAndroidBinPath: {0}", MonoAndroidBinPath);
116118

117119
MonoAndroidHelper.InitializeAndroidLogger (Log);
118120

src/Xamarin.Android.Build.Tasks/Utilities/MonoAndroidHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public static void RefreshAndroidSdk (string sdkPath, string ndkPath, string jav
5858
public static void RefreshMonoDroidSdk (string toolsPath, string binPath, string[] referenceAssemblyPaths)
5959
{
6060
MonoDroidSdk.Refresh (toolsPath, binPath,
61-
(from refPath in referenceAssemblyPaths
61+
(from refPath in referenceAssemblyPaths ?? new string [0]
6262
where !string.IsNullOrEmpty (refPath)
6363
let path = refPath.TrimEnd (Path.DirectorySeparatorChar)
6464
where File.Exists (Path.Combine (path, "mscorlib.dll"))

src/Xamarin.Android.Build.Utilities/Sdks/MonoDroidSdkBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Xamarin.Android.Build.Utilities
99
abstract class MonoDroidSdkBase
1010
{
1111
protected readonly static string DebugRuntime = "Mono.Android.DebugRuntime-debug.apk";
12-
protected readonly static string GeneratorExe = "generator.exe";
12+
protected readonly static string ClassParseExe = "class-parse.exe";
1313
protected readonly static string GeneratorScript = "generator";
1414

1515
// I can never remember the difference between SdkPath and anything else...
@@ -107,7 +107,7 @@ protected static bool ValidateRuntime (string loc)
107107
{
108108
return !string.IsNullOrWhiteSpace (loc) &&
109109
(File.Exists (Path.Combine (loc, DebugRuntime)) || // Normal/expected
110-
File.Exists (Path.Combine (loc, GeneratorExe)) || // Normal/expected
110+
File.Exists (Path.Combine (loc, ClassParseExe)) || // Normal/expected
111111
File.Exists (Path.Combine (loc, "Ionic.Zip.dll"))); // Wrench builds
112112
}
113113

src/Xamarin.Android.Build.Utilities/Sdks/MonoDroidSdkUnix.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ class MonoDroidSdkUnix : MonoDroidSdkBase
2222
protected override string FindRuntime ()
2323
{
2424
string monoAndroidPath = Environment.GetEnvironmentVariable ("MONO_ANDROID_PATH");
25+
if (monoAndroidPath == null)
26+
// for Mono.Posix and Mono.Data.Sqlite builds in xamarin-android.
27+
monoAndroidPath = Path.GetFullPath (Path.Combine (new Uri (GetType ().Assembly.CodeBase).LocalPath, "..", "..", "..", "..", ".."));
2528
if (!string.IsNullOrEmpty (monoAndroidPath)) {
2629
string libMandroid = Path.Combine (monoAndroidPath, "lib", "mandroid");
2730
if (Directory.Exists (libMandroid)) {

0 commit comments

Comments
 (0)