代码之家  ›  专栏  ›  技术社区  ›  Rob Lyndon

Xamarin Android:java.exe退出,代码为2-启用多索引

  •  1
  • Rob Lyndon  · 技术社区  · 7 年前

    在最近的更新(xamarin.android.support libraries,v28.0.0,build tools 28.0.3)之后,每个构建都失败了

    “代码2”退出的“java. exe”

    我以前已经启用了multi-dex来解决这个问题,到现在为止,这一切都没有问题。我还尝试重新启用proguard,并遵循 this 回答,包括maindexclasses.bat的更改。

    有几个新的警告,但我还不能确定它们是否导致了新的问题:

    CealMeTimeDeMistExcListList:警告:不能编写资源[ META-IMF/Mave/COM.SavaRUP.OKIO/OKIO/POM.XML](重复的ZIP条目[OKIO .jar:META-IMF/MAVEN/COM.SavaRUP.OKIO/OKIO/POM.XML])

    CealMeTimeDeMistExcListList:警告:不能编写资源[ META-IMF/Mave/COM.SavaRUP.OKIO/OKIO/POM.Frase](重复的ZIP条目[OKIO .jar:META-IMF/Mave/COM.ScRayUp.Okio/Okio/POM.Frase])

    更新 :看起来这是一个在v28 sdk中悄悄出现的bug。有人责备 https://github.com/SpiegelSoft/Repro ,我在 https://github.com/xamarin/xamarin-android/issues/2565

    如果有人能找到任何巧妙的解决办法,我将非常感激。

    2 回复  |  直到 7 年前
        1
  •  1
  •   fewlinesofcode user10694837    7 年前

    我有这个问题,我的解决办法是:

    1. 关闭项目
    2. 从中删除bin和obj文件夹 PCL/Shared Project 以及包括Android在内的所有其他平台
    3. 开放项目
    4. 重建
        2
  •  0
  •   Nikita K    7 年前

    我好像也有同样的问题:

    (Duplicate zip entry [openpay.jar:META-INF/LICENSE])
    10>CREATEMULTIDEXMAINDEXCLASSLIST : warning : can't write resource [META-INF/NOTICE] (Duplicate zip entry [openpay.jar:META-INF/NOTICE])
    10>CREATEMULTIDEXMAINDEXCLASSLIST : warning : can't write resource [META-INF/services/com.fasterxml.jackson.core.JsonFactory] (Duplicate zip entry [openpay.jar:META-INF/services/com.fasterxml.jackson.core.JsonFactory])
    10>CREATEMULTIDEXMAINDEXCLASSLIST : warning : can't write resource [META-INF/maven/com.fasterxml.jackson.core/jackson-core/pom.xml] (Duplicate zip entry [openpay.jar:META-INF/maven/com.fasterxml.jackson.core/jackson-core/pom.xml])
    10>CREATEMULTIDEXMAINDEXCLASSLIST : warning : can't write resource [META-INF/maven/com.fasterxml.jackson.core/jackson-core/pom.properties] (Duplicate zip entry [openpay.jar:META-INF/maven/com.fasterxml.jackson.core/jackson-core/pom.properties])
    10>CREATEMULTIDEXMAINDEXCLASSLIST : warning : can't write resource [com/fasterxml/jackson/core/json/VERSION.txt] (Duplicate zip entry [__reference__jackson-core-2.1.3.jar:com/fasterxml/jackson/core/json/VERSION.txt])
    10>CREATEMULTIDEXMAINDEXCLASSLIST : warning : can't write resource [META-INF/services/com.fasterxml.jackson.core.JsonFactory] (Duplicate zip entry [__reference__jackson-core-2.1.3.jar:META-INF/services/com.fasterxml.jackson.core.JsonFactory])
    10>CREATEMULTIDEXMAINDEXCLASSLIST : warning : can't write resource [META-INF/maven/com.fasterxml.jackson.core/jackson-core/pom.xml] (Duplicate zip entry [__reference__jackson-core-2.1.3.jar:META-INF/maven/com.fasterxml.jackson.core/jackson-core/pom.xml])
    10>CREATEMULTIDEXMAINDEXCLASSLIST : warning : can't write resource [META-INF/maven/com.fasterxml.jackson.core/jackson-core/pom.properties] (Duplicate zip entry [__reference__jackson-core-2.1.3.jar:META-INF/maven/com.fasterxml.jackson.core/jackson-core/pom.properties])
    10>CREATEMULTIDEXMAINDEXCLASSLIST : warning : can't write resource [META-INF/ASL2.0] (Duplicate zip entry [__reference__jackson-core-asl-1.9.11.jar:META-INF/ASL2.0])
    10>CREATEMULTIDEXMAINDEXCLASSLIST : warning : can't write resource [META-INF/LICENSE] (Duplicate zip entry [__reference__jackson-core-asl-1.9.11.jar:META-INF/LICENSE])
    10>CREATEMULTIDEXMAINDEXCLASSLIST : warning : can't write resource [META-INF/NOTICE] (Duplicate zip entry [__reference__jackson-core-asl-1.9.11.jar:META-INF/NOTICE])
    10>CREATEMULTIDEXMAINDEXCLASSLIST : warning : can't write resource [org/codehaus/jackson/impl/VERSION.txt] (Duplicate zip entry [__reference__jackson-core-asl-1.9.11.jar:org/codehaus/jackson/impl/VERSION.txt])
    10>CREATEMULTIDEXMAINDEXCLASSLIST : warning : can't write resource [META-INF/maven/com.squareup.okio/okio/pom.xml] (Duplicate zip entry [okio.jar:META-INF/maven/com.squareup.okio/okio/pom.xml])
    10>CREATEMULTIDEXMAINDEXCLASSLIST : warning : can't write resource [META-INF/maven/com.squareup.okio/okio/pom.properties] (Duplicate zip entry [okio.jar:META-INF/maven/com.squareup.okio/okio/pom.properties])
    10>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2610,3): error MSB6006: "java.exe" exited with code 2.
    

    对我来说,它是在我从packages.config迁移到packagereference之后开始发生的。它以前都在packages.config中工作过。我已经试过删除bin/obj、清理/重建,并且multidex已打开。我的目标框架是pie。

    在战斗了3天之后,对我来说“有效”的是将我所有的XAMARIN .ANDROID.Nuffic支持从23.0.0.1到27.0.2.1,并移除所有的XAMARIN .ANDROID.Nuvices NuGube,从V280.0开始添加(即只有V28和20.0.0.1),例如xamarin.android.support.coordinaterlayout)。这允许构建和运行应用程序。

    你找到工作了吗,也许是个干净点的?