1

我曾多次尝试获取 Sony Small apps SDK Sample 项目,但无法正常工作:

每次我使用它时,我都会收到错误:

06-02 10:40:13.358: E/AndroidRuntime(5903): java.lang.IllegalAccessError: 预验证类中的类引用解析为意外实现

我已经尝试从他们的网站以及 sdk 管理器重新下载它,它似乎有同样的问题。任何人都能让它工作吗?

示例项目在这里:https ://dl.dropboxusercontent.com/u/2690965/SmallAppSample.zip

这是主要的应用程序类:

public class MainApplication extends SmallApplication {

    @Override
    public void onCreate() {
        super.onCreate();

        /* Set the content of the application */
        setContentView(R.layout.main);

        /*
         * Set the content displayed when the application is minimized.
         * Calling this method is optional. If not called, application icon is displayed.
         */
        setMinimizedView(R.layout.minimized);

        /* Set the title of the application to be displayed in the titlebar */
        setTitle(R.string.app_name);

        SmallAppWindow.Attributes attr = getWindow().getAttributes();

        /* Set the requested width of the application */
        attr.width = getResources().getDimensionPixelSize(R.dimen.width);
        /* Set the requested height of the application */
        attr.height = getResources().getDimensionPixelSize(R.dimen.height);

        /*
         * Set the minimum width of the application, if it's resizable.
         *
         * If you don't have strong intention to specify minimum window size,
         * it is preferable not to set minimum window size.
         * If you still want to specify the minimum size, set as small value as possible
         * to make your application work properly on the devices with small screens.
         */
//      attr.minWidth = getResources().getDimensionPixelSize(R.dimen.min_width);
        /* Set the minimum height of the application, if it's resizable */
//      attr.minHeight = getResources().getDimensionPixelSize(R.dimen.min_height);

        /* Use this flag to make the application window resizable */
        attr.flags |= SmallAppWindow.Attributes.FLAG_RESIZABLE;
        /* Use this flag to remove the titlebar from the window */
//      attr.flags |= SmallAppWindow.Attributes.FLAG_NO_TITLEBAR;
        /* Use this flag to enable hardware accelerated rendering */
//      attr.flags |= SmallAppWindow.Attributes.FLAG_HARDWARE_ACCELERATED;

        /* Set the window attributes to apply the changes above */
        getWindow().setAttributes(attr);

        setupOptionMenu();
    }

    @Override
    public void onStart() {
        super.onStart();
    }

    @Override
    public void onStop() {
        super.onStop();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
    }

    private void setupOptionMenu() {
        View header = LayoutInflater.from(this).inflate(R.layout.header, null);

        final View optionMenu = header.findViewById(R.id.option_menu);
        optionMenu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                PopupMenu popup = new PopupMenu(MainApplication.this, optionMenu);
                popup.getMenuInflater().inflate(R.menu.menus, popup.getMenu());
                popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
                    @Override
                    public boolean onMenuItemClick(MenuItem item) {
                        Toast.makeText(MainApplication.this,
                                R.string.menu_clicked, Toast.LENGTH_SHORT).show();
                        return true;
                    }
                });
                popup.show();
            }
        });

        /* Deploy the option menu in the header area of the titlebar */
        getWindow().setHeaderView(header);
    }
}

这是Android清单

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

<uses-sdk android:minSdkVersion="15" />

<uses-permission android:name="com.sony.smallapp.permission.SMALLAPP" />

<application android:label="@string/app_name" >
    <uses-library android:name="com.sony.smallapp.framework" />

    <service
        android:name="MainApplication"
        android:exported="true" >
        <intent-filter>
            <action android:name="com.sony.smallapp.intent.action.MAIN" />
            <category android:name="com.sony.smallapp.intent.category.LAUNCHER" />
        </intent-filter>
    </service>
</application>

任何帮助都非常受欢迎

4

1 回答 1

1

我试过你的代码,它工作正常。我猜参考文献有问题。希望这个链接有帮助。http://juristr.com/blog/2010/06/android-instrumentation-test/

于 2013-06-04T20:04:24.897 回答