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

gen=Java p=Android fails with FileNotFoundException: Unable to find assembly! #602

Closed knocte closed 6 years ago

knocte commented 6 years ago

Steps to reproduce:

  1. Compile Embedinator in Windows.
  2. Clone https://github.com/knocte/gwallet master branch, compile it on Release mode.
  3. Copy all files from gwallet/src/GWallet.Backend/bin/Release/ into Embedinator/build/lib/Debug/
  4. cd into Embedinator/build/lib/Debug
  5. run Embeddinator-4000.exe -gen=Java -p=Android -out=gwallet GWallet.Backend.dll

Expected results: should not crash Current results: crashes, log below:

Parsing assemblies...
    Parsed 'GWallet.Backend.dll'
Processing assemblies...
Generating binding code...
    Generated: GWallet.Backend.h
    Generated: GWallet.Backend.c
    Generated: mscorlib.h
    Generated: mscorlib.c
    Generated: NBitcoin.h
    Generated: NBitcoin.c
    Generated: Newtonsoft.Json.h
    Generated: Newtonsoft.Json.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
Parsing assemblies...
    Parsed 'GWallet.Backend.dll'
    Parsed 'GWallet.Backend.dll'
Processing assemblies...
Generating binding code...
    Generated: mscorlib\system\collections\IStructuralEquatableImpl.java
    Generated: mscorlib\system\IComparableImpl.java
    Generated: mscorlib\system\collections\IStructuralComparableImpl.java
    Generated: gwallet_backend\gwallet\backend\IAccountImpl.java
    Generated: gwallet_backend\gwallet\backend\IBlockchainFeeInfoImpl.java
    Generated: mscorlib\system\IDisposableImpl.java
    Generated: newtonsoft_json\newtonsoft\json\JsonConverterImpl.java
    Generated: nbitcoin\nbitcoin\IRandomImpl.java
    Generated: gwallet_backend\gwallet\backend\DeserializationException.java
    Generated: gwallet_backend\gwallet\backend\VersionMismatchDuringDeserializationException.java
    Generated: gwallet_backend\gwallet\backend\DeserializableValueInfo.java
    Generated: gwallet_backend\gwallet\backend\Currency.java
    Generated: gwallet_backend\gwallet\backend\Tags.java
    Generated: gwallet_backend\gwallet\backend\InsufficientFunds.java
    Generated: gwallet_backend\gwallet\backend\InvalidPassword.java
    Generated: gwallet_backend\gwallet\backend\DestinationEqualToOrigin.java
    Generated: gwallet_backend\gwallet\backend\AddressMissingProperPrefix.java
    Generated: gwallet_backend\gwallet\backend\AddressWithInvalidLength.java
    Generated: gwallet_backend\gwallet\backend\AddressWithInvalidChecksum.java
    Generated: gwallet_backend\gwallet\backend\AccountAlreadyAdded.java
    Generated: gwallet_backend\gwallet\backend\IAccount.java
    Generated: gwallet_backend\gwallet\backend\NormalAccount.java
    Generated: gwallet_backend\gwallet\backend\ReadOnlyAccount.java
    Generated: gwallet_backend\gwallet\backend\ArchivedAccount.java
    Generated: gwallet_backend\gwallet\backend\IBlockchainFeeInfo.java
    Generated: gwallet_backend\gwallet\backend\TransferAmount.java
    Generated: gwallet_backend\gwallet\backend\CachedNetworkData.java
    Generated: gwallet_backend\gwallet\backend\UnsignedTransactionProposal.java
    Generated: gwallet_backend\gwallet\backend\NoneAvailableException.java
    Generated: gwallet_backend\gwallet\backend\ResultInconsistencyException.java
    Generated: gwallet_backend\gwallet\backend\bitcoin\Request.java
    Generated: gwallet_backend\gwallet\backend\bitcoin\ServerVersionResult.java
    Generated: gwallet_backend\gwallet\backend\bitcoin\BlockchainAddressGetBalanceInnerResult.java
    Generated: gwallet_backend\gwallet\backend\bitcoin\BlockchainAddressGetBalanceResult.java
    Generated: gwallet_backend\gwallet\backend\bitcoin\BlockchainAddressListUnspentInnerResult.java
    Generated: gwallet_backend\gwallet\backend\bitcoin\BlockchainAddressListUnspentResult.java
    Generated: gwallet_backend\gwallet\backend\bitcoin\BlockchainTransactionGetResult.java
    Generated: gwallet_backend\gwallet\backend\bitcoin\BlockchainEstimateFeeResult.java
    Generated: gwallet_backend\gwallet\backend\bitcoin\BlockchainTransactionBroadcastResult.java
    Generated: gwallet_backend\gwallet\backend\bitcoin\ErrorInnerResult.java
    Generated: gwallet_backend\gwallet\backend\bitcoin\ErrorResult.java
    Generated: gwallet_backend\gwallet\backend\bitcoin\ElectrumServerReturningInternalErrorInJsonResponseException.java
    Generated: gwallet_backend\gwallet\backend\bitcoin\StratumClient.java
    Generated: gwallet_backend\gwallet\backend\bitcoin\ServerTooOld.java
    Generated: gwallet_backend\gwallet\backend\bitcoin\MinerFee.java
    Generated: gwallet_backend\gwallet\backend\bitcoin\OutputInfo.java
    Generated: gwallet_backend\gwallet\backend\bitcoin\RawTransactionOutpoint.java
    Generated: gwallet_backend\gwallet\backend\bitcoin\TransactionDraft.java
    Generated: gwallet_backend\gwallet\backend\bitcoin\TransactionMetadata.java
    Generated: gwallet_backend\gwallet\backend\bitcoin\BouncyCastleSecureRandomWrapperForNBitcoin.java
    Generated: gwallet_backend\gwallet\backend\bitcoin\UnitConversion.java
    Generated: gwallet_backend\gwallet\backend\Client.java
    Generated: gwallet_backend\gwallet\backend\ether\MinerFee.java
    Generated: gwallet_backend\gwallet\backend\ether\TransactionMetadata.java
    Generated: gwallet_backend\gwallet\backend\ether\Server.java
    Generated: gwallet_backend\gwallet\backend\ether\ConnectionUnsuccessfulException.java
    Generated: gwallet_backend\gwallet\backend\ether\ServerTimedOutException.java
    Generated: gwallet_backend\gwallet\backend\ether\ServerCannotBeResolvedException.java
    Generated: gwallet_backend\gwallet\backend\Infrastructure.java
    Generated: gwallet_backend\gwallet\backend\FiatValueEstimation.java
    Generated: gwallet_backend\gwallet\backend\Account.java
    Generated: gwallet_backend\gwallet\backend\Caching.java
    Generated: gwallet_backend\gwallet\backend\JsonRpcSharp.java
    Generated: gwallet_backend\gwallet\backend\ConnectionUnsuccessfulException.java
    Generated: gwallet_backend\gwallet\backend\NoResponseReceivedAfterRequestException.java
    Generated: gwallet_backend\gwallet\backend\TlsNotSupportedYetInGWalletException.java
    Generated: gwallet_backend\gwallet\backend\ServerRefusedException.java
    Generated: gwallet_backend\gwallet\backend\ServerTimedOutException.java
    Generated: gwallet_backend\gwallet\backend\ServerCannotBeResolvedException.java
    Generated: gwallet_backend\gwallet\backend\ServerUnresponsiveException.java
    Generated: gwallet_backend\gwallet\backend\ServerUnreachableException.java
    Generated: gwallet_backend\gwallet\backend\Marshalling.java
    Generated: gwallet_backend\gwallet\backend\Shuffler.java
    Generated: gwallet_backend\gwallet\backend\FSharpUtil.java
    Generated: gwallet_backend\gwallet\backend\OptionConverter.java
    Generated: gwallet_backend\gwallet\backend\CustomIdiomaticDuConverter.java
    Generated: gwallet_backend\gwallet\backend\IdiomaticDuConverter.java
    Generated: gwallet_backend\Native_GWallet_Backend.java
    Generated: mscorlib\system\runtime\serialization\ISerializableImpl.java
    Generated: mscorlib\system\runtime\interopservices\_ExceptionImpl.java
    Generated: mscorlib\system\Exception.java
    Generated: mscorlib\system\runtime\serialization\ISerializable.java
    Generated: mscorlib\system\runtime\interopservices\_Exception.java
    Generated: mscorlib\system\collections\IStructuralEquatable.java
    Generated: mscorlib\system\collections\IStructuralComparable.java
    Generated: mscorlib\system\IComparable.java
    Generated: mscorlib\system\IDisposable.java
    Generated: mscorlib\Native_mscorlib.java
    Generated: nbitcoin\nbitcoin\IRandom.java
    Generated: nbitcoin\Native_NBitcoin.java
    Generated: newtonsoft_json\newtonsoft\json\JsonConverter.java
    Generated: newtonsoft_json\Native_Newtonsoft_Json.java
    Generating Java stubs...

Unhandled Exception: System.IO.FileNotFoundException: Unable to find assembly!
   at Embeddinator.XamarinAndroid.FindAssembly(String assemblyName) in C:\Users\DigitasAdmin\Documents\Embeddinator-4000\binder\Utils\XamarinAndroid.cs:line 97
   at Embeddinator.XamarinAndroidBuild.ResolveAssemblies(ProjectTargetElement target, List`1 assemblies) in C:\Users\DigitasAdmin\Documents\Embeddinator-4000\binder\Utils\XamarinAndroidBuild.cs:line 48
   at Embeddinator.XamarinAndroidBuild.GenerateJavaStubsProject(List`1 assemblies, String outputDirectory) in C:\Users\DigitasAdmin\Documents\Embeddinator-4000\binder\Utils\XamarinAndroidBuild.cs:line 184
   at Embeddinator.Driver.WriteFiles() in C:\Users\DigitasAdmin\Documents\Embeddinator-4000\binder\Driver.cs:line 200
   at Embeddinator.Driver.Run() in C:\Users\DigitasAdmin\Documents\Embeddinator-4000\binder\Driver.cs:line 245
   at Embeddinator.CLI.Main(String[] args) in C:\Users\DigitasAdmin\Documents\Embeddinator-4000\binder\CLI.cs:line 220
jonathanpeppers commented 6 years ago

This looks like Embeddinator is not able to find the downloaded copy of Xamarin.Android:

Getting Embeddinator to work with your system's Xamarin.Android is on our TODO list.

knocte commented 6 years ago

Did you run .\build.ps1 -t Download-Xamarin-Android or Generate-Android

I didn't. This was not in the README file so I didn't know I needed to do this. After doing this, it works. However, what if I had run this in Mac? ps1 doesn't run on Mac AFAIU?

jonathanpeppers commented 6 years ago

It's mentioned here, on the contributing docs: https://github.com/mono/Embeddinator-4000/blob/master/docs/Contributing.md#cake

The plan was to start using the system Xamarin.Android at some point, but we haven't gotten around to doing that yet.

We are using Cake to build Embeddinator. It works by having a bootstrapper script for Windows (or Linux/macOS). There is a powershell script and a bash script that do the same thing.

knocte commented 6 years ago

Ok cool. Still, throwing an exception is a bit scary, shouldn't this situation be detected properly and just return an error message that suggests a wrong setup?

jonathanpeppers commented 6 years ago

@knocte it sounds like you got this issue figured out by using the Cake task.

Feel free to open a new issue, or reopen if you need something else.