Embeddinator-4000 icon indicating copy to clipboard operation
Embeddinator-4000 copied to clipboard

Exception thrown on clean project

Open gpaluk opened this issue 8 years ago • 15 comments

When following the instructions on: https://developer.xamarin.com/guides/cross-platform/dotnet-embedding/getting-started/java/android/

VS Code community 7.7.3 (build 5) macOS Siera 10.12.6

I get the following exception on a clean project:

Building Solution: EmbedTest (Debug)
Executing: rm -Rf '/Users/Shared/Jenkins/Projects/EmbedTest/output/'
Executing: mono '/Users/Shared/Jenkins/Projects/EmbedTest/packages/Embeddinator-4000.0.3.0/tools/Embeddinator-4000.exe' '/Users/Shared/Jenkins/Projects/EmbedTest/bin/Debug/EmbedTest.dll' --gen=Java --platform=Android --outdir='/Users/Shared/Jenkins/Projects/EmbedTest/output' -c
Parsing assemblies...
    MonoAndroidToolsPath path is not found and no default location is provided; skipping
    Parsed 'EmbedTest.dll'
Processing assemblies...
Generating binding code...
    Generated: EmbedTest.h
    Generated: EmbedTest.c
    Generated: Mono.Android.h
    Generated: Mono.Android.c
    Generated: Java.Interop.h
    Generated: Java.Interop.c
    Generated: mscorlib.h
    Generated: mscorlib.c
    Generated: .DS_Store
    Generated: c-support.c
    Generated: c-support.h
    Generated: embeddinator.h
    Generated: glib.c
    Generated: glib.h
    Generated: mono-support.c
    Generated: mono-support.h
    Generated: mono_embeddinator.c
    Generated: mono_embeddinator.h
Compiling binding code...

Unhandled Exception:
System.InvalidOperationException: Sequence contains no elements
  at System.Linq.Enumerable.Max (System.Collections.Generic.IEnumerable`1[T] source) [0x00022] in <3fb92ec709f44a579da6a23087df403d>:0 
  at Embeddinator.XamarinAndroid+<>c.<.cctor>b__4_1 () [0x00029] in <861966a3e3bd4f5cb470ae751f890033>:0 
  at System.Lazy`1[T].CreateValue () [0x00081] in <4fdc5ed61a074cafb49fa42deb20d521>:0 
  at System.Lazy`1[T].LazyInitValue () [0x00080] in <4fdc5ed61a074cafb49fa42deb20d521>:0 
  at System.Lazy`1[T].get_Value () [0x0003a] in <4fdc5ed61a074cafb49fa42deb20d521>:0 
  at Embeddinator.XamarinAndroid.get_ApiLevel () [0x00000] in <861966a3e3bd4f5cb470ae751f890033>:0 
  at Embeddinator.Driver.CompileNDK (System.Collections.Generic.IEnumerable`1[T] files) [0x00115] in <861966a3e3bd4f5cb470ae751f890033>:0 
  at Embeddinator.Driver.CompileNativeCode (System.Collections.Generic.IEnumerable`1[T] files) [0x000ba] in <861966a3e3bd4f5cb470ae751f890033>:0 
  at Embeddinator.Driver.CompileCode () [0x000a6] in <861966a3e3bd4f5cb470ae751f890033>:0 
  at Embeddinator.Driver.Run () [0x000a5] in <861966a3e3bd4f5cb470ae751f890033>:0 
  at Embeddinator.CLI.Main (System.String[] args) [0x00092] in <861966a3e3bd4f5cb470ae751f890033>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.InvalidOperationException: Sequence contains no elements
  at System.Linq.Enumerable.Max (System.Collections.Generic.IEnumerable`1[T] source) [0x00022] in <3fb92ec709f44a579da6a23087df403d>:0 
  at Embeddinator.XamarinAndroid+<>c.<.cctor>b__4_1 () [0x00029] in <861966a3e3bd4f5cb470ae751f890033>:0 
  at System.Lazy`1[T].CreateValue () [0x00081] in <4fdc5ed61a074cafb49fa42deb20d521>:0 
  at System.Lazy`1[T].LazyInitValue () [0x00080] in <4fdc5ed61a074cafb49fa42deb20d521>:0 
  at System.Lazy`1[T].get_Value () [0x0003a] in <4fdc5ed61a074cafb49fa42deb20d521>:0 
  at Embeddinator.XamarinAndroid.get_ApiLevel () [0x00000] in <861966a3e3bd4f5cb470ae751f890033>:0 
  at Embeddinator.Driver.CompileNDK (System.Collections.Generic.IEnumerable`1[T] files) [0x00115] in <861966a3e3bd4f5cb470ae751f890033>:0 
  at Embeddinator.Driver.CompileNativeCode (System.Collections.Generic.IEnumerable`1[T] files) [0x000ba] in <861966a3e3bd4f5cb470ae751f890033>:0 
  at Embeddinator.Driver.CompileCode () [0x000a6] in <861966a3e3bd4f5cb470ae751f890033>:0 
  at Embeddinator.Driver.Run () [0x000a5] in <861966a3e3bd4f5cb470ae751f890033>:0 
  at Embeddinator.CLI.Main (System.String[] args) [0x00092] in <861966a3e3bd4f5cb470ae751f890033>:0 

---------------------- Done ----------------------

Build successful.

gpaluk avatar Jan 29 '18 20:01 gpaluk

Hi @PluginIO,

Can you make sure you have the latest Embeddinator 0.4.0 on NuGet? This looks like an issue with version 0.3.0.

jonathanpeppers avatar Jan 30 '18 16:01 jonathanpeppers

@jonathanpeppers I don't even see any option for v0.4.0 - I'm using VS Code and nuget.org - It that correct??

[EDIT] Looking here https://www.nuget.org/packages/Embeddinator-4000/ - I don't see any reference to v0.4.0 either.

gpaluk avatar Jan 30 '18 20:01 gpaluk

Hey @PluginIO, due to some internal Nuget migration at MS I have not been to publish the 0.4.0 version yet to our usual package name. You need to get it from master meanwhile, while I get this sorted out.

tritao avatar Jan 30 '18 22:01 tritao

@tritao Thanks for the info. Could you let me know when this is available on NuGet and I will test it and see if it resolves the issue, until then it's a bit of a no go due to having users that I can't expect to go though those steps. Many thanks

gpaluk avatar Feb 01 '18 11:02 gpaluk

I was hitting the same issue as @PluginIO above, so I built E4K from current master (latest commit 88b1baa). I replaced the tools,support, and external folders in the packages/Embeddinator-4000.0.3.0 folder to test out the master build.

I hit a similar but slightly different stack trace with current master code (below) stating that the Android SDK is missing.

Note that I am able to build Xamarin Android in Visual Studio for Mac on this same system without issues.

MacOS Sierra 10.12.6 Visual Studio for Mac 7.4.1 (build 48)

Xamarin.Android Version: 8.2.0.16 (Visual Studio Community) Android SDK: /Users/kevin.howard/Library/Android/sdk Supported Android versions: 6.0 (API level 23) 7.0 (API level 24) 7.1 (API level 25) 8.1 (API level 27)

SDK Tools Version: 26.1.1 SDK Platform Tools Version: 27.0.1 SDK Build Tools Version: 27.0.3

Java SDK: /usr java version "1.8.0_162" Java(TM) SE Runtime Environment (build 1.8.0_162-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.162-b12, mixed mode)

Android Designer EPL code available here: https://github.com/xamarin/AndroidDesigner.EPL

Executing: mono '/Users/me/Desktop/git/embed-android/packages/Embeddinator-4000.0.3.0/tools/Embeddinator-4000.exe' '/Users/me/Desktop/git/embed-android/shared-csharp/bin/Debug/shared-csharp.dll' --gen=Java --platform=Android --outdir='/Users/me/Desktop/git/embed-android/output' -c -verbose
Parsing assemblies...
MonoAndroidToolsPath path is not found and no default location is provided; skipping

Unhandled Exception:
System.Exception: Cannot find Android SDK installed.
  at Embeddinator.XamarinAndroid.GetMonoDroidPath () [0x00034] in <8fc39d52a1424793824a01acdddfd4e7>:0 
  at System.Lazy`1[T].CreateValue () [0x00081] in <e22c1963d07746cd9708456620d50e1a>:0 
  at System.Lazy`1[T].LazyInitValue () [0x00080] in <e22c1963d07746cd9708456620d50e1a>:0 
  at System.Lazy`1[T].get_Value () [0x0003a] in <e22c1963d07746cd9708456620d50e1a>:0 
  at Embeddinator.XamarinAndroid.get_Path () [0x00000] in <8fc39d52a1424793824a01acdddfd4e7>:0 
  at Embeddinator.XamarinAndroid+<>c.<.cctor>b__32_1 () [0x00000] in <8fc39d52a1424793824a01acdddfd4e7>:0 
  at System.Lazy`1[T].CreateValue () [0x00081] in <e22c1963d07746cd9708456620d50e1a>:0 
  at System.Lazy`1[T].LazyInitValue () [0x00080] in <e22c1963d07746cd9708456620d50e1a>:0 
  at System.Lazy`1[T].get_Value () [0x0003a] in <e22c1963d07746cd9708456620d50e1a>:0 
  at Embeddinator.XamarinAndroid.get_TargetFrameworkDirectories () [0x00000] in <8fc39d52a1424793824a01acdddfd4e7>:0 
  at Embeddinator.Driver.Parse () [0x0007c] in <8fc39d52a1424793824a01acdddfd4e7>:0 
  at Embeddinator.Driver.Run () [0x00038] in <8fc39d52a1424793824a01acdddfd4e7>:0 
  at Embeddinator.CLI.Main (System.String[] args) [0x000a6] in <8fc39d52a1424793824a01acdddfd4e7>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.Exception: Cannot find Android SDK installed.
  at Embeddinator.XamarinAndroid.GetMonoDroidPath () [0x00034] in <8fc39d52a1424793824a01acdddfd4e7>:0 
  at System.Lazy`1[T].CreateValue () [0x00081] in <e22c1963d07746cd9708456620d50e1a>:0 
  at System.Lazy`1[T].LazyInitValue () [0x00080] in <e22c1963d07746cd9708456620d50e1a>:0 
  at System.Lazy`1[T].get_Value () [0x0003a] in <e22c1963d07746cd9708456620d50e1a>:0 
  at Embeddinator.XamarinAndroid.get_Path () [0x00000] in <8fc39d52a1424793824a01acdddfd4e7>:0 
  at Embeddinator.XamarinAndroid+<>c.<.cctor>b__32_1 () [0x00000] in <8fc39d52a1424793824a01acdddfd4e7>:0 
  at System.Lazy`1[T].CreateValue () [0x00081] in <e22c1963d07746cd9708456620d50e1a>:0 
  at System.Lazy`1[T].LazyInitValue () [0x00080] in <e22c1963d07746cd9708456620d50e1a>:0 
  at System.Lazy`1[T].get_Value () [0x0003a] in <e22c1963d07746cd9708456620d50e1a>:0 
  at Embeddinator.XamarinAndroid.get_TargetFrameworkDirectories () [0x00000] in <8fc39d52a1424793824a01acdddfd4e7>:0 
  at Embeddinator.Driver.Parse () [0x0007c] in <8fc39d52a1424793824a01acdddfd4e7>:0 
  at Embeddinator.Driver.Run () [0x00038] in <8fc39d52a1424793824a01acdddfd4e7>:0 
  at Embeddinator.CLI.Main (System.String[] args) [0x000a6] in <8fc39d52a1424793824a01acdddfd4e7>:0

kevinhowarddr avatar Mar 29 '18 14:03 kevinhowarddr

@tritao @jonathanpeppers I should add that I get the same issue as @PluginIO if I install Embeddinator 4K Nuget v0.2.0.80 as well as on Nuget v0.3.0

kevinhowarddr avatar Mar 29 '18 14:03 kevinhowarddr

We need to get latest master on NuGet, one of the things we are working on atm.

For now, can you try building from source with what is on master? You should be able to just run:

git submodule update --init --recursive
./build.sh

jonathanpeppers avatar Mar 29 '18 15:03 jonathanpeppers

Thanks, @jonathanpeppers. I was already using master, but I ran again using current master (latest commit 88b1baa)

I explicitly cleaned the solution and then ran

git submodule update --init --recursive
./build.sh

I then used the output binaries.

Unfortunately, I get the same exception and stack as above, with the System.Exception: Cannot find Android SDK installed. exception

kevinhowarddr avatar Mar 29 '18 15:03 kevinhowarddr

@kevinhowarddr where is your Android SDK installed?

Zomb avatar Mar 29 '18 15:03 Zomb

@Zomb @jonathanpeppers My Android SDK location is /Users/kevin.howard/Library/Android/sdk

kevinhowarddr avatar Mar 29 '18 15:03 kevinhowarddr

I am not sure about a Mac, but I have run into this issue before on windows before and tracked it down by looking at all the paths it searches for in https://github.com/xamarin/xamarin-android-tools/tree/master/src/Xamarin.Android.Tools.AndroidSdk/Sdks. I found that my SDK was not on any of the paths specified in those files.

Zomb avatar Mar 29 '18 16:03 Zomb

Thanks, @Zomb. I believe my path is the default path for Android SDK on Mac.

If I have time today, I'll hack in some hard coded paths in the Xamarin/Embeddinator code and see what happens, but I will probably not have desk time for it until next week.

kevinhowarddr avatar Mar 29 '18 16:03 kevinhowarddr

@kevinhowarddr the other part I see in your log:

MonoAndroidToolsPath path is not found and no default location is provided; skipping

Did the build script download xamarin-android to external/Xamarin.Android? It's the part that says "this might take a while".

You might also try ./build.sh -t Generate-Android, this runs Embeddinator on a test project.

jonathanpeppers avatar Mar 29 '18 16:03 jonathanpeppers

Thanks, @jonathanpeppers, for the quick response and pointers! Your suggestion yielded very interesting results.

I did not see a reference to xamarin-android when the ./build.sh script was run. Also, I noticed there was anexternal/Xamarin.Android.Tools but not an external/Xamarin.Android.

So, I ran your suggested ./build.sh -t Generate-Android command. The build script output then showed the "this might take a while" message and downloaded xamarin-android to external/Xamarin.Android. The build script succeeded, and, after this, there was also an Android folder added to build/libs/Release.

So I put the updated support, external, and tools binaries in the packages/Embeddinator-4000.0.3.0 folder and...success! The Android sample project now works and generated .jar and .aar files correctly!

So, based on these results, it seems likely that the default build in the Embeddinator VS solution and using ./build.sh is not pulling in xamarin-android correctly on Mac. The work around is to run ./build.sh -t Generate-Android against current master code.

Thanks again, @jonathanpeppers!

kevinhowarddr avatar Mar 29 '18 18:03 kevinhowarddr

Any update on this issue

lkhore avatar Sep 08 '21 05:09 lkhore