dex fails placing debug info

by Michael Newton » Tue, 20 Apr 2010 13:08:24 GMT


Sponsored Links
  hope someone can offer some insight on this problem. My build was
failing with a dex error. After I turned verbosity up to debug I got
the following:

Buildfile: build.xml
[setup] Project Target: Android 1.6
[setup] API level: 4
[setup] WARNING: No minSdkVersion value set. Application will
install on all Android versions.

(snip)

-dex:
[echo] Converting compiled files and external libraries into /
Users/newton/scratch/bin/classes.dex...
[echo]
[apply]
[apply] trouble writing output:
[apply] com.android.dx.util.ExceptionWithContext: shouldn't happen
[apply] at
com.android.dx.util.ExceptionWithContext.withContext(ExceptionWithContext.java:
46)
[apply] at
com.android.dx.dex.file.DebugInfoItem.place0(DebugInfoItem.java:79)
[apply] at
com.android.dx.dex.file.OffsettedItem.place(OffsettedItem.java:241)
[apply] at
com.android.dx.dex.file.MixedItemSection.placeItems(MixedItemSection.java:
312)
[apply] at com.android.dx.dex.file.DexFile.toDex0(DexFile.java:
525)
[apply] at com.android.dx.dex.file.DexFile.toDex(DexFile.java:
196)
[apply] at com.android.dx.command.dexer.Main.writeDex(Main.java:
406)
[apply] at com.android.dx.command.dexer.Main.run(Main.java:143)
[apply] at com.android.dx.command.dexer.Main.main(Main.java:120)
[apply] at com.android.dx.command.Main.main(Main.java:87)
[apply] Caused by: java.lang.RuntimeException: shouldn't happen
[apply] at
com.android.dx.dex.file.DebugInfoEncoder.emitLocalsAtAddress(DebugInfoEncoder.java:
314)
[apply] at
com.android.dx.dex.file.DebugInfoEncoder.convert0(DebugInfoEncoder.java:
220)
[apply] at
com.android.dx.dex.file.DebugInfoEncoder.convert(DebugInfoEncoder.java:
155)
[apply] at
com.android.dx.dex.file.DebugInfoItem.encode0(DebugInfoItem.java:188)
[apply] at
com.android.dx.dex.file.DebugInfoItem.encode(DebugInfoItem.java:144)
[apply] at
com.android.dx.dex.file.DebugInfoItem.place0(DebugInfoItem.java:76)
[apply] ... 8 more
[apply] ...while placing debug info for
com.sshtools.j2ssh.transport.publickey.SshPublicKey.getFingerprint:
()Ljava/lang/String;
[apply] ...while placing
com.android.dx.dex.file.debuginfoi...@55bbe9aa
[apply] ...while writing section 10
[apply]


Here is the source of the class where it is failing to place debug
info:
package com.sshtools.j2ssh.transport.publickey;

import com.sshtools.j2ssh.util.Hash;
import java.security.NoSuchAlgorithmException;

public abstract class SshPublicKey {

public abstract String getAlgorithmName();

public abstract int getBitLength();

public abstract byte[] getEncoded();

public String getFingerprint() {
try {
Hash md5 = new Hash("MD5");
md5.putBytes(getEncoded());

byte[] digest = md5.doFinal();
int bits = getBitLength();
bits = (((bits % 8) != 0) ? (bits += (bits % 8)) : bits);

String ret = String.valueOf(bits);

for (int i = 0; i < digest.length; i++) {
ret += (((i == 0) ? ":" : "") + " " +
Integer.toHexString(digest[i] & 0xFF));
}

return ret;
} catch (NoSuchAlgorithmException nsae) {
return null;
}
}

publ



dex fails placing debug info

by Dan Bornstein » Wed, 21 Apr 2010 07:33:11 GMT


 On Mon, Apr 19, 2010 at 4:26 PM, Michael Newton



This looks like a bug in dx (the tool that turns .class files into
.dex files). Since compilers can produce different output for the same
source, it's much more interesting to see the compiled .class file
that is being processed.

Please file a bug by following the directions at
< http://source.android.com/report-bugs> ;. Again, in this case,
attaching the .class file that fails is much better than just
including the source text.

As a workaround, you might try compiling without debugging info (that
is, removing "-g" from your javac command line). You might also try
splitting the failing method (getFingerPrint) in various places (e.g.,
put the try body in a separate method), as that will change the
emitted code and has a good chance of avoiding the problem.

Cheers,

-dan

--


Sponsored Links


dex fails placing debug info

by Michael Newton » Wed, 21 Apr 2010 23:26:17 GMT


 I fixed this - this code is where the problem is:

            int bits = getBitLength();
            bits = (((bits % 8) != 0) ? (bits += (bits % 8)) : bits);

When I assigned the result of the expression in the second line to a
new variable instead of back to int bits, the problem went away.

The clue was in  http://code.google.com/p/android/issues/detail?id=2868 
- may be the same kind of issue.

M.




>



dex fails placing debug info

by fadden » Fri, 23 Apr 2010 04:10:41 GMT


 



Can you attach the failing and non-failing .class files to that bug?

--



Other Threads

1. Source Code for HelloGoogleMaps Tutorial

Hello Developers,

I am new at Android development and I work through the tutorials.
The HelloGoogleMaps Tutorial

http://developer.android.com/resources/tutorials/views/hello-mapview.html

does not work on my phone. The map is shown but not the marker. So I
want to ask if someone has a working source code of the tutorial?
I can not understand that Google does not provide!

Thank you in advance.

-- 

2. onDraw not getting called for a custom view derived from view in layout.

Hello All,

I have a custom view
.........

package com.yasir.canvasTest;


import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Align;
import android.util.Log;
import android.view.View;


public class GraphView extends View {

    private static final String TAG = "GraphView";
    public static boolean BAR = true;
    public static boolean LINE = false;

    private Paint paint;
    private float[] values;
    private String[] horlabels;
    private String[] verlabels;
    private String title;
    private boolean type;
    public Canvas tmpCanvas = null;

    public GraphView(Context context, float[] values, String title, String[]
horlabels, String[] verlabels) {
        super(context);
        //setScrollContainer(true);
        Log.v(TAG,"On GraphView==>");




        paint = new Paint();

        setWillNotDraw(false);
        requestLayout();
        invalidate();
    }

    @Override
    protected void onDraw(Canvas canvas) {




        Log.v(TAG,"<==On Draw");

/// drawing code here
        invalidate();
    }

    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        Log.v(TAG,"On onMeasure==>");
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);

        int parentWidth = MeasureSpec.getSize(widthMeasureSpec);
        int parentHeight = MeasureSpec.getSize(heightMeasureSpec);
        setMeasuredDimension(
                parentWidth * 2, parentHeight);
    }

}
...............
Activity: onCreate
...............
    setContentView(R.layout.horscroll);



        HorizontalScrollView hsView = (HorizontalScrollView)
findViewById(R.id.hzsv);

        LinearLayout ll = (LinearLayout) findViewById(R.id.linearParent);
        ll.removeAllViews();


        // create custom view and add to laywout
        GraphView graphView = new GraphView(this, values,
"GraphViewDemo",horlabels, verlabels, GraphView.LINE);


        hsView.requestLayout();
        hsView.setWillNotDraw(false);

        ll.requestLayout();
        ll.setWillNotDraw(false);
        ll.addView(graphView);

.....................
Xml
....................
<?xml version="1.0" encoding="utf-8"?>

<HorizontalScrollView
 android:id="@+id/hzsv"
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout android:id="@+id/linearParent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"></LinearLayout>
 </HorizontalScrollView>
..................


Regards,
Yasir Perwez

-- 

3. Maven and Emma

4. problem for send sms

5. Monkeyrunner extension library

6. I'm trying to build Library(libwebcore.so) that works on emulator and target(Nexus s).

7. Custom view and horizontal scrolling