ActivityNotFoundException上FragmentActivity [英] ActivityNotFoundException on FragmentActivity

查看:91
本文介绍了ActivityNotFoundException上FragmentActivity的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有很多的Play商店老式活动为基础的应用程序。由于这两天我尝试用片段做我的第一个步骤。我仍然不明白这一点。我读过大部分的所有文档和博客和导游有关片段,但我愚蠢的简单的测试应用程序将无法启动与MyActivity一个ClassNotFoundException异常。

I do have lots of plain old activity-based apps in the Play Store. Since two days I try to do my first steps with Fragments. I still don't get it. I've read mostly all docs and blogs and guides about Fragments but my stupid simple test app refuses to start with an ClassNotFoundException on MyActivity.

因此​​,这里是我所做的,到目前为止:

So here's what I did so far:

起始FragmentActivity称为MyActivity:

The starting FragmentActivity called MyActivity:

public class MyActivity extends FragmentActivity {

    @Override
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);

        setContentView(R.layout.myactivity);
    }
}

这里的布局/ myactivity.xml:

Here's the layout/myactivity.xml:

<LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal" >

    <fragment
        class="com.test.app.Table1List"
        android:id="@+id/table1list"
        android:layout_height="match_parent"
        android:layout_width="match_parent" />
</LinearLayout>

这是与它的XML文件ListFragment:

This is the ListFragment with its XML file:

public class Table1List extends ListFragment {

    @Override
    public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        if (viewGroup == null) {
            return null;
        }

        return layoutInflater.inflate(R.layout.table1list, viewGroup);
    }
}

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >

    <ListView
        android:drawSelectorOnTop="false"
        android:fastScrollEnabled="true" 
        android:id="@id/android:list"
        android:layout_height="fill_parent"
        android:layout_width="fill_parent" />

    <TextView
        style="@style/TextViewMedium"
        android:id="@id/android:empty"
        android:text="@string/txt_noresult" />
</LinearLayout>

打电话给我傻,但我总是叫MyActivity的FragmentActivity开始时得到一个ActivityNotFoundException。

Call me stupid but I always do get an ActivityNotFoundException during start of the FragmentActivity called MyActivity.

任何帮助是非常AP preciated。

Any help is highly appreciated.

修改

我把最新的V4兼容包从数天前。我发出的清洁项目几乎每10分钟 - 不走

I took the latest v4 Compatibility Package from several days ago. I issued clean projects nearly every 10 minutes - no go.

这里的清单:

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

    <uses-sdk
        android:minSdkVersion="7"
        android:targetSdkVersion="11" />

    <application
        android:hardwareAccelerated="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/txt_appname" >

        <activity
            android:label="@string/txt_appname"
            android:name="MyActivity" >

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>

编辑2 :这里的LogCat中:

EDIT 2: Here's the LogCat:

Unable to resolve superclass of Lcom/test/app/MyActivity; (25)
Link of class 'Lcom/test/app/MyActivity;' failed
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.test.app/com.test.app.MyActivity}: java.lang.ClassNotFoundException: com.test.app.MyActivity in loader dalvik.system.PathClassLoader@44bfda38
    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.test.app.MyActivity in loader dalvik.system.PathClassLoader@44bfda38
    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

修改3 :我也重新安装了支持包,创建了兼容性包v4的一个新项目,精简一切只是MyActivity和一个片段 - >同样的错误。我甚至用previous支持V4包(第6版)的测试。

EDIT 3: I did re-install the support package, created a new project with Compatability Package v4, stripped down everything to just the MyActivity and one fragment --> same error. I even tested with the previous Support v4 package (Release 6).

这些都是我用碎片经过近三年Android开发(在市场上大量的应用程序)的第一个步骤。看来,这整个事情是坏了。

These are my first steps with Fragments after nearly three years with Android development (lots of apps in the market). Seems that this whole thing is broken.

这是Eclipse项目树 - 任何帮助仍然强烈要求

This is the project tree in eclipse - any help still highly required.

推荐答案

我不知道这是否会解决您的问题,但看你的截图,一切看起来正确的我,除了引用的库项。这不应该有什么比较,因为最新的ADT版本17会自动检测文件夹中的所有jar文件。您可以从您的构建路径移除明确提到支持Android罐子摆脱引用的库项目。

I don't know if this will fix your problem but looking at your screenshot, everything looks correct to me except the Referenced Libraries item. That shouldn't be there any more because the latest ADT version 17 automatically detects all jars in the libs folder. You can get rid of the Referenced Libraries item by removing the explicit reference to the android support jar from your build path.

我有一个非常类似的问题,完全难住了一段时间,直到我读这篇博客里面有很多有关这问题,所以它可能是值得一读,即​​使删除引用的库不起作用。

I had a very similar problem and was completely stumped for a while until I read this blog post which has a lot of information about this issue so it might be worth a read even if removing the Referenced Libraries doesn't work.

这篇关于ActivityNotFoundException上FragmentActivity的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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