Forum Xamarin.Android
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Android app deploys/works fine when built in VS but not when built from msbuild

This has me pulling my hair out..

We have a project that works fine in debug or adhoc(release) when built and deployed using Visual Studio. But when we build it from the command line (msbuild as part of cake script) it just repeats the following log output:

D/ResourcesManager(24055): For user 0 new overlays fetched Null
I/MultiDex(24055): VM with version 2.1.0 has multidex support
I/MultiDex(24055): install
I/MultiDex(24055): VM has multidex support, MultiDex support library is disabled.
W/monodroid(24055): Creating public update directory: `/data/user/0/<AppName>/files/.__override__`
W/monodroid(24055): Using override path: /data/user/0/<AppName>/files/.__override__
W/monodroid(24055): Trying to load sgen from: /data/user/0/<AppName>/files/.__override__/libmonosgen-2.0.so
W/monodroid(24055): Trying to load sgen from: /storage/emulated/0/Android/data/<AppName>/files/.__override__/libmonosgen-2.0.so
W/monodroid(24055): Trying to load sgen from: /storage/emulated/0/../legacy/Android/data/<AppName>/files/.__override__/libmonosgen-2.0.so
W/monodroid(24055): Trying to load sgen from: /data/app/<AppName>-1/lib/arm/libmonosgen-2.0.so
W/monodroid(24055): Trying to load sgen from: /data/user/0/<AppName>/files/.__override__/links/libmonosgen-2.0.so
A/monodroid(24055): No assemblies found in '/data/user/0/<AppName>/files/.__override__' or '/storage/emulated/0/Android/data/<AppName>/files/.__override__'. Assuming this is part of Fast Deployment. Exiting...

On one device it just loops with the splash screen visible spitting this out forever, on another device it does 3 iterations (with splash flashing visible) and then stops trying and the app crashes.

I've checked that fast deployment/android shared runtime are disabled. I've tried multiple different settings in the csproj file.

relevant parts of project file (I think):

<Project>
    ...
<PropertyGroup>
    ...
    <AndroidApplication>true</AndroidApplication>
    <AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile>
    <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
    <AndroidUseLatestPlatformSdk>true</AndroidUseLatestPlatformSdk>
    <TargetFrameworkVersion>v8.0</TargetFrameworkVersion>
    <AndroidSupportedAbis>armeabi,armeabi-v7a,x86</AndroidSupportedAbis>
    <AndroidStoreUncompressedFileExtensions />
    <MandroidI18n />
    <JavaMaximumHeapSize>1G</JavaMaximumHeapSize>
    <AndroidEnableMultiDex>true</AndroidEnableMultiDex>
    <JavaOptions />
    ...
<PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <AndroidUseSharedRuntime>False</AndroidUseSharedRuntime>
    <EmbedAssembliesIntoApk>True</EmbedAssembliesIntoApk>
    <AndroidLinkMode>SdkOnly</AndroidLinkMode>
</PropertyGroup>
...
</Project>

And here is how I call it from my cake script

MSBuild(androidProject, settings => settings
    .SetConfiguration(configuration)
    .WithProperty("Platform", "AnyCPU")
    .SetVerbosity(Verbosity.Verbose)
    .WithProperty("AndroidKeyStore", "true")
    .WithProperty("AndroidSigningStorePass", aksPassword)
    .WithProperty("AndroidSigningKeyStore", androidKeyStoreFile)
    .WithProperty("AndroidSigningKeyAlias", androidKeystoreAlias)
    .WithProperty("AndroidSigningKeyPass", aksPassword)
    //.WithProperty("DebugSymbols", "true")
    .WithTarget("SignAndroidPackage")
    .WithTarget("Build")
    .WithProperty("OutputPath", System.IO.Path.Combine(buildDir, "android"))
    .WithProperty("TreatWarningsAsErrors","false"));

I've been searching the web and changing settings/rebuilding all day with no progress.

(This is a Xamarin.Forms app, but I'm posting in Android because I don't think the issue is specific to that)

Posts

  • JonDouglasJonDouglas USXamarin Team, University, Developer Group Leader Xamurai
    edited December 2017

    Hey @DuaneNewman

    If you eliminate Cake from this equation and use msbuild directly on the command line, do you run into this same issue? That would be my first diagnose step as from a first glance I am not so sure about the cake script(mainly output path).

    Secondly, can you include adb logcat logs from the time you install the app and it crashes? That will help us figure out what's going on here.

  • DuaneNewmanDuaneNewman USMember

    @JonDouglas, thanks for pushing me in the right direction.. manually building it via msbuild uncovered my issue.

    I was passing in Ad-Hoc for the configuration and calling my android csproj directly.. and my android csproj doesn't have an ad-hoc configuration. The odd thing is I didn't get a build error, just a package I couldn't use. Once I set it pass in release everything was good.

    Ad-Hoc was a remnant from when the script was building from the solution file (in which case my android project was built with release mode). What a painful mundane detail.

    Thanks again!

  • fabrifabri ILMember ✭✭

    Hi @JonDouglas and @DuaneNewman ,

    I am struggling for a while now with this matter, can't find any info for Android, so this is the closest post I've found so far.
    I need to automate both Ad-Hoc and store build and publish processes.

    I managed to build, sign and zip align for the Play Store from the command line. Unfortunately, when I download this apk from my server and have it installed, it won't work.

    I suppose the packaging process is different for Ad-Hoc and Play Store, isn't?
    Could you be so kind as to post the command lines required to produce an Ad-Hoc apk?
    Do I need to define a new project configuration named Ad-hoc? If so, what must be configured in it?

    Thanks

Sign In or Register to comment.