Invalid dex file indices" Error in Net Maui

Yusuf 791 Reputation points
2022-09-18T00:49:49.673+00:00

Hi,
I get the following error when publish Android app.

[BT : 1.8.1] error : Invalid dex file indices, expecting file 'classes?.dex' but found 'classes2.dex'

Steps:

  1. Create a new Maui app
  2. Copy keystore file created using Xamarin from

%userprofile%\AppData\Local\Xamarin\Mono for Android\KeyAlias\KeyAlias.keystore

to solution folder Then
3. Add the following code to csproj file

 <PropertyGroup Condition="$(TargetFramework.Contains('-android')) and '$(Configuration)' == 'Release'">  
        <AndroidKeyStore>True</AndroidKeyStore>  
        <AndroidSigningKeyStore>..\KeyAlias.keystore</AndroidSigningKeyStore>  
        <AndroidSigningKeyAlias>KeyAlias</AndroidSigningKeyAlias>  
        <AndroidSigningKeyPass>P@$$w0rd</AndroidSigningKeyPass>  
        <AndroidSigningStorePass>P@$$word</AndroidSigningStorePass>  
    </PropertyGroup>  
  1. Run this command in the terminal dotnet publish -c Release -f:net6.0-android

Thanks in advance

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,807 questions
0 comments No comments
{count} votes

Accepted answer
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 46,826 Reputation points Microsoft Vendor
    2022-09-19T05:21:31.6+00:00

    Hello,

    I've tested your configuration, and it worked fine as expected.

    error : Invalid dex file indices, expecting file 'classes?.dex' but found 'classes2.dex'

    the ? could be a garbled code, you could try to change your system language to English and rebuild this project.

    Best Regards,

    Alec Liu.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    4 people found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.