解析失败:Lbutterknife/ButterKnife$Action; Android X?
Failed resolution of: Lbutterknife/ButterKnife$Action; Android X?
当我尝试在我的 Android 项目中使用 Butterknife 时出现以下异常:
添加外部库时出现错误,我不知道这是否会影响我,我 运行 整个项目都在 Android x
implementation('es.situm:situm-wayfinding:0.2.0-alpha@aar') {
transitive = true
changing = true
}
我似乎按照 Butterknife 的安装说明进行了操作,所以我不确定发生了什么。有什么我需要解决的吗?
他试图重建整个项目,但他仍然不断给我同样的错误。
E/AndroidRuntime: FATAL EXCEPTION: main
Process: smartlive.com.mx.smartlive, PID: 13851
java.lang.NoClassDefFoundError: Failed resolution of: Lbutterknife/ButterKnife$Action;
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
at androidx.fragment.app.Fragment.instantiate(Fragment.java:443)
at androidx.fragment.app.FragmentContainer.instantiate(FragmentContainer.java:50)
at androidx.fragment.app.Fragment.instantiate(Fragment.java:2403)
at androidx.fragment.app.FragmentManagerImpl.onCreateView(FragmentManager.java:3736)
at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:189)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:769)
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:964)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:854)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at es.situm.wayfinding.MapsFragment.onCreateView(Unknown Source)
at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2439)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1460)
at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1784)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1852)
at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManager.java:3269)
at androidx.fragment.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:3229)
at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:201)
at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:620)
at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:178)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1248)
at android.app.Activity.performStart(Activity.java:6683)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2687)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2789)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1527)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6251)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)
Caused by: java.lang.ClassNotFoundException: Didn't find class "butterknife.ButterKnife$Action" on path: DexPathList[[zip file "/data/app/smartlive.com.mx.smartlive-2/base.apk", zip file "/data/app/smartlive.com.mx.smartlive-2/split_lib_dependencies_apk.apk", zip file "/data/app/smartlive.com.mx.smartlive-2/split_lib_slice_0_apk.apk", zip file "/data/app/smartlive.com.mx.smartlive-2/split_lib_slice_1_apk.apk", zip file "/data/app/smartlive.com.mx.smartlive-2/split_lib_slice_2_apk.apk", zip file "/data/app/smartlive.com.mx.smartlive-2/split_lib_slice_3_apk.apk", zip file "/data/app/smartlive.com.mx.smartlive-2/split_lib_slice_4_apk.apk", zip file "/data/app/smartlive.com.mx.smartlive-2/split_lib_slice_5_apk.apk", zip file "/data/app/smartlive.com.mx.smartlive-2/split_lib_slice_6_apk.apk", zip file "/data/app/smartlive.com.mx.smartlive-2/split_lib_slice_7_apk.apk", zip file "/data/app/smartlive.com.mx.smartlive-2/split_lib_slice_8_apk.apk", zip file "/data/app/smartlive.com.mx.smartlive-2/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/smartlive.com.mx.smartlive-2/lib/arm, /data/app/smartlive.com.mx.smartlive-2/base.apk!/lib/armeabi-v7a, /data/app/smartlive.com.mx.smartlive-2/split_lib_dependencies_apk.apk!/lib/armeabi-v7a, /data/app/smartlive.com.mx.smartlive-2/split_lib_slice_0_apk.apk!/lib/armeabi-v7a, /data/app/smartlive.com.mx.smartlive-2/split_lib_slice_1_apk.apk!/lib/armeabi-v7a, /data/app/smartlive.com.mx.smartlive-2/split_lib_slice_2_apk.apk!/lib/armeabi-v7a, /data/app/smartlive.com.mx.smartlive-2/split_lib_slice_3_apk.apk!/lib/armeabi-v7a, /data/app/smartlive.com.mx.smartlive-2/split_lib_slice_4_apk.apk!/lib/armeabi-v7a, /data/app/smartlive.com.mx.smartlive-2/split_lib_slice_5_apk.apk!/lib/armeabi-v7a, /data/app/smartlive.com.mx.smartlive-2/split_lib_slice_6_apk.apk!/lib/armeabi-v7a, /data/app/smartlive.com.mx.smartlive-2/split_lib_slice_7_apk.apk!/lib/armeabi-v7a, /data/app/smartlive.com.mx.smartlive-2/split_lib_slice_8_apk.apk!/lib/armeabi-v7a, /data/app/smartlive.com.mx.smartlive-2/split_lib_slice_9_apk.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib, /system/vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
Gradel 应用程序:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 28
defaultConfig {
applicationId "smartlive.com.mx.smartlive"
minSdkVersion 19
targetSdkVersion 28
versionCode 5
versionName "5.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
//noinspection GradleCompatible
implementation 'com.android.support:design:28.0.0'
implementation 'androidx.appcompat:appcompat:1.0.0-rc02'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.gridlayout:gridlayout:1.0.0'
implementation 'com.android.support:support-vector-drawable:28.0.0'
implementation 'com.google.android.material:material:1.0.0-rc02'
implementation 'com.google.android.gms:play-services-maps:16.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
// Multidex
implementation 'com.android.support:multidex:1.0.3'
//Butterknife
implementation 'com.jakewharton:butterknife:10.0.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.0.0'
//Airbnb
implementation 'com.airbnb.android:lottie:2.5.4'
//Glide
implementation 'com.github.bumptech.glide:glide:4.8.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
//CircleImage
implementation 'de.hdodenhof:circleimageview:2.2.0'
//Volley
implementation 'com.mcxiaoke.volley:library-aar:1.0.0'
implementation 'com.loopj.android:android-async-http:1.4.9'
implementation 'com.google.code.gson:gson:2.8.5'
//FireBase
implementation 'com.google.firebase:firebase-core:16.0.8'
implementation 'com.google.firebase:firebase-auth:16.2.0'
//Facebook SDK
implementation 'com.facebook.android:facebook-android-sdk:4.41.0'
// Situm SDK
/**
implementation ('es.situm:situm-sdk:2.32.3@aar') {
transitive = true
}**/
implementation('es.situm:situm-wayfinding:0.2.0-alpha@aar') {
transitive = true
changing = true
}
}
apply plugin: 'com.google.gms.google-services'
aar don't carry dependencies 你需要发布到一个 maven 主机,传递依赖可以在 pom 中反映出来。
你能试试这个吗?
// implementation 'com.jakewharton:butterknife:10.1.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.1.0'
添加最新版本的 butterknife-compiler 而不指定库本身。
当我尝试在我的 Android 项目中使用 Butterknife 时出现以下异常:
添加外部库时出现错误,我不知道这是否会影响我,我 运行 整个项目都在 Android x
implementation('es.situm:situm-wayfinding:0.2.0-alpha@aar') {
transitive = true
changing = true
}
我似乎按照 Butterknife 的安装说明进行了操作,所以我不确定发生了什么。有什么我需要解决的吗? 他试图重建整个项目,但他仍然不断给我同样的错误。
E/AndroidRuntime: FATAL EXCEPTION: main
Process: smartlive.com.mx.smartlive, PID: 13851
java.lang.NoClassDefFoundError: Failed resolution of: Lbutterknife/ButterKnife$Action;
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
at androidx.fragment.app.Fragment.instantiate(Fragment.java:443)
at androidx.fragment.app.FragmentContainer.instantiate(FragmentContainer.java:50)
at androidx.fragment.app.Fragment.instantiate(Fragment.java:2403)
at androidx.fragment.app.FragmentManagerImpl.onCreateView(FragmentManager.java:3736)
at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:189)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:769)
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:964)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:854)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at es.situm.wayfinding.MapsFragment.onCreateView(Unknown Source)
at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2439)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1460)
at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1784)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1852)
at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManager.java:3269)
at androidx.fragment.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:3229)
at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:201)
at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:620)
at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:178)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1248)
at android.app.Activity.performStart(Activity.java:6683)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2687)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2789)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1527)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6251)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)
Caused by: java.lang.ClassNotFoundException: Didn't find class "butterknife.ButterKnife$Action" on path: DexPathList[[zip file "/data/app/smartlive.com.mx.smartlive-2/base.apk", zip file "/data/app/smartlive.com.mx.smartlive-2/split_lib_dependencies_apk.apk", zip file "/data/app/smartlive.com.mx.smartlive-2/split_lib_slice_0_apk.apk", zip file "/data/app/smartlive.com.mx.smartlive-2/split_lib_slice_1_apk.apk", zip file "/data/app/smartlive.com.mx.smartlive-2/split_lib_slice_2_apk.apk", zip file "/data/app/smartlive.com.mx.smartlive-2/split_lib_slice_3_apk.apk", zip file "/data/app/smartlive.com.mx.smartlive-2/split_lib_slice_4_apk.apk", zip file "/data/app/smartlive.com.mx.smartlive-2/split_lib_slice_5_apk.apk", zip file "/data/app/smartlive.com.mx.smartlive-2/split_lib_slice_6_apk.apk", zip file "/data/app/smartlive.com.mx.smartlive-2/split_lib_slice_7_apk.apk", zip file "/data/app/smartlive.com.mx.smartlive-2/split_lib_slice_8_apk.apk", zip file "/data/app/smartlive.com.mx.smartlive-2/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/smartlive.com.mx.smartlive-2/lib/arm, /data/app/smartlive.com.mx.smartlive-2/base.apk!/lib/armeabi-v7a, /data/app/smartlive.com.mx.smartlive-2/split_lib_dependencies_apk.apk!/lib/armeabi-v7a, /data/app/smartlive.com.mx.smartlive-2/split_lib_slice_0_apk.apk!/lib/armeabi-v7a, /data/app/smartlive.com.mx.smartlive-2/split_lib_slice_1_apk.apk!/lib/armeabi-v7a, /data/app/smartlive.com.mx.smartlive-2/split_lib_slice_2_apk.apk!/lib/armeabi-v7a, /data/app/smartlive.com.mx.smartlive-2/split_lib_slice_3_apk.apk!/lib/armeabi-v7a, /data/app/smartlive.com.mx.smartlive-2/split_lib_slice_4_apk.apk!/lib/armeabi-v7a, /data/app/smartlive.com.mx.smartlive-2/split_lib_slice_5_apk.apk!/lib/armeabi-v7a, /data/app/smartlive.com.mx.smartlive-2/split_lib_slice_6_apk.apk!/lib/armeabi-v7a, /data/app/smartlive.com.mx.smartlive-2/split_lib_slice_7_apk.apk!/lib/armeabi-v7a, /data/app/smartlive.com.mx.smartlive-2/split_lib_slice_8_apk.apk!/lib/armeabi-v7a, /data/app/smartlive.com.mx.smartlive-2/split_lib_slice_9_apk.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib, /system/vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
Gradel 应用程序:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 28
defaultConfig {
applicationId "smartlive.com.mx.smartlive"
minSdkVersion 19
targetSdkVersion 28
versionCode 5
versionName "5.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
//noinspection GradleCompatible
implementation 'com.android.support:design:28.0.0'
implementation 'androidx.appcompat:appcompat:1.0.0-rc02'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.gridlayout:gridlayout:1.0.0'
implementation 'com.android.support:support-vector-drawable:28.0.0'
implementation 'com.google.android.material:material:1.0.0-rc02'
implementation 'com.google.android.gms:play-services-maps:16.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
// Multidex
implementation 'com.android.support:multidex:1.0.3'
//Butterknife
implementation 'com.jakewharton:butterknife:10.0.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.0.0'
//Airbnb
implementation 'com.airbnb.android:lottie:2.5.4'
//Glide
implementation 'com.github.bumptech.glide:glide:4.8.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
//CircleImage
implementation 'de.hdodenhof:circleimageview:2.2.0'
//Volley
implementation 'com.mcxiaoke.volley:library-aar:1.0.0'
implementation 'com.loopj.android:android-async-http:1.4.9'
implementation 'com.google.code.gson:gson:2.8.5'
//FireBase
implementation 'com.google.firebase:firebase-core:16.0.8'
implementation 'com.google.firebase:firebase-auth:16.2.0'
//Facebook SDK
implementation 'com.facebook.android:facebook-android-sdk:4.41.0'
// Situm SDK
/**
implementation ('es.situm:situm-sdk:2.32.3@aar') {
transitive = true
}**/
implementation('es.situm:situm-wayfinding:0.2.0-alpha@aar') {
transitive = true
changing = true
}
}
apply plugin: 'com.google.gms.google-services'
aar don't carry dependencies 你需要发布到一个 maven 主机,传递依赖可以在 pom 中反映出来。
你能试试这个吗?
// implementation 'com.jakewharton:butterknife:10.1.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.1.0'
添加最新版本的 butterknife-compiler 而不指定库本身。