将Android Studio更新为2.3.1并将gradle更新为3.3后,我注意到该应用程序正在崩溃某项活动。在更新之前,一切都很好。我浪费了一天这个东西,我似乎无法弄清楚为什么我会得到 a 'java.lang.NoClassDefFoundError:解析失败:Landroid / support / v4 / animation / AnimatorCompatHelper;'致命异常。
我还会上传build.gradle文件中最重要的部分
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion ANDROID_BUILD_TOOLS
defaultConfig {
minSdkVersion 16
targetSdkVersion ANDROID_TARGET_SDK
}
signingConfigs {
release {
....
}
}
buildTypes {
release {
...
}
debug {
..
}
}
sourceSets.main {
..
}
flavorDimensions "abi", "countMode"
productFlavors {
...
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
}
buildToolsVersion '25.0.0'
}
repositories {
maven {
url "https://jitpack.io"
}
}
dependencies {
if (ENABLE_ABI_ARM7) armv7Compile project(path: ':countlib', configuration: 'armv7Release')
if (!USE_CUSTOM_OPENCV) {
if (ENABLE_ABI_X86) x86Compile project(path: ':countlib', configuration: 'x86Release')
if (ENABLE_ABI_ARM) armCompile project(path: ':countlib', configuration: 'armRelease')
if (ENABLE_ABI_MIPS) mipsCompile project(path: ':countlib', configuration: 'mipsRelease')
}
compile project(':photoviewlib')
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
compile 'com.android.support:recyclerview-v7:23.1.0'
compile 'com.google.android.gms:play-services-drive:10.2.1'
// Include the sdk as a dependency
compile ('com.onedrive.sdk:onedrive-sdk-android:1.2+') {
transitive = false
}
// Include the gson dependency
compile ('com.google.code.gson:gson:2.3.1')
// Include supported authentication methods for your application
compile ('com.microsoft.services.msa:msa-auth:0.8.+')
compile ('com.microsoft.aad:adal:1.1.+')
// HTTP client
compile 'com.google.http-client:google-http-client-gson:1.20.0' exclude module: 'httpclient'
compile "com.github.danielnilsson9:color-picker-view:1.4.0@aar"
compile 'com.github.crosswall:Android-Coverflow:release-v1.0.4'
compile 'com.dropbox.core:dropbox-core-sdk:2.1.2'
}
这是完整的异常堆栈:
java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/animation/AnimatorCompatHelper;
at android.support.v7.widget.DefaultItemAnimator.resetAnimation(DefaultItemAnimator.java:513)
at android.support.v7.widget.DefaultItemAnimator.animateRemove(DefaultItemAnimator.java:187)
at android.support.v7.widget.SimpleItemAnimator.animateDisappearance(SimpleItemAnimator.java:86)
at android.support.v7.widget.RecyclerView.animateDisappearance(RecyclerView.java:3046)
at android.support.v7.widget.RecyclerView.access$700(RecyclerView.java:144)
at android.support.v7.widget.RecyclerView$4.processDisappeared(RecyclerView.java:416)
at android.support.v7.widget.ViewInfoStore.process(ViewInfoStore.java:201)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2931)
at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3071)
at android.view.View.layout(View.java:17945)
at android.view.ViewGroup.layout(ViewGroup.java:5812)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1742)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1494)
at android.view.View.layout(View.java:17945)
at android.view.ViewGroup.layout(ViewGroup.java:5812)
at android.support.design.widget.CoordinatorLayout.layoutChild(CoordinatorLayout.java:1037)
at android.support.design.widget.CoordinatorLayout.onLayoutChild(CoordinatorLayout.java:747)
at android.support.design.widget.ViewOffsetBehavior.onLayoutChild(ViewOffsetBehavior.java:42)
at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onLayoutChild(AppBarLayout.java:1133)
at android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:760)
at android.view.View.layout(View.java:17945)
at android.view.ViewGroup.layout(ViewGroup.java:5812)
at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:1192)
at android.view.View.layout(View.java:17945)
at android.view.ViewGroup.layout(ViewGroup.java:5812)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:344)
at android.widget.FrameLayout.onLayout(FrameLayout.java:281)
at android.view.View.layout(View.java:17945)
at android.view.ViewGroup.layout(ViewGroup.java:5812)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1742)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1494)
at android.view.View.layout(View.java:17945)
at android.view.ViewGroup.layout(ViewGroup.java:5812)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:344)
at android.widget.FrameLayout.onLayout(FrameLayout.java:281)
at android.view.View.layout(View.java:17945)
at android.view.ViewGroup.layout(ViewGroup.java:5812)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1742)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1494)
at android.view.View.layout(View.java:17945)
at android.view.ViewGroup.layout(ViewGroup.java:5812)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:344)
at android.widget.FrameLayout.onLayout(FrameLayout.java:281)
at com.android.internal.policy.PhoneWindow$DecorView.onLayout(PhoneWindow.java:3178)
at android.view.View.layout(View.java:17945)
at android.view.ViewGroup.layout(ViewGroup.java:5812)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2716)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2417)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1487)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7450)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:920)
at android.view.Choreographer.doCallbacks(Choreographer.java:695)
at android.view.Choreographer.doFrame(Choreographer.java:631)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographe
答案 0 :(得分:37)
通过以下问题的答案解决:Android Support Repo 46.0.0 with Android Studio 2.3
<强>解决方案:强>
在app.module末尾的 build.gradle 文件中添加了此脚本
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion '24.1.0'
}
}
}
}
希望这会有助于其他人。
答案 1 :(得分:0)
尝试此操作将解决错误
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion '25.3.0'
}
}
}
}