ActionBarSherlock:java.lang.NoClassDefFoundError:com.actionbarsherlock.R $ styleable [英] ActionBarSherlock: java.lang.NoClassDefFoundError: com.actionbarsherlock.R$styleable

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

问题描述

我正在使用Eclipse Indigo和ADT r20,使用ActionBarSherlock 4.1构建一个小型示例应用程序。



我创建了一个具有空白活动的新Android项目,复制了actionbarsherlock .jar到libs并在构建路径中引用它。



应用程序构建成功,但是在仿真器(使用2.2)或设备(使用4.0)启动之后。 4),它崩溃与错误:

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

我没有使用proguard。



我已经尝试清理ActionBarSherlock项目,将新的jar复制到我的示例项目的libs中,然后清理我的示例项目



我的MainActivity.java很简单:

  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(菜单菜单){
getSupportMenuInflater()。inflate(R.menu.activity_main,menu);
返回true;
}
}

菜单只有一个项目:

 < 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>

AndroidManifest.xml也是Eclipse创建的:

 < 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>

在这一点上,我真的不知道我可能错过了什么。

解决方案

我自己解决了这个问题,将ActionBarSherlock以不同的方式添加到Eclipse项目中。



而不是将actionbarsherlock.jar复制到lib中并将其添加到构建路径中,我将其添加到项目属性的Android部分中作为引用的项目。



该应用程序现在在仿真器和设备上正确构建和运行。




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

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

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)
        ...

I am not using proguard.

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

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>

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.

解决方案

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

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 $ styleable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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