Skip to content

Commit 6ca37d2

Browse files
atsushienojonpryor
authored andcommitted
[Xamarin.Android.Build.Tasks ] Fix MonoDroidSDK discovery. (#59)
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 8174af8 commit 6ca37d2

5 files changed

Lines changed: 11 additions & 6 deletions

File tree

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: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ protected override string FindRuntime ()
3434

3535
// check also in the users folder
3636
var personal = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
37-
var additionalSearchPaths = new [] { Path.Combine (personal, @".xamarin.android/lib/mandroid") };
37+
var additionalSearchPaths = new [] {
38+
// for Mono.Posix and Mono.Data.Sqlite builds in xamarin-android.
39+
monoAndroidPath = Path.GetFullPath (Path.Combine (new Uri (GetType ().Assembly.CodeBase).LocalPath, "..", "..", "..", "..", "..", "lib", "mandroid")),
40+
Path.Combine (personal, @".xamarin.android/lib/mandroid")
41+
};
3842

3943
return additionalSearchPaths.Concat (SearchPaths).FirstOrDefault (ValidateRuntime);
4044
}

0 commit comments

Comments
 (0)