如何在单个Xamarin Android安装包中包含多C++ ABI版本?
Hey there! I’ve dealt with this exact issue before when working with Xamarin Android and C++ shared libraries in Visual Studio 2017—let me break down the steps to get your app packing multiple ABI versions of your C++ DLL.
Step 1: Configure ABI Targets in Your C++ Shared Library Project
First, we need to make sure your C++ library builds for all the ABIs you need:
- Right-click your C++ Shared Library project and select Properties
- Navigate to Configuration Properties → General
- Look for the Target Platforms section, then check all the ABIs you want to support (common ones are
armeabi-v7a,arm64-v8a,x86,x86_64) - Don’t forget to apply this setting to both Debug and Release configurations (use the dropdown at the top of the properties window to switch between them)
Step 2: Match Supported ABIs in Your Xamarin Android Project
Next, tell your Xamarin project to include those same ABIs:
- Right-click your Xamarin Android project and go to Properties
- Switch to the Android Options tab, then click the Advanced button
- In the Supported ABIs list, check the exact same ABIs you enabled in the C++ project. This ensures Xamarin pulls the correct DLL version for each architecture.
Step 3: Verify References and Clean Compile
- Double-check that your Xamarin Android project has a project reference to the C++ Shared Library (right-click Xamarin project → Add Reference → Projects → select your C++ library)
- Old build artifacts can cause issues, so do a full clean of the solution: go to Build → Clean Solution, then rebuild everything with Build → Rebuild Solution
Step 4: Confirm the Result
After rebuilding, locate your output APK (usually in YourXamarinProject\bin\Release or Debug). If you unpack the APK, you should see a lib folder with subfolders for each ABI you selected—each will contain your C++ DLL.
Quick Notes
- Make sure Visual Studio 2017 has the Android NDK component installed (you can check via Tools → Get Tools and Features → Mobile development with .NET → verify Android NDK is selected)
- If you still only see one ABI, double-check that both projects are set to build for the same configuration (e.g., both Release or both Debug) when you compile the solution.
内容的提问来源于stack exchange,提问作者G Watts
相关产品推荐
相关产品推荐

