开发者

android.graphics.Point: all methods are stubs

I'm trying to use the Point class from android.graphics, but it appears that all the methods are stubs. For example, the 开发者_如何学JAVAline

Point p = new Point(1, 1);

causes java.lang.RuntimeException: Stub!. If I look at the bytecode for Point, I see a bunch of stubbed methods, e.g:

  // Method descriptor #17 (II)V
  // Stack: 3, Locals: 3
  public Point(int x, int y);
     0  aload_0 [this]
     1  invokespecial java.lang.Object() [1]
     4  new java.lang.RuntimeException [2]
     7  dup
     8  ldc <String "Stub!"> [3]
    10  invokespecial java.lang.RuntimeException(java.lang.String) [4]
    13  athrow
      Line numbers:
        [pc: 0, line: 5]
      Local variable table:
        [pc: 0, pc: 14] local: this index: 0 type: android.graphics.Point
        [pc: 0, pc: 14] local: x index: 1 type: int
        [pc: 0, pc: 14] local: y index: 2 type: int

What's the deal here? Surely they didn't ship a class that's 100% stubs.


I am guessing that you are looking at android.jar. That JAR file is mostly stubs. The real implementation is on the device.

For a properly configured Android project, running in an emulator or on a device, the constructor for android.graphics.Point and everything else will use the real implementation. You only use android.jar as a compilation target, and it should not be included in the resulting APK file.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜