我的应用程序有几个自定义类,它们保存在一个名为“models”的文件夹中,可以通过“com”访问。我的名字。appname。模型。类名'。直到最近,它还工作得很好,但当它试图扩大使用其中一个类的布局时,它突然崩溃了。
android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class com.myname.appname.ColourCell
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class com.myname.appname.ColourCell
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.myname.appname.ColourCell" on path: DexPathList[...]
所以它在寻找
com.myname.appname.ColourCell
而不是
com.myname.appname.models.ColourCell
.
我在谷歌上搜索了ClassNotFoundException错误,找到了以下解决方案,但似乎都不起作用:
-
启用多索引
-
更新compileSDKVersion
-
添加“maven”支持
-
禁用即时运行
当它试图膨胀布局时,仍然会出现相同的错误。
我不知道下一步该怎么办。我一点也不懂格雷德——我总是用它!不过,我在网上找到的解决方案似乎以gradle文件为中心,因此我将其包括在下面:
应用程序:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
signingConfigs {
config {
keyAlias 'xxx'
keyPassword 'xxx'
storeFile file('xxx')
storePassword 'xxx'
}
}
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.myname.appname"
minSdkVersion 21
targetSdkVersion 26
versionCode 7
versionName "1.0.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
debug {
minifyEnabled false
}
}
productFlavors {
freeConfig {
applicationId 'com.myname.appname.free'
}
paidConfig {
applicationId 'com.myname.appname.full'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile project(path: ':backend', configuration: 'android-endpoints')
compile 'com.android.support:appcompat-v7:26.0.0-beta1'
compile 'com.android.support:design:26.0.0-beta1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.code.findbugs:jsr305:2.0.1'
compile 'com.google.firebase:firebase-auth:10.0.1'
compile 'com.google.firebase:firebase-database:10.0.1'
compile 'com.google.firebase:firebase-ads:10.0.1'
compile 'com.firebase:firebase-client-android:2.5.0'
compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.firebaseui:firebase-ui-database:1.1.1'
compile 'com.android.support:multidex:1.0.1'
testCompile 'junit:junit:4.12'
}
应用程序名称:
buildscript {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
我尝试过清理项目和重建,但没有成功。它运行良好,直到达到特定的膨胀语句并尝试使用它找不到的类。我完全不知道下一步该做什么。