Create apk from command line

alberto.palberto.p ITMember ✭✭

Hi,
how can I create apk from my batch file? And which command tools should I use ?

Thanks

Posts

  • TomOpgenorthTomOpgenorth CAXamarin Team Xamurai

    Part 1 of Xamarin's documentation on publishing an application has an explanation. It also has a Powershell script you can use (might have to make some modifications) to compile at the command line on Windows.

    If you're on OS X, you can use Albacore and Rake, as shown in this Rakefile.

  • alberto.palberto.p ITMember ✭✭

    @topgenorth thanks but I saw it. My problem is that:
    1 - I build project in release mode
    2- Obfuscate dll
    3- Should I create apk with new dll, but I don't know how.

  • alberto.palberto.p ITMember ✭✭

    @jonp can you give me some more information about:
    You should perform (2) as a post-build step within your Project. The Xamarin.Android build process will then use your obfuscated assemblies as inputs for the linker, and place the obfuscated+linked assemblies into the .apk.

    How can I make this step? how can i input obfuscated dll to linker?
    unfortunately it is not clear to me this passage

  • JonathanPryorJonathanPryor USXamarin Team Xamurai

    can you give me some more information about: You should perform (2) as a post-build step within your Project.

    Within Visual Studio,

    1. Click Project > Project Name Properties...
    2. Click the Build Events tab.
    3. In the Post-build event command-line, enter the command to execute.

    Within Xamarin Studio:

    1. Click Project > Project Name Options
    2. In the tree on the left, select Build > Custom Commands
    3. In the panel on the right, set your Configuration, then in the (Select a project operation) drop-down, select After Build.
    4. Enter the Command and Working Directory to use.
    5. Click OK.
  • alberto.palberto.p ITMember ✭✭

    Ok in My case I use Xamarin studio. I'll try to use after build command for obfuscating code, sorry but where do I copy the dll and how to create the apk?

  • alberto.palberto.p ITMember ✭✭

    @jonp Great work!! Just a clarification.
    I set the obfuscate as a post-build and at the same time I copy my dll in the folder "obj \ Release" and "obj \ Release \ assemblies".

    After that, to create the apk from Xamarin Studio, I go to the menu Project-> Create Android Package or Publish Android Application.
    Is correct?

  • JonathanPryorJonathanPryor USXamarin Team Xamurai

    I set the obfuscate as a post-build and at the same time I copy my dll in the folder "obj \ Release" and "obj \ Release \ assemblies".

    I don't think that this would be necessary; bin\Release\*.dll should be copied to obj\Release\assemblies\ as part of the linking process, so you should only need to obfuscate the bin\Release assemblies (untested).

    After that, to create the apk from Xamarin Studio, I go to the menu Project-> Create Android Package or Publish Android Application. Is correct?

    That should work, yes. You can also just Run > Start Without Debugging to implicitly create the .apk and install it onto your attached device.

  • akashrastogiakashrastogi USMember

    hi ,
    i have used above command line and also msbuild.exe HelloWorld.csproj /p:Configuration=Release /t:PackageForAndroid ** but the apk which is generating is not running ,it shows parsing error while installing in device , i have business edition of xamarin. can you please help in this ,what i have to set as ** Target so that i can get working apk

  • Necro posting here but MSBuild does not work with indie edition unfortunately. :(

  • Is there a plan for Indie to be able to build Xamarin app with command line?
    Automated CI is a common best practice and shouldn't be available to enterprise only :(

  • Here also a "Parse error" occurs when installing an APK which was created using msbuild with PackageForAndroid - Target.

  • TrevorCoxTrevorCox CAMember ✭✭

    As @EmmanuelJacquier.5031 said, builds don't work with Indie. Specifically with Xamarin Studio 5.10.2 on OSX I am getting:

    MTOUCH: error MT9008: Building from the command-line requires a Business license.

    Anyone know if this is changing with the MS acquisition?

  • TrevorCoxTrevorCox CAMember ✭✭

    Great, the "Business license" error in gone with Xamarin Community Edition 5.10.3!

  • MithileshNaikMithileshNaik USMember ✭✭

    @akashrastogi and anybody else who might be facing this problem, you need to sign the apk before you install it on device.

  • AlanClarkAlanClark USForum Administrator, Xamarin Team Xamurai

    Given the age of this thread and the fast-moving pace of the Xamarin tooling (and tech in general) it would be recommended that if people are experiencing similar issues that they create a new thread on the topic :)

    Cheers,
    Al

  • GirishVenkataGirishVenkata USMember ✭✭

    Even i have similar kind of issue.. When package my app, sign and zipalign and upload to play store via jenkins app crashes after the launch. Same commands are working when i do it from msbuild.exe.

  • JTOneJTOne USMember ✭✭

    Here is C# console app example of how to build Android with custom versionCode, versionName and packedgeName separated by ABI

    https://github.com/JTOne123/OnePackagePerABI

Sign In or Register to comment.