“java.exe"退出代码 2 Xamarin.Android 项目 [英] "java.exe" exited with code 2 Xamarin.Android project

查看:41
本文介绍了“java.exe"退出代码 2 Xamarin.Android 项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有我的 Xamarin.Android 项目,其中包含多个库.当我尝试构建时,我收到一条错误消息,显示java.exe"以代码 2 退出.

so I have my Xamarin.Android project which contains several libraries. When I try to build I receive an error which says "java.exe" exited with code 2.

经过几个小时的谷歌研究后,我发现我可以启用 Multidex.根据 Jon Doublas 的博客条目,我执行了提到的步骤.http://www.jon-douglas.com/2016/09/05/xamarin-android-multidex/

After some hours of google research I found out that I could enable Multidex. According to the blog entry of Jon Doublas I did the steps mentioned. http://www.jon-douglas.com/2016/09/05/xamarin-android-multidex/

根据博客条目 Android API Level > 21 处理 Multidex 本身.好吧,我的经验是它没有.我在 API 级别 25 上构建并使用相同的信息一次又一次地得到相同的错误.文章中的步骤没有帮助.Xamarin.Android 似乎不支持 Multidex.

According to the blog entry Android API Level > 21 handles Multidex itself. Well my experience is that it does not. I am building on API Level 25 and get the same error again and again with the same information. The steps in the article do not help. It seems like Xamarin.Android does not support Multidex.

似乎您必须自己处理 Multidex,但我还没有找到任何有效的解决方案.有人找到了有效的解决方案吗?

It seems like you have to handle Multidex by yourself but I haven't found any solution which is working. Dos anybody found a solution which works?

我使用的是 Xamarin 4.6 和 Visual Studio 2017.

I am using Xamarin 4.6 and Visual studio 2017.

推荐答案

在我的项目中搜索了大约 20 个小时后找到了答案..所以这里是解决java.exe"以代码2退出的问题的步骤

Found the answer after about 20 hours of searching in my project.. So here are the steps to resolve the problem "java.exe" exited with code 2

1) 按照链接中的描述更改 MainDexClasses.bat:

1) Change the MainDexClasses.bat as described in the link:

http://www.jon-douglas.com/2016/09/05/xamarin-android-multidex/

2) 确保您已在 Android 应用程序中启用 Multidex 选项!如果 Multidex 设置为 true,请查看 .csprj 文件(在我的情况下,即使我启用了 多索引)

2) Make sure you have enabled Multidex Option in your Android Application! Have a look at the .csprj file if Multidex is set to true (in my case it wasn't even if I enabled Multidex)

3) 在您的 AndroidManifest 文件中添加以下部分

3) Add the following part in your AndroidManifest file

<application android:name="android.support.multidex.MultiDexApplication"></application>

这将告诉您的 Android 项目实际使用给定的 Multidex-Option.

This will tell your Android project to actually use the Multidex-Option given.

经过清理和构建后,我能够按原样运行我的应用程序.

After a clean and build I was able to run my application as it is.

这篇关于“java.exe"退出代码 2 Xamarin.Android 项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆