Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If a dll is not included or configured correctly for the architecture, please indicate dll name in error trace #18

Open
RubenGarcia opened this issue Sep 15, 2023 · 13 comments

Comments

@RubenGarcia
Copy link
Contributor

RubenGarcia commented Sep 15, 2023

Currently the error is indicated as

DllNotFoundException: 
Cysharp.Net.Http.YetAnotherHttpHandler.Native assembly:<unknown assembly> type <unknown type> member:(null)
DebugException="System.DllNotFoundException:
Cysharp.Net.Http.YetAnotherHttpHandler.Native assembly:<unknown assembly> type <unknown type> member:(null)"

Please amend to indicate the name of the missing dll.

Platform: Android.

@YasiWonb
Copy link

Hi, I have just encountered similar issue while trying to run my example code on Android.

I can see that armv7 is not confirmed as working, it's may be the root cause.

Logcat output

2023/09/15 17:12:20.039 2207 2241 Error Unity DllNotFoundException: Cysharp.Net.Http.YetAnotherHttpHandler.Native assembly:<unknown assembly> type:<unknown type> member:(null)
2023/09/15 17:12:20.039 2207 2241 Error Unity   at (wrapper managed-to-native) Cysharp.Net.Http.NativeMethods.yaha_init_runtime(Cysharp.Net.Http.NativeMethods/yaha_init_runtime_on_status_code_and_headers_receive_delegate,Cysharp.Net.Http.NativeMethods/yaha_init_runtime_on_receive_delegate,Cysharp.Net.Http.NativeMethods/yaha_init_runtime_on_complete_delegate)
2023/09/15 17:12:20.039 2207 2241 Error Unity   at Cysharp.Net.Http.NativeLibraryWrapper..ctor (Cysharp.Net.Http.NativeClientSettings settings) [0x00028] in .\Library\PackageCache\com.cysharp.yetanotherhttphandler@bd2c526021\NativeLibraryWrapper.cs:38 
2023/09/15 17:12:20.039 2207 2241 Error Unity   at Cysharp.Net.Http.NativeHttpHandlerCore..ctor (Cysharp.Net.Http.NativeClientSettings settings) [0x00008] in .\Library\PackageCache\com.cysharp.yetanotherhttphandler@bd2c526021\YetAnotherHttpHandler.cs:215 
2023/09/15 17:12:20.039 2207 2241 Error Unity   at Cysharp.Net.Http.YetAnotherHttpHandler.SetupHandler () [0x0000d] in .\Library\PackageCache\com.cysharp.yetanotherhttphandler@bd2c526021\YetAnotherHttpHandle

@YasiWonb
Copy link

Hello @RubenGarcia,
Have you found how to solve DllNotFoundException on Android platform ? Thx

@RubenGarcia
Copy link
Contributor Author

RubenGarcia commented Sep 20, 2023

Not yet.
I should solve
#22
beforehand.

@RubenGarcia
Copy link
Contributor Author

RubenGarcia commented Sep 21, 2023

Ok, I got it to work.

First, clone https://github.com/Cysharp/YetAnotherHttpHandler
Install rust and

rustup target add aarch64-linux-android
rustup target install armv7-linux-androideabi
cargo install cargo-ndk
cargo ndk -t arm64-v8a build
cargo ndk build

Then copy the cs files from YetAnotherHttpHandler\src\YetAnotherHttpHandler and YetAnotherHttpHandler\src\YetAnotherHttpHandler\Shims into a folder in your assets.
Then create a directory yaha in Assets/Plugins, and two directories armv7 and arm64 inside.
copy native/target/*/debug/*.so inside these directories, each in their target architecture.
Select each of them and ensure platform is android, cpu is the correct one for each of them, and load on startup is selected.
Edit NativeMethodsFuncPtr.g.cs and NativeMethods.g.cs and change the

#else 
    const string __DllName = "...";
#endif

to

#else
        const string __DllName = "libyaha_native.so";
#endif

Then enable allowUnsafeCode in Player Settings.
Then click on "Build and run".

@YasiWonb
Copy link

Well done !

I am stuck at cargo ndk -t arm64-v8a build step.

But it seems that general Android support is on the way (commits about android build :
3944918 => armv7
fc3c2ad => android-x64

I guess I will wait for v0.2 release

@RubenGarcia
Copy link
Contributor Author

You need to run the cargo ndk lines from
YetAnotherHttpHandler/native
directory.
Also, add --release to the cargo ndk lines to get optimized libraries.

@YasiWonb
Copy link

YasiWonb commented Sep 22, 2023

Yes, I have seen first command cd native in other topic , but I obtain :

  • a warning "warning: some crates are on edition 2021 which defaults to resolver = "2", but virtual workspaces default to resolver = "1""

  • an error "error: failed to run custom build command for ring v0.16.20" due to a "file not found" in command "C:\Program" "Files\Unity\Hub\Editor\2022.3.6f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin\clang"

I cannot figure out which file is spoken about : I can see
YetAnotherHttpHandler\native\target\aarch64-linux-android\debug\build\ring-ffea147bf53e7271\out\aesv8-armx-linux64.o
and
.cargo\registry\src\index.crates.io-6f17d22bba15001f\ring-0.16.20\pregenerated\aesv8-armx-linux64.S
that are referenced.

@RubenGarcia
Copy link
Contributor Author

I have the warning about the resolver, it is harmless.
For your error, it looks like it is getting confused by the space in "Program Files". Maybe check that and move the ndk to somewhere else without spaces.
If you still have issues, I can upload the so file I generated.

@bartutiryakioglu
Copy link

I have the warning about the resolver, it is harmless. For your error, it looks like it is getting confused by the space in "Program Files". Maybe check that and move the ndk to somewhere else without spaces. If you still have issues, I can upload the so file I generated.

Can you upload the SO file, i think it would solve all my problems

@RubenGarcia
Copy link
Contributor Author

armv7-linux-androideabi, release
libyaha_native.zip

@RubenGarcia
Copy link
Contributor Author

aarch64-linux-android, release
libyaha_native.zip

@eozkur
Copy link

eozkur commented Nov 3, 2023

I used the files you've uploaded and they worked fine in both device types. However, this is the case for .apk files. When we tried using these in production (when we built an .aab file) the Arm7 app couldn't find and load the dll. Do you have any idea why this is happening or do you have a possible fix?
By the way I uncompressed the .aab file and found the .so file in arm7 -> lib folder.

@RubenGarcia
Copy link
Contributor Author

No, I did not create aab files, so I can't help there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants