编译 xamarin-android 应用程序时出现 java.exe 错误
Posted
技术标签:
【中文标题】编译 xamarin-android 应用程序时出现 java.exe 错误【英文标题】:java.exe error while compiling xamarin-android application 【发布时间】:2018-10-09 22:07:01 【问题描述】:我正在开发一个应用程序,突然我开始出现构建错误,
我也尝试过增加 java 的堆大小,但没有任何效果,有人可以帮我放吗?
这是日志....
> > `C:\Program Files\Java\jdk1.8.0_131\\bin\java.exe -jar C:\Users\DELL\AppData\Local\Xamarin\MonoForandroid\AndroidSDK\build-tools\25.0.1\\lib\dx.jar
> --no-strict --dex --output=obj\Debug\android\bin obj\Debug\android\bin\classes "C:\Program Files (x86)\Reference
> Assemblies\Microsoft\Framework\MonoAndroid\v7.0\mono.android.jar"
> obj\Debug\__library_projects__\Telerik.Xamarin.Android.Common\library_project_imports\bin\Common.jar
> obj\Debug\__library_projects__\Telerik.Xamarin.Android.Data\library_project_imports\bin\Data.jar
> obj\Debug\__library_projects__\Telerik.Xamarin.Android.Gauges\library_project_imports\bin\Gauges.jar
> obj\Debug\__library_projects__\Telerik.Xamarin.Android.Input\library_project_imports\bin\Input.jar obj\Debug\__library_projects__\Telerik.Xamarin.Android.List\library_project_imports\bin\List.jar
> obj\Debug\__library_projects__\Telerik.Xamarin.Android.Primitives\library_project_imports\bin\Primitives.jar
> obj\Debug\__library_projects__\TwilioClient.Android\library_project_imports\bin\classes.jar
> obj\Debug\__library_projects__\TwilioClient.Android\library_project_imports\libs\org.apache.http.legacy.jar
> obj\Debug\__library_projects__\Xamarin.Android.Support.Animated.Vector.Drawable\library_project_imports\bin\classes.jar
> obj\Debug\__library_projects__\Xamarin.Android.Support.Compat\library_project_imports\bin\classes.jar
> obj\Debug\__library_projects__\Xamarin.Android.Support.Core.UI\library_project_imports\bin\classes.jar
> obj\Debug\__library_projects__\Xamarin.Android.Support.Core.Utils\library_project_imports\bin\classes.jar
> obj\Debug\__library_projects__\Xamarin.Android.Support.Design\library_project_imports\bin\classes.jar
> obj\Debug\__library_projects__\Xamarin.Android.Support.Fragment\library_project_imports\bin\classes.jar
> obj\Debug\__library_projects__\Xamarin.Android.Support.Media.Compat\library_project_imports\bin\classes.jar
> obj\Debug\__library_projects__\Xamarin.Android.Support.Transition\library_project_imports\bin\classes.jar
> obj\Debug\__library_projects__\Xamarin.Android.Support.v4\library_project_imports\bin\classes.jar
> obj\Debug\__library_projects__\Xamarin.Android.Support.v7.AppCompat\library_project_imports\bin\classes.jar
> obj\Debug\__library_projects__\Xamarin.Android.Support.v7.RecyclerView\library_project_imports\bin\classes.jar
> obj\Debug\__library_projects__\Xamarin.Android.Support.Vector.Drawable\library_project_imports\bin\classes.jar
> C:\Users\DELL\AppData\Local\Xamarin\Xamarin.Android.Support.CustomTabs\23.3.0.0\embedded\classes.jar
>
> 1>
> 1> trouble writing output: Too many field references: 65539; max is 65536.
> 1> You may try using --multi-dex option.
> 1> References by package:
> 1> 2 android.accounts
> 1> 27 android.app
> 1> 24 android.content.pm
> 1> 10 android.content.res
> 1> 45 android.graphics
> 1> 2 mono.android.speech
> 1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2068,3):
> error MSB6006: "java.exe" exited with code 2.
> 1> DexOutputs:
> 1> obj\Debug\android\bin\classes.dex
> 1>Done executing task "CompileToDalvik" -- FAILED.
> 1>Done building target "_CompileToDalvikWithDx" in project "TestVoipApp.csproj" -- FAILED.
> 1>
> 1>Build FAILED.`
有什么建议吗?
【问题讨论】:
请将完整的构建日志作为文本添加到问题中 请不要将错误信息发布为图片 添加日志和删除图像。 【参考方案1】:开启MultiDex
Xamarin.Android -> 转到属性 -> AndroidOptions -> 启用 MultiDex
【讨论】:
我尝试并得到了这个错误严重性代码描述项目文件行抑制状态错误无法读取 [C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v7.0\ mono.android.jar] (无法处理类 [android/app/ActivityTracker.class] (不支持的类版本号 [52.0] (最大 51.0, Java 1.7))) TestVoipApp E:\Test\TestVOIP\TestAndroidClient\TwilioApp\ CREATEMULTIDEXMAINDEXCLASSLIST @Tayyab 看到这个答案,可以帮助你解决你刚才提到的这个错误; ***.com/questions/39514518/…以上是关于编译 xamarin-android 应用程序时出现 java.exe 错误的主要内容,如果未能解决你的问题,请参考以下文章
提前编译时出现 SystemJS 错误(NgZone 没有提供程序)