ActionBarSherlock:java.lang.NoClassDefFoundError的:com.actionbarsherlock.R $设置样式 [英] ActionBarSherlock: java.lang.NoClassDefFoundError: com.actionbarsherlock.R$styleable

查看:199
本文介绍了ActionBarSherlock:java.lang.NoClassDefFoundError的:com.actionbarsherlock.R $设置样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图建立与ActionBarSherlock 4.1使用Eclipse靛蓝和ADT R20微小的样本应用程序。

I am trying to build a tiny sample application with ActionBarSherlock 4.1 using Eclipse Indigo and ADT r20.

我创建了一个新的Andr​​oid项目的空白活动,复制actionbarsherlock.jar到库,并在构建路径引用它。

I created a new Android project with a blank activity, copied actionbarsherlock.jar to libs and referenced it in the build path.

的应用程序成功生成,但在开始在任仿真器(使用2.2)或设备(使用4.0.4),它与误差崩溃:

The app builds successfully, but upon starting on either the emulator (using 2.2) or the device (using 4.0.4), it crashes with the error:

java.lang.NoClassDefFoundError: com.actionbarsherlock.R$styleable
        at com.actionbarsherlock.view.MenuInflater$MenuState.readItem(MenuInflater.java:328)
        ...

我不使用ProGuard的。

I am not using proguard.

我试图清理ActionBarSherlock项目,将新的jar放到我的样本项目的库,然后再清洗我的样本项目。

I have tried cleaning the ActionBarSherlock project, copying the new jar into my sample project's libs, and then cleaning my sample project.

我的MainActivity.java很简单:

My MainActivity.java is quite simple:

package com.example.lrn;

import com.actionbarsherlock.app.SherlockActivity;
import com.actionbarsherlock.view.Menu;
import android.os.Bundle;

public class MainActivity extends SherlockActivity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getSupportMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }
}

菜单上有,但单个项目:

The menu has but a single item:

<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@+id/menu_settings"
        android:title="@string/menu_settings"
        android:orderInCategory="100"
        android:showAsAction="ifRoom" />
</menu>

和的Andr​​oidManifest.xml中也只是作为Eclipse的创建是:

And the AndroidManifest.xml is also just about as Eclipse created it:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.lrn"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="16" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/title_activity_main" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

在这一点上我真的不知道我可能已经错过了。

At this point I really have no idea what I may have missed.

推荐答案

我通过增加ActionBarSherlock以不同的方式我的Eclipse项目解决了这个问题我自己。

I resolved this issue myself by adding ActionBarSherlock to my Eclipse project in a different way.

,我增加一条,作为项目属性的Andr​​oid的部分引用的项目。

Instead of copying actionbarsherlock.jar into libs and adding it to the build path, I added it as a referenced project in the Android section of the project properties.

该应用程序现在构建并同时在仿真器和设备运行正常。

The app now builds and runs correctly on both the emulator and the device.

这篇关于ActionBarSherlock:java.lang.NoClassDefFoundError的:com.actionbarsherlock.R $设置样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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