R.java 文件没有产生 或者dx.jar未找到错误

本文解决离线安装SDK时dx.jar文件不一致导致的错误,确保平台工具库和开发版本库中dx.jar文件的一致性即可修正问题。
出现这样的错误,可能是没安装好sdk,可以修正一下,尤其是离线安装,有可能导致。确保dx.jar这个文件在platform-tools\lib和选择的开发版本lib中的文件一致就可以
Error building Player: CommandInvokationFailure: Unable to convert classes into dex format. See the Console for details. C:/Program Files/Java/jdk-1.8\bin\java.exe -Xmx2048M -Dcom.android.sdkmanager.toolsdir="D:/Android/sdk\tools" -Dfile.encoding=UTF8 -jar "D:\Unity\5.3.8f2\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\sdktools.jar" - stderr[ warning: Ignoring InnerClasses attribute for an anonymous inner class (com.tencent.mm.sdk.b.b) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is *not* an inner class. warning: Ignoring InnerClasses attribute for an anonymous inner class (com.testin.agent.a.b) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is *not* an inner class. warning: Ignoring InnerClasses attribute for an anonymous inner class (com.testin.agent.a.e) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is *not* an inner class. warning: Ignoring InnerClasses attribute for an anonymous inner class (com.testin.agent.a.f) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is *not* an inner class. warning: Ignoring InnerClasses attribute for an anonymous inner class (com.testin.agent.a.i) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is *not* an inner class. warning: Ignoring InnerClasses attribute for an anonymous inner class (com.testin.agent.a.m) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is *not* an inner class. warning: Ignoring InnerClasses attribute for an anonymous inner class (com.testin.agent.d.b.c) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is *not* an inner class. warning: Ignoring InnerClasses attribute for an anonymous inner class (com.testin.agent.d.b.b) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is *not* an inner class. warning: Ignoring InnerClasses attribute for an anonymous inner class (com.testin.agent.e.h) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is *not* an inner class. Uncaught translation error: java.lang.IllegalArgumentException: already added: Lbitter/jnibridge/JNIBridge; Uncaught translation error: java.lang.IllegalArgumentException: already added: Lbitter/jnibridge/JNIBridge$a; Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/unity3d/player/NativeLoader; Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/unity3d/player/ReflectionHelper; Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/unity3d/player/ReflectionHelper$1; Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/unity3d/player/ReflectionHelper$a; Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/unity3d/player/UnityPlayer; Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/unity3d/player/UnityPlayer$1; Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/unity3d/player/UnityPlayer$10; UNEXPECTED TOP-LEVEL EXCEPTION: java.lang.RuntimeException: Translation has been interrupted at com.android.dx.command.dexer.Main.processAllFiles(Main.java:608) at com.android.dx.command.dexer.Main.runMonoDex(Main.java:311) at com.android.dx.command.dexer.Main.run(Main.java:277) at com.android.dx.command.dexer.Main.main(Main.java:245) at com.android.dx.command.Main.main(Main.java:106) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at SDKMain.main(SDKMain.java:129) Caused by: java.lang.InterruptedException: Too many errors at com.android.dx.command.dexer.Main.processAllFiles(Main.java:600) ... 9 more ] stdout[ processing bin\classes\.\com\dw\Dating\lua\R.class... processing bin\classes\.\com\dw\Dating\lua\R$attr.class... processing bin\classes\.\com\dw\Dating\lua\R$drawable.class... processing bin\classes\.\com\dw\Dating\lua\R$string.class... processing bin\classes\.\com\dw\Dating\lua\R$style.class... processing bin\classes\.\com\dw\Dating\lua\R$xml.class... processing archive bin\classes.jar... processing bitter/jnibridge/JNIBridge.class... processing bitter/jnibridge/JNIBridge$a.class... processing com/unity3d/player/NativeLoader.class... processing com/unity3d/player/ReflectionHelper.class... processing com/unity3d/player/ReflectionHelper$1.class... processing com/unity3d/player/ReflectionHelper$a.class... processing com/unity3d/player/UnityPlayer.class... processing com/unity3d/player/UnityPlayer$1.class... processing com/unity3d/player/UnityPlayer$10.class... processing com/unity3d/player/UnityPlayer$11.class... processing com/unity3d/player/UnityPlayer$12.class... processing com/unity3d/player/UnityPlayer$13.class... processing com/unity3d/player/UnityPlayer$14.class... processing com/unity3d/player/UnityPlayer$15.class... processing com/unity3d/player/UnityPlayer$15$1.class... processing com/unity3d/player/UnityPlayer$16.class... processing com/unity3d/player/UnityPlayer$17.class... processing com/unity3d/player/UnityPlayer$18.class... processing com/unity3d/player/UnityPlayer$19.class... processing com/unity3d/player/UnityPlayer$2.class... processing com/unity3d/player/UnityPlayer$20.class... processing com/unity3d/player/UnityPlayer$3.class... processing com/unity3d/player/UnityPlayer$4.class... processing com/unity3d/player/UnityPlayer$5.class... processing com/unity3d/player/UnityPlayer$6.class... processing com/unity3d/player/UnityPlayer$7.class... processing com/unity3d/player/UnityPlayer$8.class... processing com/unity3d/player/UnityPlayer$9.class... processing com/unity3d/player/UnityPlayer$a.class... processing com/unity3d/player/UnityPlayer$b.class... processing com/unity3d/player/UnityPlayer$c.class... processing com/unity3d/player/UnityPlayer$d.class... processing com/unity3d/player/UnityPlayerActivity.class... processing com/unity3d/player/UnityPlayerNativeActivity.class... processing com/unity3d/player/UnityPlayerProxyActivity.class... processing com/unity3d/player/UnityWebRequest.class... processing com/unity3d/player/WWW.class... processing com/unity3d/player/a.class... processing com/unity3d/player/a$1.class... processing com/unity3d/player/a$2.class... processing com/unity3d/player/a$a.class... processing com/unity3d/player/b.class... processing com/unity3d/player/b$1.class... processing com/unity3d/player/b$2.class... processing com/unity3d/player/c.class... processing com/unity3d/player/d.class... processing com/unity3d/player/d$1.class... processing com/unity3d/player/d$2.class... processing com/unity3d/player/e.class... processing com/unity3d/player/f.class... processing com/unity3d/player/g.class... processing com/unity3d/player/h.class... processing com/unity3d/player/i.class... processing com/unity3d/player/j.class... processing com/unity3d/player/k.class... processing com/unity3d/player/k$1.class... processing com/unity3d/player/k$2.class... processing com/unity3d/player/k$2$1.class... processing com/unity3d/player/k$2$1$1.class... processing com/unity3d/player/l.class... processing com/unity3d/player/l$1.class... processing com/unity3d/player/m.class... processing com/unity3d/player/n.class... processing com/unity3d/player/n$1.class... processing com/unity3d/player/o.class... processing com/unity3d/player/p.class... processing com/unity3d/player/p$1.class... processing com/unity3d/player/q.class... processing com/unity3d/player/r.class... processing com/unity3d/player/s.class... processing com/unity3d/player/s$1.class... processing com/unity3d/player/s$2.class... processing com/unity3d/player/s$3.class... processing com/unity3d/player/t.class... processing com/unity3d/player/u.class... processing com/unity3d/player/v.class... processing com/unity3d/player/w.class... processing com/unity3d/player/w$1.class... processing org/fmod/FMODAudioDevice.class... processing org/fmod/a.class... processing archive plugins\.\FanweiPlugin_v4.4.jar... processing android/app/ActivityThread.class... processing android/app/Instrumentation.class... processing android/app/Instrumentation$ActivityMonitor.class... processing android/app/Instrumentation$ActivityResult.class... processing android/app/LoadedApk.class... processing com/fanwei/bluearty/pluginmgr/BuildConfig.class... processing com/fanwei/bluearty/pluginmgr/DynamicActivity.class... processing com/fanwei/bluearty/pluginmgr/Globals.class... processing com/fanwei/bluearty/pluginmgr/PluginActivityLifeCycleCallback.class... processing com/fanwei/bluearty/pluginmgr/PluginManager.class... processing com/fanwei/bluearty/pluginmgr/delegate/DelegateActivityThread.class... processing com/fanwei/bluearty/pluginmgr/delegate/DelegateInstrumentation.class... processing com/fanwei/bluearty/pluginmgr/delegate/LayoutInflaterProxyContext.class... processing com/fanwei/bluearty/pluginmgr/environment/CreateActivityData.class... processing com/fanwei/bluearty/pluginmgr/environment/PlugInfo.class... processing com/fanwei/bluearty/pluginmgr/environment/PluginClassLoader.class... processing com/fanwei/bluearty/pluginmgr/environment/PluginContext.class... processing com/fanwei/bluearty/pluginmgr/environment/PluginInstrumentation.class... processing com/fanwei/bluearty/pluginmgr/reflect/NULL.class... processing com/fanwei/bluearty/pluginmgr/reflect/Reflect.class... processing com/fanwei/bluearty/pluginmgr/reflect/Reflect$1.class... processing com/fanwei/bluearty/pluginmgr/reflect/ReflectException.class... processing com/fanwei/bluearty/pluginmgr/selector/DefaultActivitySelector.class... processing com/fanwei/bluearty/pluginmgr/selector/DynamicActivitySelector.class... processing com/fanwei/bluearty/pluginmgr/utils/FileUtil.class... processing com/fanwei/bluearty/pluginmgr/utils/IntReader.class... processing com/fanwei/bluearty/pluginmgr/utils/NamespaceStack.class... processing com/fanwei/bluearty/pluginmgr/utils/PluginManifestUtil.class... processing com/fanwei/bluearty/pluginmgr/utils/StringBlock.class... processing com/fanwei/bluearty/pluginmgr/utils/Trace.class... processing com/fanwei/bluearty/pluginmgr/utils/XmlManifestReader.class... processing com/fanwei/bluearty/pluginmgr/utils/XmlResourceParser.class... processing com/fanwei/bluearty/pluginmgr/verify/PluginNotFoundException.class... processing com/fanwei/bluearty/pluginmgr/verify/PluginOverdueVerifier.class... processing com/fanwei/bluearty/pluginmgr/verify/SimpleLengthVerifier.class... processing com/fanwei/bluearty/pluginmgr/widget/LayoutInflaterWrapper.class... processing com/fanwei/bluearty/pluginmgr/widget/ViewStub.class... processing com/fanwei/bluearty/pluginmgr/widget/ViewStub$OnInflateListener.class... processing com/fanwei/bluearty/simplejson/BasicType.class... processing com/fanwei/bluearty/simplejson/BuildConfig.class... processing com/fanwei/bluearty/simplejson/SimpleJson.class... processing com/fanwei/bluearty/simplejson/SimpleJson$1.class... processing com/fanwei/bluearty/simplejson/annotation/CollectionCreateBy.class... processing com/fanwei/bluearty/simplejson/annotation/NickName.class... processing com/fanwei/bluearty/simplejson/annotation/NotConvert.class... processing com/fanwei/bluearty/simplejson/annotation/SerializeBy.class... processing com/fanwei/bluearty/simplejson/serializer/Serializer.class... processing com/fanwei/bluearty/tinyhttp/BuildConfig.class... processing com/fanwei/bluearty/tinyhttp/Const.class... processing com/fanwei/bluearty/tinyhttp/Request.class... processing com/fanwei/bluearty/tinyhttp/Request$Method.class... processing com/fanwei/bluearty/tinyhttp/Response.class... processing com/fanwei/bluearty/tinyhttp/RetryManager.class... processing com/fanwei/bluearty/tinyhttp/Webb.class... processing com/fanwei/bluearty/tinyhttp/Webb$1.class... processing com/fanwei/bluearty/tinyhttp/Webb$AutoDisconnectInputStream.class... processing com/fanwei/bluearty/tinyhttp/Webb$FWHostnameVerifier.class... processing com/fanwei/bluearty/tinyhttp/Webb$FWX509TrustManager.class... processing com/fanwei/bluearty/tinyhttp/WebbException.class... processing com/fanwei/bluearty/tinyhttp/WebbUtils.class... processing com/fanwei/jubaosdk/common/BuildConfig.class... processing com/fanwei/jubaosdk/common/core/AbstractCall.class... processing com/fanwei/jubaosdk/common/core/AbstractCall$Callback.class... processing com/fanwei/jubaosdk/common/core/AbstractCall$CallbackUI.class... processing com/fanwei/jubaosdk/common/core/AbstractCall$CallbackUI$UIHandler.class... processing com/fanwei/jubaosdk/common/core/Call.class... processing com/fanwei/jubaosdk/common/core/Dispatcher.class... processing com/fanwei/jubaosdk/common/core/OnPayResultListener.class... processing com/fanwei/jubaosdk/common/entity/Advertisement.class... processing com/fanwei/jubaosdk/common/entity/OrderEntity.class... processing com/fanwei/jubaosdk/common/entity/PayMethodResponse.class... processing com/fanwei/jubaos<message truncated>
最新发布
07-19
<think>好的,我现在需要解决用户遇到的Unity导出Android项目时出现的错误:“CommandInvokationFailure: Unable to convert classes into dex format”。用户提供了详细的错误日志,显示多个类文件存在InnerClasses属性问题,以及重复添加类的错误,最终导致构建失败。 首先,我需要理解错误的根本原因。根据日志,有几个关键点: 1. **InnerClasses属性警告**:多个类如com.tencent.mm.sdk.b.b和com.testin.agent.a.b缺少EnclosingMethod属性,这通常是因为这些类是用旧版本的编译器生成的,不支持现代.class文件格式。虽然这些是警告,但可能影响后续处理。 2. **重复类错误**:日志中出现多个“already added”错误,例如Lbitter/jnibridge/JNIBridge;和Lcom/unity3d/player/NativeLoader;等类被重复添加。这可能是由于依赖冲突,多个库引入了相同的类。 3. **Unity版本过旧**:用户使用的是Unity 5.3.8,这是一个非常旧的版本(2016年发布),可能不支持较新的Android SDK或Java版本,导致兼容性问题。 接下来,我需要考虑可能的解决方案。根据之前的对话历史,用户已经询问过关于FileProvider配置和Multidex的问题,现在的问题是构建失败,涉及类转换为dex格式的问题。 可能的解决步骤: 1. **更新Unity版本**:建议用户升级到更高版本的Unity,比如2019.4或以上,以获得更好的兼容性和支持。 2. **检查JDK版本**:用户使用的是JDK 1.8,虽然Unity 5.3.8支持JDK 1.8,但可能存在兼容性问题。但考虑到Unity版本老旧,升级Unity可能更有效。 3. **解决重复类冲突**:检查项目中的插件,特别是微信SDK和Testin插件,可能存在与其他库的冲突。需要更新这些插件到最新版本,或者手动移除重复的依赖库。 4. **启用Multidex**:如果方法数超过限制,需要启用Multidex,但用户可能已经尝试过,但需要确认配置是否正确。 5. **清理项目并重新导入插件**:删除旧的插件和缓存,重新导入必要的插件,确保没有重复的类文件。 6. **ProGuard混淆**:使用ProGuard来移除无用的类和方法,减少冲突的可能性。 现在需要将这些思考整理成一个结构化的回答,分步骤说明,并提供相关问题。需要注意用户可能对Unity版本升级有顾虑,比如项目迁移的复杂性,但必须强调必要性。同时,重复类的问题可能需要详细检查插件依赖,用户可能需要指导如何查找和解决依赖冲突。 另外,用户日志中还有“message truncated”,可能表示日志被截断,需要提醒用户检查完整日志是否有更多信息。但根据现有信息,可以推断出上述可能的原因和解决方法。</think>以下是修复 **`Unable to convert classes into dex format`** 的完整指南: --- ### 🔍 **错误原因分析** #### 1. **类重复冲突** - **关键错误**: `already added: Lcom/unity3d/player/NativeLoader;` `already added: Lbitter/jnibridge/JNIBridge;` - **原因**:多个插件或依赖库包含相同类(如 `UnityPlayer`、`JNIBridge`、`ReflectionHelper`)。 - **冲突来源**: - 微信 SDK、Testin 插件与 Unity 内置类重复。 - 第三方插件使用了旧版 `android.support.v4` 或 `androidx` 库。 #### 2. **Java 类版本不兼容** - **警告**: `Ignoring InnerClasses attribute for an anonymous inner class` - **原因**:`com.tencent.mm.sdk.b.b` 和 `com.testin.agent.*` 由旧版编译器生成,缺少 `EnclosingMethod` 属性。 #### 3. **Unity 版本过时** - **问题**:Unity 5.3.8(2016 年发布)内置的 `sdktools.jar` 无法处理现代 Java文件。 --- ### ✅ **修复步骤** #### 1. **清理重复类冲突** - **操作**: 1. **删除重复插件**: - 检查 `Plugins/Android` 目录,移除重复的 JAR/AAR 文件(如 `classes.jar`、`FanweiPlugin_v4.4.jar`)。 2. **使用 `exclude` 排除冲突依赖**: - 在 `build.gradle` 中添加排除规则(适用于自定义构建): ```gradle dependencies { implementation('com.tencent.mm.opensdk:wechat-sdk-android-without-mta:+') { exclude group: 'com.unity3d.player', module: 'UnityPlayer' } } ``` #### 2. **更新插件版本** - **操作**: 1. **升级微信 SDK**: - 从 [微信开放平台](https://open.weixin.qq.com/) 下载最新版 SDK(如 `6.8.0`)。 2. **更新 Testin 插件**: - 从 [Testin 官网](https://www.testin.cn/) 获取兼容 Android 10+ 的最新版本。 #### 3. **升级 Unity 引擎** - **操作**: 1. **备份项目**: - 备份 `Assets/` 和 `ProjectSettings/`。 2. **使用 Unity Hub 升级**: - 安装 Unity 2019.4 LTS 或 2021.3 LTS。 3. **迁移项目**: - 打开 Unity Hub → `Add Existing Project` → 选择项目目录。 #### 4. **启用 ProGuard 混淆** - **操作**: 1. **开启混淆**: - Unity Editor → `Edit > Project Settings > Player Settings` → `Android > Write Ahead Native Debugging = true`。 2. **添加排除规则**: - 在 `Assets/Plugins/Android/proguard-user.txt` 中添加: ```proguard -keep class com.tencent.mm.sdk.** { *; } -keep class com.testin.agent.** { *; } -keep class bitter.jnibridge.** { *; } ``` #### 5. **手动修复类文件(高级)** - **操作**: 1. **使用 Recaf 反编译插件 JAR**: ```bash java -jar Recaf.jar -input FanweiPlugin_v4.4.jar ``` 2. **修复 `InnerClasses` 属性**: - 手动添加 `EnclosingMethod` 属性(需熟悉 Java 字节码)。 3. **重新编译并签名**: - 使用 `javac` 重新编译修改后的类文件。 --- ### 🧪 **完整修复示例** #### 修复前(错误配置): ```bash # Unity 5.3.8 + 微信 SDK 1.8.0 + Testin 插件 4.0.0 Error: Unable to convert classes into dex format. ``` #### 修复后(推荐配置): ```bash # Unity 2021.3 + 微信 SDK 6.8.0 + Testin 插件 5.0.0 Build Success! ``` --- ### 🛠️ **工具辅助检查** 1. **查看完整构建日志**: - 删除 `Temp/` 和 `Library/` 后重新构建,检查 `Editor.log`。 2. **使用 `dexdump` 分析 Dex 文件**: ```bash dexdump -l xml classes.dex > classes.xml ``` 3. **依赖冲突检测**: - 使用 [JarAnalyzer](https://github.com/tnachen/jaranalyzer) 检查重复类: ```bash java -jar jaranalyzer.jar analyze Plugins/Android/ ``` --- ### 📌 **注意事项** - **Android SDK 版本兼容性**: - Unity 2021.3 需使用 Android SDK API 30(Android 11)。 - 确保 `SDK Tools` 已更新: ```bash SDK Manager → Android SDK → 更新至 30.x.x ``` - **JDK 版本匹配**: - Unity 2021.3 需使用 JDK 11(通过 Unity Hub 自动安装)。 --- ### ✅ **最终验证** 1. **清理 Unity 缓存**: - 删除 `Temp/`、`Library/` 和 `UserSettings/`。 2. **重新构建项目**: - Unity → `File > Build Settings > Build`。 3. **安装测试**: - 在 Android 设备上运行应用,确认无 `NoClassDefFoundError`。 ---
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值