gpt4 book ai didi

Android 应用程序无法在 ver 中运行。 2.3

转载 作者:行者123 更新时间:2023-11-29 00:26:41 25 4
gpt4 key购买 nike

我的应用程序在 Android 4.0+ 版本上运行良好,但是当我尝试在版本 4.0 上启动它时出现错误。 2.3有什么建议么?android:minSdkVersion="8"android:targetSdkVersion="15"

09-16 21:37:29.759: E/AndroidRuntime(8307): FATAL EXCEPTION: main

09-16 21:37:29.759: E/AndroidRuntime(8307): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.Catholic_app/com.example.Catholic_app.News.Top}: android.view.InflateException: Binary XML file line #2: Error inflating class fragment

09-16 21:37:29.759: E/AndroidRuntime(8307): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1659)

09-16 21:37:29.759: E/AndroidRuntime(8307): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1675)

09-16 21:37:29.759: E/AndroidRuntime(8307): at android.app.ActivityThread.access$1500(ActivityThread.java:121)

09-16 21:37:29.759: E/AndroidRuntime(8307): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:943)

09-16 21:37:29.759: E/AndroidRuntime(8307): at android.os.Handler.dispatchMessage(Handler.java:99)

09-16 21:37:29.759: E/AndroidRuntime(8307): at android.os.Looper.loop(Looper.java:130)

09-16 21:37:29.759: E/AndroidRuntime(8307): at android.app.ActivityThread.main(ActivityThread.java:3701)

09-16 21:37:29.759: E/AndroidRuntime(8307): at java.lang.reflect.Method.invokeNative(Native Method)

09-16 21:37:29.759: E/AndroidRuntime(8307): at java.lang.reflect.Method.invoke(Method.java:507)

09-16 21:37:29.759: E/AndroidRuntime(8307): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)

09-16 21:37:29.759: E/AndroidRuntime(8307): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)

09-16 21:37:29.759: E/AndroidRuntime(8307): at dalvik.system.NativeStart.main(Native Method)

09-16 21:37:29.759: E/AndroidRuntime(8307): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class fragment

09-16 21:37:29.759: E/AndroidRuntime(8307): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:581)

09-16 21:37:29.759: E/AndroidRuntime(8307): at android.view.LayoutInflater.inflate(LayoutInflater.java:386)

09-16 21:37:29.759: E/AndroidRuntime(8307): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)

09-16 21:37:29.759: E/AndroidRuntime(8307): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)

09-16 21:37:29.759: E/AndroidRuntime(8307): at com.jeremyfeinstein.slidingmenu.lib.SlidingMenu.setMenu(SlidingMenu.java:375)

09-16 21:37:29.759: E/AndroidRuntime(8307): at com.example.Catholic_app.News.Top.createSlidingMenu(Top.java:81)

09-16 21:37:29.759: E/AndroidRuntime(8307): at com.example.Catholic_app.News.Top.onCreate(Top.java:70)

09-16 21:37:29.759: E/AndroidRuntime(8307): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)

09-16 21:37:29.759: E/AndroidRuntime(8307): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1623)

09-16 21:37:29.759: E/AndroidRuntime(8307): ... 11 more

09-16 21:37:29.759: E/AndroidRuntime(8307): Caused by: java.lang.ClassNotFoundException: android.view.fragment in loader dalvik.system.PathClassLoader[/data/app/com.example.Catholic_app-1.apk]

09-16 21:37:29.759: E/AndroidRuntime(8307): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)

09-16 21:37:29.759: E/AndroidRuntime(8307): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)

09-16 21:37:29.759: E/AndroidRuntime(8307): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)

09-16 21:37:29.759: E/AndroidRuntime(8307): at android.view.LayoutInflater.createView(LayoutInflater.java:471)

09-16 21:37:29.759: E/AndroidRuntime(8307): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:549)

09-16 21:37:29.759: E/AndroidRuntime(8307): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)

09-16 21:37:29.759: E/AndroidRuntime(8307): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)

09-16 21:37:29.759: E/AndroidRuntime(8307): ... 19 more

我没有在我的代码中使用 getSupportFragmentManager() 或 getFragmentManager() 方法。我使用附加库“滑动菜单”。这段代码出现错误

slidingMenu.setMenu(R.layout.slidingmenu);

我在哪里调用滑动菜单库的下一个方法

public void setMenu(int res) {
setMenu(LayoutInflater.from(getContext()).inflate(res, null));
}

我的R.layout.slidingmenu文件

 <?xml version="1.0" encoding="utf-8"?> 
<fragment
xmlns:android="schemas.android.com/apk/res/android"
android:name="com.example.Catholic_app.Menu.SlidingMenuFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/slidingmenu"> </fragment>

附言support-library-v4 已经添加

最佳答案

要使用 3.0 版以下的 Fragment,您必须在您的应用程序中使用它的支持库。

您应该使用 getSupportFragmentManager() 而不是 getFragmentManager()

android.support.v4.app.FragmentManager fm = getSupportFragmentManager();

更多详情请查看HERE

将其中一个库添加到您的 Android 项目:

In your Android project, create a directory named libs at the root of your project (next to src/, res/, etc.)
Locate the JAR file for the library you want to use and copy it into the libs/ directory.

For example, the library that supports API level 4 and up is located at <sdk>/extras/android/support/v4/android-support-v4.jar.
Add the JAR to your project build path.

关于Android 应用程序无法在 ver 中运行。 2.3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18843929/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com