David Demmers
David Demmers

Reputation: 5

java: duplicate class: org.apache.cordova.BuildConfig , while generating signed apk android studio ionic/cordova project

Error:(6, 14) java: duplicate class: org.apache.cordova.BuildConfig

This error message comes up when i try to generate a signed apk for a beta version of an already once submitted app

but while compiling there are several duplicate classes of buildConfig.

if you know how to fix it with android studio or know how to propperly sign a apk with ionic/cordova pls do tell

-David

EDIT:

package org.apache.cordova;

public final class BuildConfig {
  public static final boolean DEBUG = false;
  public static final String APPLICATION_ID = "org.apache.cordova";
  public static final String BUILD_TYPE = "release";
  public static final String FLAVOR = "";
  public static final int VERSION_CODE = 1;
  public static final String VERSION_NAME = "1.0";
}

Upvotes: 0

Views: 1078

Answers (1)

Orvenito
Orvenito

Reputation: 437

everything you need to know in publishing your app is in the documentation of Ionic: Ionic Documentation

if you have any questions regarding this. just comment.

EDIT

To generate a release build for Android, we can use the following cordova cli command:

$ ionic cordova build --release android

generate private key using the keytool command that comes with the JDK.

$ keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000

sign the unsigned APK, run the jarsigner tool which is also included in the JDK:

$ jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore HelloWorld-release-unsigned.apk alias_name

This signs the apk in place. Finally, we need to run the zip align tool to optimize the APK. The zipalign tool can be found in /path/to/Android/sdk/build-tools/VERSION/zipalign

$ zipalign -v 4 HelloWorld-release-unsigned.apk HelloWorld.apk

Upvotes: 1

Related Questions