问题
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
回答1:
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.
回答2:
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.
回答3:
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.
来源:https://stackoverflow.com/questions/44006261/multidex-xamarin-maps-android-issues