私のアプリには、「models」というフォルダーに保持され、「com.myname.appname.models.classname」を介してアクセスされるいくつかのカスタムクラスがあります。最近までは正常に機能していましたが、これらのクラスの1つを使用するレイアウトを拡張しようとすると、突然クラッシュします。
私が得ているエラーは次のとおりです。
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エラーをグーグルで検索したところ、次の解決策が見つかりましたが、どれも機能していないようです。
レイアウトを膨らませようとすると、同じエラーでクラッシュします。
次に何をしようかわからない。私はgradleをまったく理解していません-私はいつもそれを使ってきました!私がオンラインで見つけた解決策は、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
}
プロジェクトのクリーニングと再構築を試みましたが、成功しませんでした。その特定のinflateステートメントに到達し、見つからないクラスを使用しようとするまで、正常に実行されています。次に何をしようか全くわからない。
私は脳波を持っていて、(「リファクタリング」メニューオプションを介して)「ColourCell」クラスをASが探していたパスに移動しました。それはうまくいきました。その後、(再び「リファクタリング」を介して)「モデル」に戻すことができましたが、まだ機能しています。
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加