在Java项目中使用的android.jar - RuntimeException的存根? [英] Using android.jar in Java project - RuntimeException Stub?

查看:229
本文介绍了在Java项目中使用的android.jar - RuntimeException的存根?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图包含的android.jar 到Java项目中,从构建路径中删除JRE 并运行此code。它抛出运行时异常。为什么呢?

I tried to include android.jar into Java project, remove JRE from Build Path and run this code. It throws Runtime exception. Why?

Exception in thread "main" java.lang.RuntimeException: Stub!
    at android.content.ContentValues.<init>(ContentValues.java:5)
    at JarTest.main(JarTest.java:5)

public class JarTest {
    public static void main(final String[] args) {
        final ContentValues values = new ContentValues();
        values.put("test", "test");
        System.out.println(values);
    }
}

为什么只有在Android的环境中使用ContentValues​​?

Why is ContentValues used only in Android environment?

推荐答案

在SDK中的android.jar只包含SDK类,没有被发现的设备(或仿真器),真正实现的存根实现。罐子只是提供了一流的元数据,以便您的应用程序引用SDK类将建立正确的。

The android.jar in the SDK only contains stub implementations of the SDK classes, not the real implementations that are found on the devices (or emulator). The jar just provides the class metadata so that your apps that reference the SDK classes will build properly.

您不能创建引用,将Android设备之外运行的android.jar任何项目。

You can't create any project that references the android.jar that will run outside an Android device.

这篇关于在Java项目中使用的android.jar - RuntimeException的存根?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆