我已多次尝试过索尼小型应用SDK示例项目,但我无法让它工作:
每次我使用它时都会收到错误:
06-02 10:40:13.358:E / AndroidRuntime(5903): java.lang.IllegalAccessError:已解析的预验证类中的类ref 意外实施
我尝试从他们的网站以及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 Manifest
<?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>
任何帮助都非常受欢迎
答案 0 :(得分:1)
我尝试了你的代码,它运行正常。我猜这些引用有问题。希望此链接有所帮助。 http://juristr.com/blog/2010/06/android-instrumentation-test/