Duplicated Class error

I did a plugin for UE4.26 that works ok. Now I am working on UE4.27 and I try to use the same plugin but it fails when I try to launch de game on the device.

It claims I have a duplicated class. Is there a way to disable it?
Why U4.26 goes ok and 4.27 fails with that error?

Any help?

FAILURE: Build failed with an exception.
LogPlayLevel: * What went wrong:
LogPlayLevel: Execution failed for task ':app:checkDebugDuplicateClasses'.
LogPlayLevel: > 1 exception was raised by workers:
LogPlayLevel:   java.lang.RuntimeException: Duplicate class androidx.localbroadcastmanager.content.LocalBroadcastManager found in modules jetified-classes.jar (classes.jar) and localbroadcastmanager-1.0.0-runtime.jar (androidx.localbroadcastmanager:localbroadcastmanager:1.0.0)
LogPlayLevel:   Duplicate class androidx.localbroadcastmanager.content.LocalBroadcastManager$1 found in modules jetified-classes.jar (classes.jar) and localbroadcastmanager-1.0.0-runtime.jar (androidx.localbroadcastmanager:localbroadcastmanager:1.0.0)
LogPlayLevel:   Duplicate class androidx.localbroadcastmanager.content.LocalBroadcastManager$BroadcastRecord found in modules jetified-classes.jar (classes.jar) and localbroadcastmanager-1.0.0-runtime.jar (androidx.localbroadcastmanager:localbroadcastmanager:1.0.0)
LogPlayLevel:   Duplicate class androidx.localbroadcastmanager.content.LocalBroadcastManager$ReceiverRecord found in modules jetified-classes.jar (classes.jar) and localbroadcastmanager-1.0.0-runtime.jar (androidx.localbroadcastmanager:localbroadcastmanager:1.0.0)

Note: everything builds ok when I package the plugin and then I compile in Rider:

image

But it screws if I try to launch it:

The jar it names it’s generated in user/.gradle folder when trying to launch…even deleting it will regenerate and give same error.

found some crazy folder inside a jar that was not needed.
Anyway 4.26 didnt cared and worked.

sigh…

1 Like

Greetings @eldany.uy

Were you able to resolve the error?

Hi @FrostyJas . Yes I solved it.

In my case I had a folder inside a .jar that UE4.27 didnt liked (found as duplicated classes).
I fixed it just extracting the .jar contents (its a zip), removing that folder and compressing again as .jar. I could not find the other ‘duplicated’ files in my project but that fixed my problem.

It’s strange UE4.26 don’t give that error and compiles ok.

just in case this androidx folder with those 4 files was the source of the problems:

image

Best,
Dany

Hi @FrostyJas .

Yesterday I thought I had solved it but no :frowning: What I did solved the LAUNCH
issue where it failed stating a duplicated class was there.

Now I want to make a distribution APK and I get this error :frowning:

I dont have this issues on 4.26,this happens on 4.27 only.

UATHelper: Packaging (Android (ETC2)): > Task :app:minifyReleaseWithR8 FAILED
UATHelper: Packaging (Android (ETC2)): C:\Users\eldan\.gradle\caches\transforms-2\files-2.1\9447db4656f1da834de603aa9f9ca870\jetified-play-services-base-11.8.0\proguard.txt:3:89-97: R8: The field name "<fields>" is used in a field rule. The characters in this field name are legal for the JVM, but unlikely to originate from a source language. Maybe this is no
t the rule you are looking for.
UATHelper: Packaging (Android (ETC2)): C:\Users\eldan\.gradle\caches\transforms-2\files-2.1\14e9686d257f7e42209d8cba951687d6\jetified-r-classes.jar: R8: Type androidx.localbroadcastmanager.R is defined multiple times: C:\Users\eldan\.gradle\caches\transforms-2\files-2.1\14e9686d257f7e42209d8cba951687d6\jetified-r-classes.jar:androidx/localbroadcastmanager/R.
class, Z:\app\build\intermediates\compile_and_runtime_not_namespaced_r_class_jar\release\R.jar:androidx/localbroadcastmanager/R.class
UATHelper: Packaging (Android (ETC2)): > Task :app:mergeReleaseNativeLibs
UATHelper: Packaging (Android (ETC2)): FAILURE: Build failed with an exception.
UATHelper: Packaging (Android (ETC2)): * What went wrong:
UATHelper: Packaging (Android (ETC2)): Execution failed for task ':app:minifyReleaseWithR8'.
UATHelper: Packaging (Android (ETC2)): > com.android.tools.r8.CompilationFailedException: Compilation failed to complete
UATHelper: Packaging (Android (ETC2)): * Try:
UATHelper: Packaging (Android (ETC2)): Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
UATHelper: Packaging (Android (ETC2)): * Get more help at https://help.gradle.org
UATHelper: Packaging (Android (ETC2)): 61 actionable tasks: 61 executed
UATHelper: Packaging (Android (ETC2)): BUILD FAILED in 59s
UATHelper: Packaging (Android (ETC2)): ERROR: cmd.exe failed with args /c "F:\00 ULTRATON\TGRacer\Intermediate\Android\armv7\gradle\rungradle.bat" :app:assembleRelease
UATHelper: Packaging (Android (ETC2)):        (see C:\Users\eldan\AppData\Roaming\Unreal Engine\AutomationTool\Logs\C+Program+Files+Epic+Games+UE_4.27Chaos\Log.txt for full exception trace)
UATHelper: Packaging (Android (ETC2)): AutomationTool exiting with ExitCode=1 (Error_Unknown)
UATHelper: Packaging (Android (ETC2)): BUILD FAILED
PackagingResults: Error: Unknown Error

Any clue?

this is from the log.txt

UEDeployAndroid.FilterStdOutErr: BUILD FAILED in 59s
Log.WriteException: ==============================================================================
Log.WriteException: ERROR: cmd.exe failed with args /c "F:\00 ULTRATON\TGRacer\Intermediate\Android\armv7\gradle\rungradle.bat" :app:assembleRelease
Log.WriteException:        (see C:\Users\eldan\AppData\Roaming\Unreal Engine\AutomationTool\Logs\C+Program+Files+Epic+Games+UE_4.27Chaos\Log.txt for full exception trace)
Log.WriteException: 
Log.WriteException: BuildException: cmd.exe failed with args /c "F:\00 ULTRATON\TGRacer\Intermediate\Android\armv7\gradle\rungradle.bat" :app:assembleRelease
Log.WriteException:    at UnrealBuildTool.UEDeployAndroid.RunCommandLineProgramWithExceptionAndFiltering(String WorkingDirectory, String Command, String Params, String OverrideDesc, Boolean bUseShellExecute) in D:\Build\++UE4\Sync\Engine\Source\Programs\UnrealBuildTool\Platform\Android\UEDeployAndroid.cs:line 1740
Log.WriteException:    at UnrealBuildTool.UEDeployAndroid.MakeApk(AndroidToolChain ToolChain, String ProjectName, TargetType InTargetType, String ProjectDirectory, String OutputPath, String EngineDirectory, Boolean bForDistribution, String CookFlavor, UnrealTargetConfiguration Configuration, Boolean bMakeSeparateApks, Boolean bIncrementalPackage, Boolean bDisallowPackagingDataInApk, Boolean bDisallowExternalFilesDir, Boolean bSkipGradleBuild) in D:\Build\++UE4\Sync\Engine\Source\Programs\UnrealBuildTool\Platform\Android\UEDeployAndroid.cs:line 4210
Log.WriteException:    at UnrealBuildTool.UEDeployAndroid.PrepForUATPackageOrDeploy(FileReference ProjectFile, String ProjectName, DirectoryReference ProjectDirectory, String ExecutablePath, String EngineDirectory, Boolean bForDistribution, String CookFlavor, UnrealTargetConfiguration Configuration, Boolean bIsDataDeploy, Boolean bSkipGradleBuild) in D:\Build\++UE4\Sync\Engine\Source\Programs\UnrealBuildTool\Platform\Android\UEDeployAndroid.cs:line 4801
Log.WriteException:    at AndroidPlatform.Package(ProjectParams Params, DeploymentContext SC, Int32 WorkingCL) in D:\Build\++UE4\Sync\Engine\Source\Programs\AutomationTool\Android\AndroidPlatform.Automation.cs:line 713
Log.WriteException:    at Project.Package(ProjectParams Params, Int32 WorkingCL) in D:\Build\++UE4\Sync\Engine\Source\Programs\AutomationTool\Scripts\PackageCommand.Automation.cs:line 35
Log.WriteException:    at BuildCookRun.DoBuildCookRun(ProjectParams Params) in D:\Build\++UE4\Sync\Engine\Source\Programs\AutomationTool\Scripts\BuildCookRun.Automation.cs:line 217
Log.WriteException:    at BuildCookRun.ExecuteBuild() in D:\Build\++UE4\Sync\Engine\Source\Programs\AutomationTool\Scripts\BuildCookRun.Automation.cs:line 39
Log.WriteException:    at AutomationTool.BuildCommand.Execute() in D:\Build\++UE4\Sync\Engine\Source\Programs\AutomationTool\AutomationUtils\BuildCommand.cs:line 263
Log.WriteException:    at AutomationTool.Automation.Execute(List`1 CommandsToExecute, Dictionary`2 Commands) in D:\Build\++UE4\Sync\Engine\Source\Programs\AutomationTool\AutomationUtils\Automation.cs:line 547
Log.WriteException:    at AutomationTool.Automation.Process(String[] Arguments, StartupTraceListener StartupListener) in D:\Build\++UE4\Sync\Engine\Source\Programs\AutomationTool\AutomationUtils\Automation.cs:line 511
Log.WriteException:    at AutomationTool.Program.MainProc(String[] Arguments, StartupTraceListener StartupListener) in D:\Build\++UE4\Sync\Engine\Source\Programs\AutomationTool\Program.cs:line 175
Log.WriteException:    at AutomationTool.Program.<>c__DisplayClass1_0.<Main>b__2() in D:\Build\++UE4\Sync\Engine\Source\Programs\AutomationTool\Program.cs:line 87
Log.WriteException:    at AutomationTool.InternalUtils.RunSingleInstance(Func`1 Main) in D:\Build\++UE4\Sync\Engine\Source\Programs\AutomationTool\AutomationUtils\Utils.cs:line 739
Log.WriteException:    at AutomationTool.Program.Main(String[] Arguments) in D:\Build\++UE4\Sync\Engine\Source\Programs\AutomationTool\Program.cs:line 87
Log.WriteException: ==============================================================================
Program.Main: AutomationTool exiting with ExitCode=1 (Error_Unknown)

Hello @eldany.uy
Did you find any solution to this duplicate classes problem?

yes

androidx.localbroadcastmanager.R

I had this inside more than one .jar file I just decompiled it, removed from one of the jars, recompiled again and the problem was solved.

Where were these .jar files located? In the .gradle folder for users? Because deleting from there did not solve my problem

a custom java library I had to use…It was specific for my project

project\Plugins<custom plugin>\Source\ThirdParty\repository