com.android.dex.DexIndexOverflowException Java Examples

The following examples show how to use com.android.dex.DexIndexOverflowException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TypeIdsSection.java    From Box with Apache License 2.0 6 votes vote down vote up
/**
 * Writes the portion of the file header that refers to this instance.
 *
 * @param out {@code non-null;} where to write
 */
public void writeHeaderPart(AnnotatedOutput out) {
    throwIfNotPrepared();

    int sz = typeIds.size();
    int offset = (sz == 0) ? 0 : getFileOffset();

    if (sz > DexFormat.MAX_TYPE_IDX + 1) {
        throw new DexIndexOverflowException(
                String.format("Too many type identifiers to fit in one dex file: %1$d; max is %2$d.%n"
                                + "You may try using multi-dex. If multi-dex is enabled then the list of "
                                + "classes for the main dex list is too large.",
                        items().size(), DexFormat.MAX_MEMBER_IDX + 1));
    }

    if (out.annotates()) {
        out.annotate(4, "type_ids_size:   " + Hex.u4(sz));
        out.annotate(4, "type_ids_off:    " + Hex.u4(offset));
    }

    out.writeInt(sz);
    out.writeInt(offset);
}
 
Example #2
Source File: TypeIdsSection.java    From Box with Apache License 2.0 6 votes vote down vote up
/**
 * Writes the portion of the file header that refers to this instance.
 *
 * @param out {@code non-null;} where to write
 */
public void writeHeaderPart(AnnotatedOutput out) {
    throwIfNotPrepared();

    int sz = typeIds.size();
    int offset = (sz == 0) ? 0 : getFileOffset();

    if (sz > DexFormat.MAX_TYPE_IDX + 1) {
        throw new DexIndexOverflowException(
                String.format("Too many type identifiers to fit in one dex file: %1$d; max is %2$d.%n"
                                + "You may try using multi-dex. If multi-dex is enabled then the list of "
                                + "classes for the main dex list is too large.",
                        items().size(), DexFormat.MAX_MEMBER_IDX + 1));
    }

    if (out.annotates()) {
        out.annotate(4, "type_ids_size:   " + Hex.u4(sz));
        out.annotate(4, "type_ids_off:    " + Hex.u4(offset));
    }

    out.writeInt(sz);
    out.writeInt(offset);
}
 
Example #3
Source File: TypeIdsSection.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/**
 * Writes the portion of the file header that refers to this instance.
 *
 * @param out {@code non-null;} where to write
 */
public void writeHeaderPart(AnnotatedOutput out) {
    throwIfNotPrepared();

    int sz = typeIds.size();
    int offset = (sz == 0) ? 0 : getFileOffset();

    if (sz > DexFormat.MAX_TYPE_IDX + 1) {
        throw new DexIndexOverflowException(
                String.format("Too many type identifiers to fit in one dex file: %1$d; max is %2$d.%n"
                                + "You may try using multi-dex. If multi-dex is enabled then the list of "
                                + "classes for the main dex list is too large.",
                        items().size(), DexFormat.MAX_MEMBER_IDX + 1));
    }

    if (out.annotates()) {
        out.annotate(4, "type_ids_size:   " + Hex.u4(sz));
        out.annotate(4, "type_ids_off:    " + Hex.u4(offset));
    }

    out.writeInt(sz);
    out.writeInt(offset);
}
 
Example #4
Source File: TypeIdsSection.java    From buck with Apache License 2.0 6 votes vote down vote up
/**
 * Writes the portion of the file header that refers to this instance.
 *
 * @param out {@code non-null;} where to write
 */
public void writeHeaderPart(AnnotatedOutput out) {
    throwIfNotPrepared();

    int sz = typeIds.size();
    int offset = (sz == 0) ? 0 : getFileOffset();

    if (sz > DexFormat.MAX_TYPE_IDX + 1) {
        throw new DexIndexOverflowException("Too many type references: " + sz +
                "; max is " + (DexFormat.MAX_TYPE_IDX + 1) + ".\n" +
                Main.getTooManyIdsErrorMessage());
    }

    if (out.annotates()) {
        out.annotate(4, "type_ids_size:   " + Hex.u4(sz));
        out.annotate(4, "type_ids_off:    " + Hex.u4(offset));
    }

    out.writeInt(sz);
    out.writeInt(offset);
}
 
Example #5
Source File: MergeTest.java    From buck with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Throwable {

    for (int i = 0; i < NUMBER_OF_TRIES; i++) {
      String fileName1 = args[(int) (Math.random() * args.length)];
      String fileName2 = args[(int) (Math.random() * args.length)];
      try {
        Dex toMerge = new Dex(new File(fileName1));
        Dex toMerge2 = new Dex(new File(fileName2));
        new DexMerger(toMerge, toMerge2, CollisionPolicy.KEEP_FIRST).merge();
      } catch (DexIndexOverflowException e) {
        // ignore index overflow
      } catch (Throwable t) {
        System.err.println(
            "Problem merging those 2 dexes: \"" + fileName1 + "\" and \"" + fileName2 + "\"");
        throw t;
      }
    }
  }
 
Example #6
Source File: MemberIdsSection.java    From Box with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
protected void orderItems() {
    int idx = 0;

    if (items().size() > DexFormat.MAX_MEMBER_IDX + 1) {
        throw new DexIndexOverflowException(getTooManyMembersMessage());
    }

    for (Object i : items()) {
        ((MemberIdItem) i).setIndex(idx);
        idx++;
    }
}
 
Example #7
Source File: MemberIdsSection.java    From Box with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
protected void orderItems() {
    int idx = 0;

    if (items().size() > DexFormat.MAX_MEMBER_IDX + 1) {
        throw new DexIndexOverflowException(getTooManyMembersMessage());
    }

    for (Object i : items()) {
        ((MemberIdItem) i).setIndex(idx);
        idx++;
    }
}
 
Example #8
Source File: MemberIdsSection.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
protected void orderItems() {
    int idx = 0;

    if (items().size() > DexFormat.MAX_MEMBER_IDX + 1) {
        throw new DexIndexOverflowException(getTooManyMembersMessage());
    }

    for (Object i : items()) {
        ((MemberIdItem) i).setIndex(idx);
        idx++;
    }
}
 
Example #9
Source File: MemberIdsSection.java    From buck with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
protected void orderItems() {
    int idx = 0;

    if (items().size() > DexFormat.MAX_MEMBER_IDX + 1) {
        throw new DexIndexOverflowException(getTooManyMembersMessage());
    }

    for (Object i : items()) {
        ((MemberIdItem) i).setIndex(idx);
        idx++;
    }
}
 
Example #10
Source File: InstructionTransformer.java    From Box with Apache License 2.0 4 votes vote down vote up
private static void jumboCheck(boolean isJumbo, int newIndex) {
    if (!isJumbo && (newIndex > 0xffff)) {
        throw new DexIndexOverflowException("Cannot merge new index " + newIndex +
                               " into a non-jumbo instruction!");
    }
}
 
Example #11
Source File: InstructionTransformer.java    From Box with Apache License 2.0 4 votes vote down vote up
private static void jumboCheck(boolean isJumbo, int newIndex) {
    if (!isJumbo && (newIndex > 0xffff)) {
        throw new DexIndexOverflowException("Cannot merge new index " + newIndex +
                               " into a non-jumbo instruction!");
    }
}
 
Example #12
Source File: InstructionTransformer.java    From buck with Apache License 2.0 4 votes vote down vote up
private static void jumboCheck(boolean isJumbo, int newIndex) {
    if (!isJumbo && (newIndex > 0xffff)) {
        throw new DexIndexOverflowException("Cannot merge new index " + newIndex +
                               " into a non-jumbo instruction!");
    }
}