mono / Embeddinator-4000

Tools to turn .NET libraries into native libraries that can be consumed on Android, iOS, Mac, Linux and other platforms.
MIT License
758 stars 95 forks source link

Embeddinator runs without errors, still no aar file #767

Open MarcK95 opened 4 years ago

MarcK95 commented 4 years ago

Steps to Reproduce

I created a test project like its described here https://docs.microsoft.com/en-us/xamarin/tools/dotnet-embedding/get-started/java/android

I installed Embeddinator as nuget

I tried all methods of building an aar file like its described here https://docs.microsoft.com/en-us/xamarin/tools/dotnet-embedding/get-started/install/install

I get no positive result in any of these possibilities

Expected Behavior

Should generate aar file inside output folder

Actual Behavior

generates a bunch of files but no aar

Environment

Win10 64bit, VS19 (16.4.6)

Logs

WHEN USING COMMAND LINE WITHOUT -c Embeddinator-4000.exe -gen=Java --platform=Android -out=Foo bin\Debug\hello-from-csharp.dll -v

Pass 'Embeddinator.Passes.CheckDeclarations'
    Found forbidden property name: Java_Lang_Object_Class
Pass 'CppSharp.Passes.CaseRenamePass'
Pass 'Embeddinator.Passes.InterfacesPass'
Pass 'Embeddinator.Passes.CheckReservedKeywords'

Generating binding code... Generated: hello_from_csharp\hellofromcsharp\Class1.java Generated: hello_from_csharp\hellofromcsharp\Resource.java Generated: hello_from_csharp\hellofromcsharp\Animation.java Generated: hello_from_csharp\hellofromcsharp\Attribute.java Generated: hello_from_csharp\hellofromcsharp\Boolean.java Generated: hello_from_csharp\hellofromcsharp\Color.java Generated: hello_from_csharp\hellofromcsharp\Dimension.java Generated: hello_from_csharp\hellofromcsharp\Drawable.java Generated: hello_from_csharp\hellofromcsharp\Id.java Generated: hello_from_csharp\hellofromcsharp\Integer.java Generated: hello_from_csharp\hellofromcsharp\Layout.java Generated: hello_from_csharp\hellofromcsharp\String.java Generated: hello_from_csharp\hellofromcsharp\Style.java Generated: hello_from_csharp\hellofromcsharp\Styleable.java Generated: hello_from_csharp\Native_hello_from_csharp.java Generated: mscorlib\system\IDisposableImpl.java Generated: mscorlib\system\IDisposable.java Generated: mscorlib\Native_mscorlib.java Generating Java stubs... Key HKCU\SOFTWARE\Novell\Mono for Android\AndroidSdkDirectory found: Path contains adb in \platform-tools (C:\Program Files (x86)\Android\android-sdk). Key HKCU\SOFTWARE\Novell\Mono for Android\AndroidNdkDirectory found: Path contains ndk-stack in . (C:\Users\UserName\AppData\Local\Android\Sdk\ndk-bundle). Key HKCU\SOFTWARE\Novell\Mono for Android\JavaSdkDirectory found: Path contains jarsigner.exe in \bin (C:\Program Files\Java\jdk-14). Invoking: C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /nologo /verbosity:minimal C:\Users\UserName\Documents\projects\hello\hello-from-csharp\hello-from-csharp\Foo\GenerateJavaStubs.proj

This runs without errors, but there is still no aar file generated in the output folder

WHEN USING COMMAND LINE WITH -c Embeddinator-4000.exe -gen=Java --platform=Android -out=Foo bin\Debug\hello-from-csharp.dll -v -c

Pass 'Embeddinator.Passes.CheckDeclarations'
Pass 'Embeddinator.Passes.FixMethodParametersPass'
Pass 'Embeddinator.Passes.CheckReservedKeywords'

Generating binding code... Generated: hello-from-csharp.h Generated: hello-from-csharp.c Generated: Mono.Android.h Generated: Mono.Android.c Generated: Java.Interop.h Generated: Java.Interop.c Generated: mscorlib.h Generated: mscorlib.c 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... Key HKCU\SOFTWARE\Novell\Mono for Android\AndroidSdkDirectory found: Path contains adb in \platform-tools (C:\Program Files (x86)\Android\android-sdk). Key HKCU\SOFTWARE\Novell\Mono for Android\AndroidNdkDirectory found: Path contains ndk-stack in . (C:\Users\UserName\AppData\Local\Android\Sdk\ndk-bundle). Key HKCU\SOFTWARE\Novell\Mono for Android\JavaSdkDirectory found: Path contains jarsigner.exe in \bin (C:\Program Files\Java\jdk-14).

Unhandled Exception: System.Exception: Unable to find NDK toolchain for Arm! at Xamarin.Android.Tasks.NdkUtil.GetNdkClangBin(String toolchainsPath, AndroidTargetArch arch) at Embeddinator.Driver.CompileNDK(IEnumerable1 files) at Embeddinator.Driver.CompileNativeCode(IEnumerable1 files) at Embeddinator.Driver.CompileCode() at Embeddinator.Driver.Run() at Embeddinator.CLI.Main(String[] args)

WHEN USING MSBUILD TARGETS

The command "set K_OUTPUT='C:\Users\UserName\Documents\projects\hello\hello-from-csharp\output' if exist K_OUTPUT% rmdir /S /Q K_OUTPUT% 'C:\Users\UserName\Documents\projects\hello\hello-from-csharp\packages\Embeddinator-4000.0.2.0.80\tools\Embeddinator-4000.exe' 'C:\Users\UserName\Documents\projects\hello\hello-from-csharp\hello-from-csharp\bin\Debug\hello-from-csharp.dll' --gen=Java --platform=Android --outdir=K_OUTPUT% -c" exited with code 123

WHEN USING POST-BUILD STEPS

The command "set E4K_OUTPUT="C:\Users\UserName\Documents\projects\hello\hello-from-csharp\output" if exist %E4K_OUTPUT% rmdir /S /Q %E4K_OUTPUT% "C:\Users\UserName.nuget\packages\Embeddinator-4000\0.4.0\tools\Embeddinator-4000.exe" "C:\Users\UserName\Documents\projects\hello\hello-from-csharp\hello-from-csharp\bin\Debug\hello-from-csharp.dll" --gen=Java --platform=Android --outdir=%E4K_OUTPUT% -c" exited with code -532462766

lindexi commented 4 years ago

Could you run C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /nologo C:\Users\UserName\Documents\projects\hello\hello-from-csharp\hello-from-csharp\Foo\GenerateJavaStubs.proj

Remove the /verbosity:minimal code from msbuild command.

lindexi commented 4 years ago

https://github.com/jamesmontemagno/embeddinator-hellosharedui/issues/3

MarcK95 commented 4 years ago

I ran the command you mentioned with the following result:

Build` started 09.04.2020 09:02:40.
Project "C:\Users\UserName\Documents\projects\hello\hello-from-csharp\hello-from-csharp\Foo\GenerateJavaStubs.proj" on node 1 (default targets).
Build:
  Copying file from "C:\Users\UserName\Documents\projects\hello\hello-from-csharp\hello-from-csharp\Foo\obj\lp\hello-from-csharp\jl\res\layout\hello.xml" to "C:\Users\UserName\Documents\projec
  ts\hello\hello-from-csharp\hello-from-csharp\Foo\android\res\layout\hello.xml".
  Copying file from "C:\Users\UserName\Documents\projects\hello\hello-from-csharp\hello-from-csharp\Foo\obj\lp\hello-from-csharp\jl\res\values\strings.xml" to "C:\Users\UserName\Documents\proj
  ects\hello\hello-from-csharp\hello-from-csharp\Foo\android\res\values\strings.xml".
  Made 1 replacement(s).
  Made 2 replacement(s).
  Made 2 replacement(s).
Done Building Project "C:\Users\UserName\Documents\projects\hello\hello-from-csharp\hello-from-csharp\Foo\GenerateJavaStubs.proj" (default targets).

Build succeeded.
    0 Warning(s)
    0 Error(s)

I didn't get what you mean with this:

yes, remove the /verbosity:minimal code

lindexi commented 4 years ago

@MarcKammermann I find the old issus : https://github.com/jamesmontemagno/embeddinator-hellosharedui/issues/3

And the msbuild output is without any error but still no arr file. This is a confusing question

andrejs-mamontovs commented 4 years ago

I ran the command you mentioned with the following result:

Build` started 09.04.2020 09:02:40.
Project "C:\Users\UserName\Documents\projects\hello\hello-from-csharp\hello-from-csharp\Foo\GenerateJavaStubs.proj" on node 1 (default targets).
Build:
  Copying file from "C:\Users\UserName\Documents\projects\hello\hello-from-csharp\hello-from-csharp\Foo\obj\lp\hello-from-csharp\jl\res\layout\hello.xml" to "C:\Users\UserName\Documents\projec
  ts\hello\hello-from-csharp\hello-from-csharp\Foo\android\res\layout\hello.xml".
  Copying file from "C:\Users\UserName\Documents\projects\hello\hello-from-csharp\hello-from-csharp\Foo\obj\lp\hello-from-csharp\jl\res\values\strings.xml" to "C:\Users\UserName\Documents\proj
  ects\hello\hello-from-csharp\hello-from-csharp\Foo\android\res\values\strings.xml".
  Made 1 replacement(s).
  Made 2 replacement(s).
  Made 2 replacement(s).
Done Building Project "C:\Users\UserName\Documents\projects\hello\hello-from-csharp\hello-from-csharp\Foo\GenerateJavaStubs.proj" (default targets).

Build succeeded.
    0 Warning(s)
    0 Error(s)

I didn't get what you mean with this:

yes, remove the /verbosity:minimal code

Same problem

robinwit commented 4 years ago

Same here… Is this project still actively being maintainted? 👀

Raykud commented 4 years ago

Same here… Is this project still actively being maintainted? 👀

I doubt it. You just have to check the commits and see that its so long since they made a fix and not to count the documentation is as old as 3 years at least (referencing VS2017) not to count the 100+ issues without resolving.

Harishez commented 3 years ago

Downgrading NDK to v14 helped in overcoming this. The project isn't updated for the latest NDKs

Harishez commented 3 years ago

@lindexi Faced this error? Any help appreciated!

Unhandled Exception: System.ComponentModel.Win32Exception: The system cannot fin d the file specified at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startIn fo) at System.Diagnostics.Process.Start() at Embeddinator.Helpers.Invoke(String program, String arguments, Dictionary2 envVars) at Embeddinator.Driver.CompileJava(IEnumerable1 files) at Embeddinator.Driver.CompileCode() at Embeddinator.Driver.Run() at Embeddinator.CLI.Main(String[] args)

lindexi commented 3 years ago

@Harishez I do not know which file not found.

Harishez commented 3 years ago

@lindexi It doesn't point to any file. I get this after the following in log

Compiling binding code...

Full Log:

Generating Java stubs...
Invoking: C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /nologo /verbosity:minimal C:\Users\HarishZ\Documents\gofrugal\print_poc\Gofrugal.POS.Ex portRuntime\Gofrugal.POS.ExportRuntime\obj\Debug\foo\GenerateJavaStubs.proj
Compiling binding code...
Unhandled Exception: System.ComponentModel.Win32Exception: The system cannot fin d the file specified at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startIn fo) at System.Diagnostics.Process.Start()
at Embeddinator.Helpers.Invoke(String program, String arguments, Dictionary2 envVars) at Embeddinator.Driver.CompileJava(IEnumerable1 files)
at Embeddinator.Driver.CompileCode()
at Embeddinator.Driver.Run()
at Embeddinator.CLI.Main(String[] args)

And then the exception I had shared being thrown

seacco commented 3 years ago

Downgrading NDK to v14 helped in overcoming this. The project isn't updated for the latest NDKs

did you change anything else? I am facing the same issue and downgrading to NDK v14 alone does not resolve it.