Build Failed ionic v3

I am getting error when i run ionic cordova build android --release

BUILD FAILED

Total time: 23.22 secs
Error: /Users/DOTMAN/Documents/ionic/Affinity-mobile/platforms/android/gradlew: Command failed with exit code 1 Error output:
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Dex: Error converting bytecode to dex:
Cause: Dex cannot parse version 52 byte code.
This is caused by library dependencies that have been compiled using Java 8 or above.
If you are using the ‘java’ gradle plugin in a library submodule add
targetCompatibility = ‘1.7’
sourceCompatibility = ‘1.7’
to that submodule’s build.gradle file.
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.RuntimeException: Exception parsing classes
at com.android.dx.command.dexer.Main.processClass(Main.java:775)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:741)
at com.android.dx.command.dexer.Main.access$1200(Main.java:88)
at com.android.dx.command.dexer.Main$FileBytesConsumer.processFileBytes(Main.java:1683)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:695)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:592)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:321)
at com.android.dx.command.dexer.Main.run(Main.java:292)
at com.android.builder.internal.compiler.DexWrapper.run(DexWrapper.java:54)
at com.android.builder.core.DexByteCodeConverter.lambda$dexInProcess$0(DexByteCodeConverter.java:173)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000)
at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:476)
at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
at com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)
at com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)
at com.android.dx.command.dexer.Main.parseClass(Main.java:787)
at com.android.dx.command.dexer.Main.access$1600(Main.java:88)
at com.android.dx.command.dexer.Main$ClassParserTask.call(Main.java:1722)
at com.android.dx.command.dexer.Main.processClass(Main.java:773)
… 16 more

1 error; aborting

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:transformClassesWithDexForRelease’.

com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Return code 1 for dex process

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

[ERROR] An error occurred while running cordova build android --release (exit
code 1).

1 Like

@mhartington please i need help to this

What is your current version of everything listed when you run
ionic info
I’m getting the same error and mine is configured like
Ionic:

ionic (Ionic CLI) : 4.10.2 (C:\Users\slick\AppData\Roaming\npm\node_modules\ionic)
Ionic Framework : ionic-angular 3.9.2
@ionic/app-scripts : 3.2.1

Cordova:

cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
Cordova Platforms : android 6.2.3, browser 5.0.4
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 2.3.1, (and 17 other plugins)

System:

NodeJS : v8.11.2 (C:\Program Files\nodejs\node.exe)
npm : 5.6.0
OS : Windows 10

Never mind I have solved the issue. Thanks for the concern

Hello,
could you give the solution that you used to solve your problem so that if other finds it in the same situation they will be able to repair.

thank you :wink:

2 Likes

You are right… i will do that.

@dotman any chance you can post what you did to fix this? I’ve tried multiple “fixes” from other forums but no luck.

This is the fix to the issue open your build.gradle file and add the line below inside defaultConfig

defaultConfig {
multiDexEnabled true
}

And open project.properties file and check if you have the line below there

cordova.system.library.4=com.squareup.okhttp3:okhttp:3+

Then change it to this

cordova.system.library.4=com.squareup.okhttp3:okhttp:3.12.1

Save and run ionic cordova build android again. I hope it works for you

6 Likes

Thank you! That fixed the build issue :slight_smile:

You are welcome…please mark it as a solution

thank you @dotman :+1:

Thanks,
you saved my day.

1 Like

Glad it fixed your issue too

Thank u so much @dotman I’ve lost about 10 hours on this issue.

You’re welcome…Have a good day

where i can find project.properties

Inside platforms/android folder

Thank you very much!! :clap: :clap: :+1: :+1: