JJD*_*JJD 2 android classnotfoundexception mapactivity actionbarsherlock
我正在尝试设置一个使用Jake Wharton的ActionBarSherlock和ActionBarSherlock-Plugin-Maps的示例项目.我按照这里和这里的说明进行操作.我不一定需要碎片.这是我创建的简单类.
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;
}
}
Run Code Online (Sandbox Code Playgroud)
虽然我试着按照确切的描述,但最终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
Run Code Online (Sandbox Code Playgroud)
我之前测试过这个库并创建了一个SherlockActivity工作正常的子类.在这样做时,我注意到ClassNotFoundException当我忘记配置android:theme设置时也会发生同样的情况AndroidManifest.xml.以下是两个(SherlockActivity和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>
Run Code Online (Sandbox Code Playgroud)
更新:
uses-library按照Raghav Sood和M Mohsin Naeem的建议添加设置后,我会遇到以下消息.
Installation error: INSTALL_FAILED_MISSING_SHARED_LIBRARY
Run Code Online (Sandbox Code Playgroud)
这是我项目设置的屏幕截图.

编辑:
也许.classpath我的actionbarsherlocktest 项目的文件有助于......
<?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>
Run Code Online (Sandbox Code Playgroud)
库项目的.classpath文件看起来完全一样.
解决的INSTALL_FAILED_MISSING_SHARED_LIBRARY错误消息.
出于某些原因,Eclipse总是启动为API级别7配置但没有Google API的模拟器.我无法强迫它选择"启用地图"的模拟器.删除"无地图"模拟器后,应用程序成功启动.你知道这会怎么样吗?
摘要:
最后,我让它运行起来.以下是我想分享的一些经验.
action-support-v4.jar到最新版本.actionbarsherlock-plugin-map-x.y.z.jar到库项目的libs文件夹.action-support-v4.jar或actionbarsherlock-plugin-map-x.y.z.jar到您的主项目.也没有必要将任何.jar文件添加到主项目的构建路径中.Rag*_*ood 10
您将遇到此错误的原因只有三个:
你还应该添加
<uses-library android:name="com.google.android.maps" />
Run Code Online (Sandbox Code Playgroud)
到您的清单文件.
| 归档时间: |
|
| 查看次数: |
5051 次 |
| 最近记录: |