ClassNotFoundException - android.support.v4.view.ViewPager

时间:2014-11-21 13:14:02

标签: android android-fragments android-studio

我正在尝试使用可滑动视图创建标签布局。要添加ViewPager我创建了activity_fragments_logs.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">

<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/pager"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
</android.support.v4.view.ViewPager>

</LinearLayout>

我已按照https://developer.android.com/tools/support-library/setup.html

中的步骤添加了支持库

现在,此xml文件的设计选项卡正在提供ClassNotFoundException。这是例外:

java.lang.ClassNotFoundException: android.support.v4.view.ViewConfigurationCompatFroyo
at org.jetbrains.android.uipreview.ProjectClassLoader.load(ProjectClassLoader.java:112)
at com.android.tools.idea.rendering.RenderClassLoader.findClass(RenderClassLoader.java:52)
at org.jetbrains.android.uipreview.ProjectClassLoader.findClass(ProjectClassLoader.java:73)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at android.support.v4.view.ViewConfigurationCompat$FroyoViewConfigurationVersionImpl.getScaledPagingTouchSlop(ViewConfigurationCompat.java:56)
at android.support.v4.view.ViewConfigurationCompat.getScaledPagingTouchSlop(ViewConfigurationCompat.java:105)
at android.support.v4.view.ViewPager.initViewPager(ViewPager.java:367)
at android.support.v4.view.ViewPager.<init>(ViewPager.java:355)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:379)
at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:99)
at com.android.tools.idea.rendering.LayoutlibCallback.loadView(LayoutlibCallback.java:172)
at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:207)
at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:132)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:806)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:782)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:385)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:401)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:329)
at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:333)
at com.android.tools.idea.rendering.RenderService$5.compute(RenderService.java:674)
at com.android.tools.idea.rendering.RenderService$5.compute(RenderService.java:663)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:932)
at com.android.tools.idea.rendering.RenderService.createRenderSession(RenderService.java:663)
at com.android.tools.idea.rendering.RenderService.render(RenderService.java:790)
at com.intellij.android.designer.designSurface.AndroidDesignerEditorPanel$6.run(AndroidDesignerEditorPanel.java:480)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310)
at com.intellij.util.ui.update.MergingUpdateQueue$2.run(MergingUpdateQueue.java:254)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227)
at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217)
at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
at com.intellij.util.Alarm$Request$1.run(Alarm.java:327)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)

我在Stack Overflow上读过一个类似的问题,但它处理Eclipse而我正在使用Android Studio。

Updated SDK version, getting ClassNotFoundException: android.support.v4.view.ViewPager

我已经搜索了很多关于这个但我找不到任何有用的东西。

1 个答案:

答案 0 :(得分:0)

xmlns:android="http://schemas.android.com/apk/res/android"

从视图寻呼机中删除它应该位于层次结构的顶部