听起来您只想发布一个 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
希望这可以帮助。