Error: Could not find EOCD, after adding "splits" in Android
Asked Answered
S

4

10

I am using the following splits code in my gradle to reduce APK size:

splits {
        abi {
            // Enable ABI split

        enable true

        // Clear list of ABIs
        reset()

        // Specify each architecture currently supported by the Video SDK
        include "armeabi-v7a", "arm64-v8a", "x86", "x86_64"

        // Specify that we do not want an additional universal SDK
        universalApk false
    }
}

When I run the app, the APK is generated fine, with reduced size and runs on Emulator.

But when I try to build APK file from Build > Build bundles/apks like enter image description here

I get this error:

Execution failed for task ':app:packageAbcDebug'.
> A failure occurred while executing com.android.build.gradle.tasks.PackageAndroidArtifact$IncrementalSplitterRunnable
   > Could not find EOCD in '....apk'

Possible solution:
 - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html

I only wanted to exclude "x86" architectures, to reduce the APK size and need to send the APK to my client. How do I fix this?

Skepticism answered 6/11, 2020 at 11:24 Comment(3)
have you tried this #20674125Vertievertiginous
@Vertievertiginous yes just tried. getting same errorSkepticism
Did you try to clean - delete .gradle from project - invalidate cache and restart - rebuild?Irregularity
H
4

May be its late but here is the solution with reason for it to work.

Since we are using splits to create apks for each architecture build system needs a different name for each apk being generated.

Best solution is to provide a dynamic way of generating apk names.

Just go to app level build.gradle file Add rules for release/debug build variants in buildTypes block inside android block like this

buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            applicationVariants.all { variant ->
                variant.outputs.all { output ->
                    project.ext { appName = 'YourApkName' }
                    outputFileName = "${appName}-${output.getFilter(OutputFile.ABI)}-${variant.name}-${variant.versionName}.apk"
                }
            }
        }
    }

Explaination : Here the apk name is appended by the ABI name that helps build system identify the apks for each architectures.

Hither answered 23/2, 2021 at 13:21 Comment(0)
P
5

I was running into a similar issue during my build process, though I wasn't enabling split. Take it for what you will.

After digging through the source kit for PackageAndroidArtifact and other sources in Android, I discovered "EOCD" means "End Of Central Directory". That is, it's related to the end marker of the zip file that gets built when building your output. (The link to the comments in Android's source kit.)

In my own case, I discovered that even though I'm asking Android Studio to do a complete clean of my build directory, it's leaving the app-debug.apk build artifact file. (For reasons, I'm trying to package the debug version of our APK for internal testing.) And somehow that file got corrupted, which completely confuses the build process.

The resolution was to manually delete the apk file prior to running the build process. (In my case, it was found in my build's app/debug directory, next to the app/build directory.)

G'figure...

Philanthropy answered 12/2, 2021 at 19:10 Comment(2)
Thanks for ur attempt. I deleted apk from build/debug, but i get this exception now: Execution failed for task ':app:package..Debug'. > A failure occurred while executing com.android.build.gradle.tasks.PackageAndroidArtifact$IncrementalSplitterRunnable > java.io.IOException: Failed to create '...apk'Skepticism
This worked for me. My previous build attempt had crashed when the system ran out of space, so the corrupted .apk in output kept causing the error. Deleting the build folder did the trick. Thanks!Melisent
H
4

May be its late but here is the solution with reason for it to work.

Since we are using splits to create apks for each architecture build system needs a different name for each apk being generated.

Best solution is to provide a dynamic way of generating apk names.

Just go to app level build.gradle file Add rules for release/debug build variants in buildTypes block inside android block like this

buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            applicationVariants.all { variant ->
                variant.outputs.all { output ->
                    project.ext { appName = 'YourApkName' }
                    outputFileName = "${appName}-${output.getFilter(OutputFile.ABI)}-${variant.name}-${variant.versionName}.apk"
                }
            }
        }
    }

Explaination : Here the apk name is appended by the ABI name that helps build system identify the apks for each architectures.

Hither answered 23/2, 2021 at 13:21 Comment(0)
G
0

If you develop flutter app you should open terminal and type:

flutter clean && flutter pub get
Grader answered 11/6, 2024 at 6:57 Comment(0)
L
-1

You can also use Android Size Analyze to identify sizes and reduces the apk size.

In order to understand which files are actually taking up more space in the application, use the Android Size Analyzer plugin inside Android Studio. For installing the plugin

Select File > Settings (or on Mac, Android Studio > Preferences.) Select the Plugins section in the left panel. Click the Marketplace tab. Search for the “Android Size Analyzer” plugin. Click the Install button for the analyzer plugin.

enter image description here

Restart the IDE after installing the plugin. Now, to analyze the application, go to Analyze > Analyze App Size from the menu bar.

Linlithgow answered 5/3, 2021 at 7:35 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.