安卓开发——Error inflating class ******(com.example.pull_to_refresh.PullToRefreshView)

Error inflating class ******(com.example.pull_to_refresh.PullToRefreshView)
肝了一天,问题解决之后气炸了,小白的老师布置了一个实验,其中有一个项目模板,老师要求先把模板运行起来,当小白更改完版本以及依赖配置问题之后后,便开始运行项目,结果模拟器上显示要么只显示白屏,要么显示应用已停止运行。当小白进行代码检查时,确实没有发现问题。当与bug抗争了一天之后,小白灵机一动,会不会是路径的问题,果然
在这里插入图片描述

在这里插入图片描述

在这里插入图片描述
如上图所示,在xml文件中引用了一个自定义类PullToRefreshView,而小白犯的错误就是没有对应好路径(上图已改正),所以如果大家在运行项目时,发现类似问题,要仔细考虑一下路径有无错误。

虽然小白没有出现版本问题,但还是觉得有必要贴一下代码

apply plugin: 'com.android.application'

android {
    compileSdkVersion 30
    buildToolsVersion "30"

    defaultConfig {
        applicationId "com.example.food3"
        minSdkVersion 14
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
//    compile 'com.android.support:appcompat-v7:+'
    implementation 'androidx.appcompat:appcompat:1.0.2'
    compile 'com.yalantis:phoenix:1.2.3'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}

注:模拟器上出现应用已停止运行类似的问题解决常见错误
1.xml文件中代码有误,可能是元素的layout_width和layout_height未设置,也可能是xml中引用的资源不存在或者资源的路径不对
2.java代码有误,出现这种问题时,小白一般都是从上到下逐步对代码进行抛异常。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

异二次元

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值