最近一次更新(Xamarin.Android.Support库,V28.0.0,构建工具28.0.3)之后,每个构建都因以下原因而失败
“ java.exe”以代码2退出
我以前启用了Multi-Dex来解决此问题,直到现在一直有效。我还尝试过重新启用ProGuard,并遵循this回答中的所有步骤,包括对MainDexClasses.bat的更改。
有几个新的警告,但是我无法确定它们是否引起了新的问题:
CREATEMULTIDEXMAINDEXCLASSLIST:警告:无法写入资源[META-INF / maven / com.squareup.okio / okio / pom.xml](重复的zip条目[okio.jar:META-INF / maven / com.squareup。 okio / okio / pom.xml])
CREATEMULTIDEXMAINDEXCLASSLIST:警告:无法写入资源[META-INF / maven / com.squareup.okio / okio / pom.properties](重复的zip条目[okio.jar:META-INF / maven / com.squareup。 okio / okio / pom.properties])
更新:看来这是V28 SDK中的一个bug。 https://github.com/SpiegelSoft/Repro处有一个复制人,而我在https://github.com/xamarin/xamarin-android/issues/2565中有一个问题
如果有人可以找到任何有效的解决方法,我将非常感激。
答案 0 :(得分:1)
我遇到了这个问题,对我来说,解决方法是:
PCL/Shared Project
和所有其他平台(包括Android)上删除bin和obj文件夹答案 1 :(得分:0)
我似乎有相同的问题:
(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,clean / rebuild,并且启用了multidex。我的目标框架是Pie。
战斗了3天之后,对我来说“起作用”的是将所有Xamarin.Android.Support nugets从28.0.0.1降级到27.0.2.1,并删除了从v28开始添加的所有Xamarin.Android.Support nugets .0.0(即仅适用于v28和28.0.0.1,例如Xamarin.Android.Support.CoordinaterLayout)。这样可以构建和运行该应用程序。
您是否能够找到解决方法,也许是一种更清洁的方法?
答案 2 :(得分:0)
从VS Mac切换到VS Windows时出现此错误。
Here the topic Switching From VS Mac To VS Windows got “java.exe” exited with code 2
问题来自Android.csproj和密钥库路径。
即使我已经在Mac Path上进行了更改,它也已设置为
VSWindows AndroidProject =>属性=>登录
<AndroidKeyStore>True</AndroidKeyStore>
<AndroidSigningKeyStore>YourMacPath/Alias.keystore</AndroidSigningKeyStore>
<AndroidSigningStorePass>Password</AndroidSigningStorePass>
<AndroidSigningKeyAlias>Alias</AndroidSigningKeyAlias>
<AndroidSigningKeyPass>AliasPassword</AndroidSigningKeyPass>
在调试和发布部分。
然后您可以在VS Windows上对其进行编辑。
希望我帮助了某人。 再见