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
Android: class not found exception: android.support.v4.app.FragmentPager
提问by user1324936
In my code I
import android.support.v4.view.ViewPager
but I get a ClassNotFoundException: android.support.v4.view.ViewPager
when 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 来添加兼容性库。添加后,清理您的项目并再次构建。
回答by Mina Gabriel
i'm using Android Studio Beta 0.8.6
and i had to do it this way
我正在使用Android Studio Beta 0.8.6
,我不得不这样做
File -> Project Structure
文件 -> 项目结构
回答by ITurchenko
Go to <Your android apk folder>\sdk\extras\android\support\v4
folder and add android-support-v4.jar
to 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 工具==>支持库==>接受许可