How to build a Xamarin.Android project without managed executables?

强颜欢笑 提交于 2019-12-11 15:29:41

问题


I'm tinkering with Xamarin.Forms on Visual Studio Community for Mac version 7.3.2

What I'm trying to accomplish is to convert all managed code to native executables using these options in MyApp.Droid.csproj:

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
  <EmbedAssembliesIntoApk>false</EmbedAssembliesIntoApk>
  <AotAssemblies>true</AotAssemblies>
  <EnableLLVM>true</EnableLLVM>
</PropertyGroup>

EmbedAssembliesIntoApk does embed the assemblies into the apk so I've set it to false, because those are precisely what I want to get rid of.

I've also set AotAssemblies and EnableLLVM to true so the managed code is AOT compiled and converted to native code.

Those options build a signed apk with the lib/ folder containing the files below and no assemblies folder, which is what I want.

lib/
  armeabi-v7a/
    libgdbserver.so
    libmono-profiler-log.so
    libmonodroid.so
    libmonosgen-2.0.so

The problem is that if I clear the application data on the device and try to run the app again it won't start giving me some error saying 'no assemblies found' or 'conflicts between different versions of the same assembly'

Is it possible to build and ship a Xamarin.Forms application for Android without any managed assemblies, but only native executables?

Update:

I tried Xamarin Studio and it adds the option BundleAssemblies, so the project setting are as follows but Xamarin fails build the target:

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
  <DebugSymbols>true</DebugSymbols>
  <DebugType>pdbonly</DebugType>
  <Optimize>true</Optimize>
  <OutputPath>bin\Release</OutputPath>
  <ErrorReport>prompt</ErrorReport>
  <WarningLevel>4</WarningLevel>
  <AndroidManagedSymbols>true</AndroidManagedSymbols>
  <AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
  <AndroidLinkMode>Full</AndroidLinkMode>
  <EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
  <AotAssemblies>true</AotAssemblies>
  <EnableLLVM>true</EnableLLVM>
  <BundleAssemblies>true</BundleAssemblies>
</PropertyGroup>

With those option on Visual Studio I get this executables:

lib/
  armeabi-v7a/
    libmonodroid_bundle_app.so
    libmonodroid.so
    libmonosgen-2.0.so

plus a bunch of files something.dll.so

来源:https://stackoverflow.com/questions/48025885/how-to-build-a-xamarin-android-project-without-managed-executables

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!