Android 带有ViewPager的LayoutFlate异常
重新安装Android Studio后仍收到此消息。不确定这里到底发生了什么,但我在更新minSDK版本后收到了这条消息 我有另一个用户也在使用相同的文件,他的应用程序可以运行。这是我运行ViewPager的片段。我在活动中定义的ViewPager的背景旁边有一个红色感叹号Android 带有ViewPager的LayoutFlate异常,android,Android,重新安装Android Studio后仍收到此消息。不确定这里到底发生了什么,但我在更新minSDK版本后收到了这条消息 我有另一个用户也在使用相同的文件,他的应用程序可以运行。这是我运行ViewPager的片段。我在活动中定义的ViewPager的背景旁边有一个红色感叹号 java.lang.RuntimeException: Unable to start activity ComponentInfo{urlinq.android.com.edu_chat_lollipop/urlinq.a
java.lang.RuntimeException: Unable to start activity ComponentInfo{urlinq.android.com.edu_chat_lollipop/urlinq.android.com.edu_chat.LoginActivity}: android.view.InflateException: Binary XML file line #10: Binary XML file line #10: Error inflating class android.support.v4.view.ViewPager
login_main.xml
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.1'
defaultConfig {
applicationId "urlinq.android.com.edu_chat_lollipop"
minSdkVersion 22
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
repositories {
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
}
dependencies {
compile 'com.loopj.android:android-async-http:1.4.9'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
}
尝试将此添加到依赖项
编译'com.android.support:support-v4:23.0.1'首先使用viewpager,而不使用诸如编译'com.android.support:appcompat-v7:23.0.1'之类的支持库 编译'com.android.support:design:23.0.1'
这将帮助您隔离viewpager或支持库的问题 请提供login_main.xml布局文件,我刚刚完成了。没有什么变化。
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<bitmap
android:id="@+id/Idofbg3"
android:gravity="fill"
android:src="@drawable/welcome" />
</item>
<item>
<bitmap
android:id="@+id/Idofbg2"
android:gravity="fill"
android:src="@drawable/welcome2" />
</item>
<item>
<bitmap
android:id="@+id/Idofbg1"
android:gravity="fill"
android:src="@drawable/welcome3" />
</item>
</layer-list>
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.1'
defaultConfig {
applicationId "urlinq.android.com.edu_chat_lollipop"
minSdkVersion 22
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
repositories {
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
}
dependencies {
compile 'com.loopj.android:android-async-http:1.4.9'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
}
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true">
<android.support.v4.view.ViewPager
android:id="@+id/loginPager"
android:layout_width="match_parent"
android:layout_height="340dp"
android:background = "@drawable/login_drawable"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true" />
<fragment
android:layout_width="match_parent"
android:layout_height="285dp"
android:name="urlinq.android.com.edu_chat.SignUpFragment"
android:id="@+id/fragment"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
tools:layout="@layout/combined_login"
android:layout_alignParentBottom="true" />
<ImageView
android:layout_width="150dp"
android:layout_height="65dp"
android:id="@+id/eduChatLogo"
android:background="@drawable/chatlogo"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp" />
</RelativeLayout>