Multidex Xamarin Maps android issues - c#

After adding the Xamarin maps nuget package to my app, I was getting the Java.exe has exited with code 2 error. I enabled multi-dex in the android options and I am now getting the following error:
Expecting class path separator ';' before '\Android\android-sdk\build-tools\26.0.0-preview\lib\shrinkedAndroid.jar'
I re-installed the Android SDK and made sure that I had the latest version, however I am still getting the error. I've spent a good while googling this issue and trying different solutions, however I have not found one to work

There are some issues with multi-dex at the current build. Updating to Visual Studio 2017 13.2 may fix the issue you mentioned. If it doesn´t, you can try two things:
To fix the class path separator error, put your Android SDK in a path without spaces. i.e: C:\android-sdk\ and change the path in Tools>Options>Xamarin>Android SDK Location.
If you don´t want to move the SDK you can create a link with a command line:
mklink /D "C:\android-sdk" "C:\Program Files (x86)\Android\android-sdk"
If even with Multi-dex enabled, it doesn´t run:
When you tick "Enable Multi-Dex" option in the Android project properties, you´ll see the change reflected in the csproj as you would expect
<AndroidEnableMultipleDex>true</AndroidEnableMultipleDex>
But if you take a closer look, there is another similar xml node that keeps its value to false:
<AndroidEnableMultiDex>false</AndroidEnableMultiDex>
Notice the difference between "MultiDex" and "MultipleDex"
Changing the second one to true will make the trick.

I have same problem while adding map with nuget package to my app.
just change the latest proguard.jar file from link
and replce from your android sdk-> tools->proguard->lib->progaurd.jar
and
right click on your android project->select option->build->android build-> enable proguard and enable multidex as well go to Advance ->java heap size put 1G.

I had this same issue running Visual Studio 2017 v 15.2.
As has been mentioned before, this results when you've added enough nugets and packages to your solution that you exceed the 65k method limit in a standard dex file, requiring you to enable multi-dex.
Like others have noted, enabling multi-dex doesn't always fix the problem, because it turns on a flag called "AndroidEnableMutipleDex" in the .csproj file. So, as suggested above, I added the node
<AndroidEnableMultiDex>true</AndroidEnableMultiDex>
but, since I wasn't too familiar with the format of the .csproj file, I forgot to add it under both
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
...
<AndroidEnableMultipleDex>true</AndroidEnableMultipleDex>
<AndroidEnableMultiDex>true</AndroidEnableMultiDex>
</PropertyGroup>
and
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
...
<AndroidEnableMultipleDex>true</AndroidEnableMultipleDex>
<AndroidEnableMultiDex>true</AndroidEnableMultiDex>
</PropertyGroup>
Yes, this a a basic mistake, but it can be easy to make if you're not used to manually editing your .csproj file, especially if you're just wading into this for the first time and not even sure where exactly the bug is coming from.
Also, as others have noted, you will need to move the location of your Android sdk to a path with no spaces.

Related

How do I fix Azure pipeline error NETSDK1152?

While running my pipeline, it fails at the publish phase with 2 errors.
##[error]Error: The process 'C:\Program Files\dotnet\dotnet.exe' failed with exit code 1
##[error]Dotnet command failed with non-zero exit code on the following projects : ...
The pipeline also lists all paths to files with duplicate names, even if the contents are different. The pipeline worked fine before with the duplicate names, but now throws and error and will not proceed. what is the correct fix for this?
I think my pipeline is using Dotnet6 even though the app is only 3.1, and this was added to fix it. I don't know if this is the correct fix, but it is working.
I added this to the csproj files that have duplicate file names.
<PropertyGroup>
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
</PropertyGroup>
This is where I found it.
https://learn.microsoft.com/en-us/dotnet/core/project-sdk/msbuild-props#erroronduplicatepublishoutputfiles
This is a breaking change introduced in .NET 6
https://learn.microsoft.com/en-us/dotnet/core/compatibility/sdk/6.0/duplicate-files-in-output
You have multiple ways of fixing this:
Evaluate your resources in the project where "CopyToOutputFolder" is set to "Always" and remove if they are unnecessary. How MSBuild handles this is, it tries to copy these resources to output folder after the build is completed.
Target a specific SDK during the build by adding it in global.json
https://learn.microsoft.com/en-us/dotnet/core/versions/selection
You probably have "rollForward" option set to "latestFeature" that automatically uses the latest SDK, so you can remove that and target .NET 5 or earlier.

Could not find file obj\Debug\100\android\assets\Xamarin.Auth.dll.mdb'

I have developed a xamarin app and I got this error 'Could not find file obj\Debug\100\android\assets\Xamarin.Auth.dll.mdb' while debugging Visual studio 2019. It occured after VS update 16.9.1. There is no issue if i build the app in release.
I had exactly the same issue following the 16.9.1 update. After much frustration and trying everything I could think of including the suggestions in the other answers I found that this is actually a known issue introduced by Xamarin.Android 11.2.0.21 which ships with VS 16.9.1.
The problem seems to be caused by an update to fast deployment which requires .mdb debug files instead of the old .pdb symbols for Android projects.
To fix you need to update any NuGet packages which still use the old pdb symbol files in the hopes that they have been changed to use mdb debug files. In my case this wasn't possible, so the workaround is to add the following lines to your Android csproj just above the </Project> tag:
<Target Name="_RemoveMdbFiles" BeforeTargets="_Upload">
<ItemGroup>
<_Temp Include="%(_ResolvedSymbols.Identity)" Condition="'%(_ResolvedSymbols.Extension)' == '.mdb'" />
<_ResolvedSymbols Remove="#(_Temp)"/>
</ItemGroup>
If this workaround also isn't an option for you, I think the only other resolution would be to downgrade to VS 16.8.x.
EDIT: Seems to be fixed in VS 16.9.2 update.
Src:
https://learn.microsoft.com/en-us/xamarin/android/release-notes/11/11.2#known-issue-fast-deployment-and-mdb-files
https://github.com/xamarin/xamarin-android/issues/5631#issuecomment-794289675
A workaround is to create a file called Xamarin.Auth.dll.mdb. I just created a copy of Xamarin.Auth.dll and renamed it. It does not solve the underlying problem but at least I'm able to debug. Not sure if this have any side effects but so far so good...

Always run Custom Build Event in Visual Studio (without VC++)

How can I always run a custom script in Visual Studio 2015, even if nothing has changed... but using VS without VS++ installed?
I effectively want to do the same as this question however, my installation of Visual Studio 2015 does not have VC++ installed (as everything we do is either C# or VB.Net) so I do not have access to the same project properties pages.
Using the accepted answer as a starting point, and this article for more details I have added the following to my project file, but I simply cannot get it to run the custom script unless a file in the project has changed...
<PropertyGroup>
<ItemDefinitionGroup>
<CustomBuildStep>
<Command>MyScript.vbs</Command>
<Outputs>$(TargetName).missing</Outputs>
<Inputs>$(TargetFileName)</Inputs>
</CustomBuildStep>
</ItemDefinitionGroup>
</PropertyGroup>
<PropertyGroup>
<CustomBuildAfterTargets>ClCompile</CustomBuildAfterTargets>
<CustomBuildBeforeTargets>Link</CustomBuildBeforeTargets>
</PropertyGroup>
I have done a lot of searching for values for <CustomBuildAfterTargets> and <CustomBuildBeforeTargets> but I cannot find anything official or otherwise. It's highly frustrating for the MS article not to provide details on possible values.
I did also try adding the <DisableFastUpToDateCheck> attribute as per one of the answers, but that still rebuilds the project so isn't what I want.

Azure functions fail when creating a blank/empty project in an existing solution

I upgrade to Visual Studio 2017 15.8.1 and am having issues creating an Azure function project. The project I am trying to create is through the template wizard, just a new V1 empty function project.
I receive the following error, which seems to be .net core related.
NETSDK1004 Assets file '\obj\project.assets.json' not
found. Run a NuGet package restore to generate this
file. FunctionApp1 C:\Program Files\dotnet\sdk\2.1.400\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets 198
Run a NuGet package restore to generate this file.
But my project file states:
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<AzureFunctionsVersion>v1</AzureFunctionsVersion>
</PropertyGroup>
Just to be clear, I do want a 4.6.1 project, not a core one.
I have looked at other answers to this issue but none resolve it. Package reinstall, dotnet restore etc. I get more errors if I select a different template (e.g. HTTP Trigger)
Any ideas?
I thought I had a solution to reboot, then open %temp% and delete all the temporary files in that folder. Then reboot again for good measure and it worked from a blank / empty project, but as soon as I try include this in another solution or move the project it fails.
Seems I have it working now and I'll leave this here in case anyone else has the same.
I did try many many things to resolve, but I believe the crux of my fix was to reboot, then open %temp% and delete all the temporary files in that folder. Then I rebooted again for good measure and it worked from a blank / empty project.
Well that wasted a chunk of my day. I had created a repo in git which had a space in the name. When cloned I ended up with an encoded view of the repo - i.e. a %20 for the space, which appeared in the folder path. Since this was just some demo work I had left it as is instead of tidying it up to a clean namespace.
Turns out if you have a %20 or some other encoded value in your path you will get the NETSDK1004 error. I hope this answer saves someone else some time!

no start action in debug VS2013

I am trying to use DDEX for npgsql. while following steps provided http://fxjr.blogspot.fr/2011/05/npgsql-design-time-support-preview.html I came across a problem. The steps specifies that after setting up the project to startup project. I should go to the debug option and select start action to external program. But the problem is I cannot see the option for that. below is the screen shot of what I get when I select debug in project properties.
Is there any way around to get the project debug in another instance of devenv.exe to complete my DDEX npgsql setup?
Thanks.
This debug option is not available in VS Express.
The way around this is to manually edit the *.csproj.user file in your project folder, and add the following PropertyGroup:
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<StartAction>Program</StartAction>
<StartProgram>C:\Path\To\program.exe</StartProgram>
<StartArguments>/Something</StartArguments>
</PropertyGroup>
You will need to make sure that the Configuration and Platform (Debug|x86 in my example) match yours.
Cheers

Categories

Resources