ZipException when converting to dex with Ant, in eclipse it works fine

I have a project that builds ok in Eclipse, but throws a ZipException when executing "ant debug". The conclusion is as follows: (excluded paths and project name)

-dex: [dex] Converting compiled files and external libraries into /home/.../Android/[folder]/bin/classes.dex... [dx] [dx] UNEXPECTED TOP-LEVEL EXCEPTION: [dx] java.util.zip.ZipException: error in opening zip file [dx] at java.util.zip.ZipFile.open(Native Method) [dx] at java.util.zip.ZipFile.<init>(ZipFile.java:131) [dx] at java.util.zip.ZipFile.<init>(ZipFile.java:148) [dx] at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:206) [dx] at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:131) [dx] at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:109) [dx] at com.android.dx.command.dexer.Main.processOne(Main.java:418) [dx] at com.android.dx.command.dexer.Main.processAllFiles(Main.java:329) [dx] at com.android.dx.command.dexer.Main.run(Main.java:206) [dx] at com.android.dx.command.dexer.Main.main(Main.java:174) [dx] at com.android.dx.command.Main.main(Main.java:95) [dx] 1 error; aborting BUILD FAILED /home/.../android-sdk-linux_x86/tools/ant/build.xml:818: The following error occurred while executing this line: /home/.../android-sdk-linux_x86/tools/ant/build.xml:820: The following error occurred while executing this line: /home/.../android-sdk-linux_x86/tools/ant/build.xml:832: The following error occurred while executing this line: /home/.../android-sdk-linux_x86/tools/ant/build.xml:278: null returned: 1 

This project refers to a library project that refers to another library project. So

Project A → Project B → Project C

For me, the weird part is that installing from eclipse works fine, but I need to build a project from Ant.

I searched for unanswered answers. Related questions in SO that didn't help

How to fix this ZipException when compiling a Jenkins Android project?

Configure ant to run unit tests. Where should the libraries be? How to set up class path? avoiding ZipException

+6
source share
2 answers

I was getting the same error when dexing. I found that a damaged .jar file in the included android library project was causing this problem.

Fixing a damaged .jar file in an included Android library project has been fixed.

Hope this helps someone! = D

+1
source

I had the exact same problem in my project. I found that running ant with the debug flag '-d' resets the information needed to diagnose the problem. ant will download the exact dx command to the console and looks something like this:

 Execute:Java13CommandLauncher: Executing '/Users/cliff/android-sdk-macosx/platform-tools/dx' with arguments: '--dex' '--output' '/Users/cliff/Src/myproject/myproject-app/bin/classes.dex' '/Users/cliff/Src/myproject/myproject-app/bin/classes' '/Users/cliff/Src/myproject/myproject-config/bin/classes.jar' 

In my case, one of the dependent projects (myproject-config) was not built, so myproject-config / bin / classes.jar was missing. I went into the myproject-config / folder, executed "ant debug", then came back and was able to successfully create the project

+1
source

Source: https://habr.com/ru/post/911774/


All Articles