运行ActionBarSherlock-插件功能的地图时ClassNotFoundException的:Android的 [英] Android: ClassNotFoundException when running ActionBarSherlock-Plugin-Maps

查看:174
本文介绍了运行ActionBarSherlock-插件功能的地图时ClassNotFoundException的:Android的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想建立一个使用示例项目杰克沃顿商学院的 ActionBarSherlock ,提供的 ActionBarSherlock-插件-地图。我按照说明这里这里。我不一定需要片段。这里是我创建的简单类。

I am trying to setup an example project that uses Jake Wharton's ActionBarSherlock with ActionBarSherlock-Plugin-Maps. I follow the instructions here and here. I do not necessarily need Fragments. Here is the simple class I created.

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 当我启动应用程序。这里是堆栈跟踪。

Although I tried to follow the exact descriptions I end up with a ClassNotFoundException when I launch the application. Here is the stacktrace.

  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的发生:主题<$ 设置C $ C>的Andr​​oidManifest.xml 。下面是这两个文件( SherlockActivity SherlockMapActivity )示例项目,以防万一:

I tested the library before and created a subclass of SherlockActivity which worked fine. While doing so, I noticed that the same ClassNotFoundException occurs when I forget to configure the android:theme setting in AndroidManifest.xml. Here is the file for both (SherlockActivity and SherlockMapActivity) example projects, just in case:

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


更新:

添加后使用库设置由拉哈夫索德和M穆赫辛纳伊姆的建议我碰到下面的信息。

After adding the uses-library setting as suggested by Raghav Sood and M Mohsin Naeem I run into the following message.

Installation error: INSTALL_FAILED_MISSING_SHARED_LIBRARY

下面是我的项目设置的截图。

Here is a screenshot of my projects' setup.

编辑:

也许的的.classpath 文件我的 actionbarsherlocktest 的项目可以帮助...

Maybe the .classpath file of my actionbarsherlocktest project helps ...

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

的项目看起来完全的.classpath 文件是相同的。

The .classpath file of the library project looks exactly the same.

解决方案 INSTALL_FAILED_MISSING_SHARED_LIBRARY 错误消息。

有关某些原因的Eclipse开始总是被配置为API 7级,但没有谷歌API的模拟器。我无法管理,迫使它挑已启用地图 - 模拟器。我删除了地图少模拟器之后,应用程序成功启动。你知道这是如何发生的呢?

For some reasons Eclipse always started the emulator that was configured for API level 7 but without the Google API. I could not manage to force it to pick the "map-enabled" emulator. After I deleted the "map-less" emulator the application launched successfully. Do you know how this can happen?

摘要:

最后,我得到了它运行。这里有一些经验,我喜欢分享。

Finally, I got it running. Here are some experiences I like to share.


  • 从网站上下载最新版本的 ActionBarSherlock 的。

  • 不可以克隆以检出4.1.0标签(9598f2b)。它没有为我工作。

  • 设置在Eclipse中ActionBarSherlock库项目。

  • 更新包含行动支持-v4.jar 到最新版本。

  • 添加在 actionbarsherlock-插件-MAP-xyzjar 文件夹项目。

  • 您做的不可以需要将其添加到库项目的构建路径。

  • 设置您的主要项目,并添加库项目作为一个依赖。

  • 您做的不可以需要添加行动支持-v4.jar actionbarsherlock-插件地图-xyzjar 来您的主项目。这也是不可以需要任何.jar文件添加到主体工程的构建路径。

  • 系统简单的和有用的例子的,遵循的是可用信息库。

  • Download the latest version of ActionBarSherlock from the website.
  • Do not clone the repository in order to checkout the 4.1.0 tag (9598f2b). It did not work for me.
  • Setup the ActionBarSherlock library project in Eclipse.
  • Update the contained action-support-v4.jar to the latest version.
  • Add the actionbarsherlock-plugin-map-x.y.z.jar to the libs folder of the library project.
  • You do not need to add it to the build path of the library project.
  • Setup your main project and add the library project as a dependency.
  • You do not need to add the action-support-v4.jar or the actionbarsherlock-plugin-map-x.y.z.jar to your main project. It is also not necessary to add any of the .jar files to the build path of the main project.
  • A simple and helpful example to follow is available in the repository.

推荐答案

有只有三个理由,你永远不会得到这个错误:

There are only three reasons you will ever get this error:


  1. 类真的不存在。如果您使用的是来自官方的例子code和得到这个,请确保您有库的最新版本

  2. 您还没有添加罐子构建路径。要解决此问题,右键单击Eclipse中的罐子,也构建路径►添加到构建路径。

  3. 您的罐子是不是在/ libs文件夹。这种情况发生时,你已经添加了罐子到构建路径,但ADT的新版本需要它是在/库。把它放在那里,它重新添加到构建路径。

您还应该添加

<uses-library android:name="com.google.android.maps" />

要你的清单文件。

这篇关于运行ActionBarSherlock-插件功能的地图时ClassNotFoundException的:Android的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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