Skip to content

Instantly share code, notes, and snippets.

Avatar

Jonathan Pryor jonpryor

View GitHub Profile
View ah.java
// array hash
class ah {
public static void main (String[] args) {
int[] a = new int []{1,2,3};
int[] b = new int []{1,2,3};
System.out.println ("a hash: " + a.hashCode());
System.out.println ("b hash: " + b.hashCode());
}
}
@jonpryor
jonpryor / MainActivity.cs
Created Apr 10, 2017
PCLStorage NuGet use
View MainActivity.cs
using System;
using Android.App;
using Android.Widget;
using Android.OS;
using System.Threading.Tasks;
using PCLStorage;
namespace FurkanErasian_PclStorage
View README.md

Android NDK, SDK

Note: A xamarin-android checkout maintains its own Android NDK + SDK to ensure consistent builds and build behavior, permitting reproducible builds and providing greater flexibility around when we need to perform Android SDK + NDK updates. The Android SDK and NDK are maintained by default via two directories in your home directory:

  • $(AndroidToolchainCacheDirectory): Where downloaded files are cached. Defaults to the $HOME/android-archives directory.
View README.md

Consider this scenario:

  1. You have expansion-deps.projitems which contains the @(JdkIncludePath) item group.
  2. You have expansion.props which uses @(JdkIncludePath) to generate a $(_JdkIncludePaths) property
  3. You have expansion.projitems which creates a new @(_HostRuntime) item group which uses $(JdkIncludePath) within the %(_HostRuntime.CFlags) item metadata
  4. You print out %(_HostRuntime.CFlags).

Incredibly, behavior differs between xbuild, msbuild in mono 4.6, and msbuild in mono 4.8.

View JNICrash.diff
diff -u MainActivity.cs.jonp-orig MainActivity.cs
--- MainActivity.cs.jonp-orig 2016-07-06 17:11:28.000000000 -0400
+++ MainActivity.cs 2016-08-01 14:45:49.000000000 -0400
@@ -3,7 +3,10 @@
using Android.OS;
using Android.Runtime;
+using Java.Interop;
+
using System;
View Binding Java Interfaces in Xamarin.md

Binding Java 8 Interfaces from C♯

Help wanted! :-)

Background

Xamarin.Android binds the Android Java API, which means that all Java language features need to be "bound" to corresponding C# language features. For many language constructs, this binding is simple, e.g. type names are (usually) unchanged and identical, while other language features are changed in subtle

View xamarin-android.diff
diff --git a/build-tools/mono-runtimes/mono-runtimes.projitems b/build-tools/mono-runtimes/mono-runtimes.projitems
index ae79165..89484f8 100644
--- a/build-tools/mono-runtimes/mono-runtimes.projitems
+++ b/build-tools/mono-runtimes/mono-runtimes.projitems
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
- <_MonoRuntime Include="armeabi" Condition="$(AndroidSupportedTargetJitAbis.Contains (':armeabi:'))">
+ <_MonoRuntime Include="armeabi" Condition="$(AndroidSupportedTargetJitAbisForConditionalChecks.Contains (':armeabi:'))">
View xamarin-android.diff
diff --git a/Configuration.props b/Configuration.props
index f71adb1..a71d4f3 100644
--- a/Configuration.props
+++ b/Configuration.props
@@ -11,6 +11,7 @@
<HostCc Condition=" '$(HostCc)' == '' ">cc</HostCc>
<HostCxx Condition=" '$(HostCxx)' == '' ">c++</HostCxx>
<ManagedRuntime Condition=" '$(ManagedRuntime)' == '' And '$(OS)' != 'Windows_NT' ">mono</ManagedRuntime>
+ <TargetFrameworkRootPath>$(MSBuildThisFileDirectory)bin\$(Configuration)\lib\xbuild-frameworks</TargetFrameworkRootPath>
<HOME Condition=" '$(HOME)' == '' ">$(HOMEDRIVE)$(HOMEPATH)</HOME>
View xamarin-android.diff
diff --git a/src/Mono.Posix/Mono.Posix.csproj b/src/Mono.Posix/Mono.Posix.csproj
index 8120cc2..5d3f73e 100644
--- a/src/Mono.Posix/Mono.Posix.csproj
+++ b/src/Mono.Posix/Mono.Posix.csproj
@@ -245,6 +245,11 @@
<Name>Mono.Android</Name>
<Private>False</Private>
</ProjectReference>
+ <ProjectReference Include="..\Xamarin.Android.Build.Tasks\Xamarin.Android.Build.Tasks.csproj">
+ <Project>{3F1F2F50-AF1A-4A5A-BEDB-193372F068D7}</Project>
View xamarin-android.diff
diff --git a/external/Java.Interop b/external/Java.Interop
--- a/external/Java.Interop
+++ b/external/Java.Interop
@@ -1 +1 @@
-Subproject commit b6431ac85042960ba28dfb19f0be19573745d968
+Subproject commit b6431ac85042960ba28dfb19f0be19573745d968-dirty
diff --git a/src/Mono.Android/Mono.Android.targets b/src/Mono.Android/Mono.Android.targets
index 09878c4..0f357b0 100644
--- a/src/Mono.Android/Mono.Android.targets
+++ b/src/Mono.Android/Mono.Android.targets
You can’t perform that action at this time.