gpt4 book ai didi

android - 'mono shared runtime' 始终部署到 android 设备

转载 作者:行者123 更新时间:2023-11-29 16:08:29 25 4
gpt4 key购买 nike

我正在尝试使用 xamarin.android 和 visual studio 2012 创建一个 APK,但是“包 ... apk 文件”的选项被禁用 - 我相信这是一个错误,如下所述:( https://bugzilla.xamarin.com/show_bug.cgi?id=10530 ).

但是,在部署到设备时仍会创建一个 apk,问题是我只想要一个包含所有内容的 APK(因此我可以通过网络服务器部署它),但是以这种方式构建时,即使在发布时使用'未选中“使用共享运行时”,“单声道共享运行时”仍安装在设备上。我在这里创建了一个问题:(https://bugzilla.xamarin.com/show_bug.cgi?id=11419)但还没有回复..

最佳答案

听起来您只想发布一个 APK,对吗?在这种情况下,可以从命令行构建 APK。如果您使用的是 Windows,则可以使用以下 Powershell 脚本作为模板来自动执行此操作:

# First clean the Release target.
msbuild.exe HelloWorld.csproj /p:Configuration=Release /t:Clean

# Now build the project, using the Release target.
msbuild.exe HelloWorld.csproj /p:Configuration=Release /t:PackageForAndroid

# At this point there is only the unsigned APK - sign it.
# The script will pause here as jarsigner prompts for the password.
# It is possible to provide they keystore password for jarsigner.exe by adding an extra command line parameter -storepass, for example
# -storepass <MY_SECRET_PASSWORD>
# If this script is to be checked in to source code control then it is not recommended to include the password as part of this script.
& 'C:\Program Files\Java\jdk1.6.0_24\bin\jarsigner.exe' -verbose -sigalg MD5withRSA -digestalg SHA1 -keystore ./xample.keystore -signedjar ./bin/Release/mono.samples.helloworld-signed.apk ./bin/Release/mono.samples.helloworld.apk publishingdoc

# Now zipalign it. The -v parameter tells zipalign to verify the APK afterwards.
& 'C:\Program Files\Android\android-sdk\tools\zipalign.exe' -f -v 4 ./bin/Release/mono.samples.helloworld-signed.apk ./helloworld.apk

在 Mac 上也可以从命令行构建。我通常会使用 Rake 构建文件自动执行此操作(您需要为来自 Albacore 的 .NET Rake 任务安装 gem)。以下是您可以用作模板的 rakefile:

require 'albacore'

@file_version = "2.0.0.0"
@keystore = "../keystores/opgenorth-release-key.keystore"
@alias_name = "mytrips"
@input_apk = "EmploymentStandardsJudgments.Android/bin/Release/net.opgenorth.esj.apk"
@signed_apk = "EmploymentStandardsJudgments.Android/bin/Release/net.opgenorth.esj-signed.apk"
@final_apk = "deploy/AlbertaEmploymentJudgments.apk"

task :default => [:clean, :versioning, :build, :sign]

desc "Remove the bin and obj directories."
task :clean do
rm_rf "EmploymentStandardsJudgments.Android/bin"
rm_rf "EmploymentStandardsJudgments.Android/obj"
end

desc "Update the build number before compiling."
assemblyinfo :versioning do |asm|
asm.input_file = "EmploymentStandardsJudgments.Android/Properties/AssemblyInfo.cs"
asm.output_file = "EmploymentStandardsJudgments.Android/Properties/AssemblyInfo.cs"
asm.version = @file_version
asm.file_version = @_file_version
end

desc "Compiles the project."
xbuild :build do |msb|
msb.solution = "EmploymentStandardsJudgments.Android/EmploymentStandardsJudgments.Android.csproj"
msb.properties = { :configuration => :release }
msb.targets [ :Clean, :Build, :SignAndroidPackage ]
end

desc "Signs and zip aligns the APK."
task :sign do
sh "jarsigner", "-verbose", "-sigalg", "MD5withRSA", "-digestalg", "SHA1", "-keystore", @keystore, "-signedjar", @signed_apk, @input_apk, @alias_name
sh "zipalign", "-f", "-v", "4", @signed_apk, @final_apk
end

desc "Install the APK on a device."
task :install do
%x[adb shell pm uninstall -k net.opgenorth.esj.android]
%x[adb install deploy/AlbertaEmploymentJudgments.apk]
end

希望这对您有所帮助。

关于android - 'mono shared runtime' 始终部署到 android 设备,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15764984/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com