Android:找不到类异常:android.support.v4.app.FragmentPager

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10199430/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 02:50:47  来源:igfitidea点击:

Android: class not found exception: android.support.v4.app.FragmentPager

androidclassnotfoundexception

提问by user1324936

In my code I import android.support.v4.view.ViewPagerbut I get a ClassNotFoundException: android.support.v4.view.ViewPagerwhen I set content view to this xml file:

在我导入的代码中,android.support.v4.view.ViewPager但是ClassNotFoundException: android.support.v4.view.ViewPager当我将内容视图设置为这个 xml 文件时,我得到了一个:

...
 <android.support.v4.app.FragmentPager 
     android:layout_height="0px" 
     android:layout_width="match_parent" 
     android:layout_weight="1" 
     android:id="@+id/pager"> 
     </android.support.v4.app.FragmentPager>
...

回答by waqaslam

You have to add compatibility library by right clicking your project and selecting Android Tools -> Add Compatibility Library. Once its added, clean your project and build again.

您必须通过右键单击您的项目并选择Android Tools -> Add Compatibility Library 来添加兼容性库。添加后,清理您的项目并再次构建。



enter image description here

在此处输入图片说明

回答by Mina Gabriel

i'm using Android Studio Beta 0.8.6and i had to do it this way

我正在使用Android Studio Beta 0.8.6,我不得不这样做



File -> Project Structureenter image description here

文件 -> 项目结构在此处输入图片说明

回答by ITurchenko

Go to <Your android apk folder>\sdk\extras\android\support\v4folder and add android-support-v4.jarto app library (or whole sdk library).

转到<Your android apk folder>\sdk\extras\android\support\v4文件夹并添加android-support-v4.jar到应用程序库(或整个 sdk 库)。

回答by Anil Chahal

Add Support library by right clicking your project and selecting Android Tools -> Add Compatibility Library. After adding Support Library clean your project and Go to Java Build Path, Go to Order and Export [Last tab] click all currently added Jar files and libraries..press Ok and refresh your Project.. It works fine for me..

通过右键单击您的项目并选择 Android 工具 -> 添加兼容性库来添加支持库。添加支持库后,清理您的项目并转到 Java 构建路径,转到订单和导出 [最后一个选项卡] 单击所有当前添加的 Jar 文件和库..按确定并刷新您的项目..它对我来说很好用..

回答by Alex Klimashevsky

You should add android.support.v4 jar to your app.

您应该将 android.support.v4 jar 添加到您的应用程序中。

回答by Mukta gajare

If it is not gradle based then You should Migrate Eclipse ADT based project to Gradle based.. Import Project into android studio..

如果它不是基于 gradle,那么您应该将基于 Eclipse ADT 的项目迁移到基于 Gradle 的项目。将项目导入 android studio ..

回答by Edward

I had this problem please right click on your project and click Android Tools and now click Support Libraries and then Accept License Now Run your Project It will Work :D

我遇到了这个问题,请右键单击您的项目,然后单击 Android 工具,然后单击支持库,然后立即接受许可运行您的项目,它将起作用:D

RightClick==>Android Tools==>Support Libraries ==>Accept License

右键==>Android 工具==>支持库==>接受许可