我正在尝试设置一个使用 Jake Wharton 的示例项目动作栏夏洛克 with ActionBarSherlock-插件-地图。我按照说明进行操作here and here。我不一定需要碎片。这是我创建的简单类。
package com.example.actionbarsherlock;
import android.os.Bundle;
import com.actionbarsherlock.app.SherlockMapActivity;
public class MainActivity extends SherlockMapActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
protected boolean isRouteDisplayed() {
return false;
}
}
尽管我试图遵循确切的描述,但我最终得到了一个ClassNotFoundException
当我启动应用程序时。这是堆栈跟踪。
Unable to resolve superclass of Lcom/actionbarsherlock/app/SherlockMapActivity; (729)
Link of class 'Lcom/actionbarsherlock/app/SherlockMapActivity;' failed
Unable to resolve superclass of Lcom/example/actionbarsherlock/MainActivity; (533)
Link of class 'Lcom/example/actionbarsherlock/MainActivity;' failed
D/AndroidRuntime(408): Shutting down VM
threadid=3: thread exiting with uncaught exception (group=0x4001b188)
Uncaught handler: thread main exiting due to uncaught exception
java.lang.RuntimeException: Unable to instantiate activity
ComponentInfo{com.example.actionbarsherlock/com.example.actionbarsherlock.MainActivity}:
java.lang.ClassNotFoundException: com.example.actionbarsherlock.MainActivity
in loader dalvik.system.PathClassLoader@44e8ca40
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2417)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
at android.app.ActivityThread.access$2200(ActivityThread.java:119)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4363)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: com.example.actionbarsherlock.MainActivity
in loader dalvik.system.PathClassLoader@44e8ca40
at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2409)
... 11 more
threadid=7: reacting to signal 3
Unable to open stack trace file '/data/anr/traces.txt': Permission denied
我之前测试了该库并创建了一个子类SherlockActivity
效果很好。在这样做的同时,我注意到同样的ClassNotFoundException
当我忘记配置时发生android:theme
设置在AndroidManifest.xml
。这是两者的文件(SherlockActivity
and SherlockMapActivity
)示例项目,以防万一:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.actionbarsherlock"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="15" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:theme="@style/Theme.Sherlock"
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>
Update:
添加后uses-library
按照 Raghav Sood 和 M Mohsin Naeem 建议的设置我遇到以下消息。
Installation error: INSTALL_FAILED_MISSING_SHARED_LIBRARY
这是我的项目设置的屏幕截图。
Edit:
也许是.classpath
我的文件动作条夏洛克测试项目帮助...
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="lib" path="libs/actionbarsherlock-plugin-maps-4.1.0.jar"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
The .classpath
的文件library项目看起来完全一样。
Solution to the INSTALL_FAILED_MISSING_SHARED_LIBRARY
错误信息。
由于某些原因,Eclipse 总是启动配置为 API 级别 7 的模拟器,但是没有谷歌API。我无法强迫它选择“支持地图”的模拟器。在我删除“无地图”模拟器后,应用程序成功启动。你知道这是怎么发生的吗?
Summary:
最后,我让它运行起来。以下是我想分享的一些经验。
- 下载最新版本动作栏夏洛克从网站上。
- Do not克隆存储库为了检查 4.1.0 标签 (9598f2b)。它对我不起作用。
- 在 Eclipse 中设置 ActionBarSherlock 库项目。
- 更新包含的
action-support-v4.jar
到最新版本。
- Add the
actionbarsherlock-plugin-map-x.y.z.jar
to the libs
的文件夹library项目。
- You do not需要将其添加到库项目的构建路径中。
- 设置您的主项目并将库项目添加为依赖项。
- You do not需要添加
action-support-v4.jar
or the actionbarsherlock-plugin-map-x.y.z.jar
到你的主要项目。也是not需要将任何 .jar 文件添加到主项目的构建路径中。
- A 简单而有用的例子可以在存储库中找到以下内容。