寻找错误的片段类与Android兼容库片段、错误、Android

2023-09-13 23:41:16 作者:这个世界、我只为你笑

我试图夸大包含​​使用向后兼容包和SDK 10级我把jar文件并把它放在我的项目的库文件夹中的片段布局。我伸出FragmentActivity。

I am trying to inflate a layout containing a Fragment using the backwards compatibility package and SDK level 10. I took the jar file and placed it in the libs folder of my project. I extended FragmentActivity.

这一切都完美的作品,当我在一个XLARGE屏幕设备上的API级别11运行。

It all works perfectly when I run at API level 11 on an XLarge screen device.

当我回落到编制对10的水平,和正常大小的屏幕上运行,我得到失败的地步,创建一个新的活动和膨胀的片段吧。

When I drop back to compiling against level 10, and running on a normal sized screen, I get failure at the point where it create a new Activity and inflate the fragment in it.

引起的:   抛出java.lang.ClassNotFoundException:   android.view.fragment装载机   dalvik.system.PathClassLoader [/data/app/com.motoappsummitagenda-1.apk]   一月4日至1日:07:14.311 2870 2870Ë   AndroidRuntime:在   dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)

Caused by: java.lang.ClassNotFoundException: android.view.fragment in loader dalvik.system.PathClassLoader[/data/app/com.motoappsummitagenda-1.apk] 04-01 01:07:14.311 2870 2870 E AndroidRuntime: at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)

因此​​,它看起来像什么,什么地方是寻找android.view.fragment,不兼容的版本,android.support.v4.app.Fragment。当然,android.view.fragment不会在API层面10.找到,但在这里的是,从android.view.fragment来的?

So it looks like something, somewhere is looking for android.view.fragment, and not the compatibility version, android.support.v4.app.Fragment. Of course, android.view.fragment won't be found on API level 10. But where is that android.view.fragment coming from?

这是正在膨胀中的XML是

The XML that is being inflated is

<?xml version="1.0" encoding="utf-8"?>
<fragment
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:name="com.motorapp.SessionFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/sessionfragment">
</fragment>

在$ C $下启动:

The code for it starts:

package com.motorapp;

import java.util.List;
import java.util.ListIterator;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.support.v4.app.*;
import android.support.v4.util.*;
import android.support.v4.*;
import android.support.v4.widget.*; 

public class SessionFragment extends android.support.v4.app.Fragment {

的症状类似这个问题,但我没有那些错误 inflating与兼容包的Andr​​oid 片段

The symptoms are similar to this problem, but I don't have those mistakes inflating fragments with compatibility package android

在android.compatibility.v4.android支持-V4 jar文件是在Eclipse中我的构建路径 在项目>属性> Java构建路径

The android.compatibility.v4.android-support-v4 jar file is on my build path in Eclipse under Project > Properties > Java build path

我在清单(我已经试过了名的不同变化)。     

I have in the manifest (and I have tried different variations of the name).

在开始使用的片段,我第一次使用的蜂窝设备API 11,所有的作品完美。它是在得到同样的code(修改为使用略有不同的兼容性API)与兼容性库,我也有这个问题的工作。任何想法将非常欢迎。谢谢, 彼得·

In getting started with fragments, I first used API 11 on a honeycomb device, and that all works perfectly. It is in getting the same code (modified to use the slightly different compatibility API) working with the compatibility library that I have this problem. Any ideas would be very welcome. Thanks, Peter

推荐答案

我有同样的错误类的问题,兼容性库,并试图上面没有运气提到的一切。我终于想通了:我是用了不正确的XML元素片段,而不是正确的片段。资本似乎无关紧要。

I had the same wrong class problem with the compatibility library and tried everything mentioned above with no luck. I finally figured it out: I was using the incorrect XML element Fragment rather than correct one fragment. Capitalization seems to matter.