错误:java.lang.NoClassDefFoundError:无法初始化类org.gradle.internal.resource.transport.http.AlwaysRedirectRedirectStrategy

时间:2017-03-14 07:19:29

标签: java android android-studio android-gradle

我最近更新了Android Studio to 2.3。当我尝试打开在AS 2.2中运行的现有项目时,我在gradle中给出了以下错误:

  

错误:java.lang.NoClassDefFoundError:无法初始化类   org.gradle.internal.resource.transport.http.AlwaysRedirectRedirectStrategy

当我重新启动AS时,它显示错误

Error:Unable to load class 'org.apache.commons.logging.LogFactory'.

此意外错误的可能原因包括:

  • Gradle的依赖关系缓存可能已损坏(这有时会在网络连接超时后发生。) 重新下载依赖项和同步项目(需要网络)
  • Gradle构建过程(守护程序)的状态可能已损坏。停止所有Gradle守护进程可以解决此问题。 停止Gradle构建过程(需要重新启动)
  • 您的项目可能正在使用第三方插件,该插件与项目中的其他插件或项目请求的Gradle版本不兼容。
对于损坏的Gradle进程,您还可以尝试关闭IDE,然后终止所有Java进程。

我的项目是:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.0'
        classpath 'com.google.gms:google-services:3.0.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
    repositories {
        maven { url "https://jitpack.io" }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

我的模块级别是:

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/public' }
}



dependencies {
    compile('com.crashlytics.sdk.android:crashlytics:2.6.6@aar') {
        transitive = true;
    }
    compile 'com.android.support:support-v4:25.2.0'
    compile 'com.android.support:leanback-v17:25.2.0'
    compile 'com.android.support:cardview-v7:25.2.0'
}
android {
    compileSdkVersion 25
    buildToolsVersion '25.0.2'
    defaultConfig {
        applicationId 'com.example.app'
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 3
        versionName "1.0.2"
        multiDexEnabled true
    }

    signingConfigs {
        release {
            keyAlias 'asda'
            keyPassword 'asdas'
            storeFile file('/home/.playstore/asda/asd.jks')
            storePassword 'asda'
        }
    }

    buildTypes {
        release {
            //shrinkResources true
            //minifyEnabled true
            //proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
        }
    }
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/ASL2.0'
    }
    useLibrary 'org.apache.http.legacy'
    repositories {
        mavenCentral()
        maven { url "https://repo.commonsware.com.s3.amazonaws.com" }
        maven {
            url "https://jitpack.io"
        }
    }
    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        testCompile 'junit:junit:4.12'
        compile 'com.android.support:appcompat-v7:25.2.0'
        compile 'com.android.support:design:25.2.0'
        compile 'com.android.support:multidex:1.0.1'
        compile 'org.apache.commons:commons-io:1.3.2'
        compile('org.apache.httpcomponents:httpmime:4.3.6') {
            exclude module: "httpclient"
        }
        compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
        compile 'org.apache.commons:commons-lang3:3.4'
        compile 'org.codehaus.jackson:jackson-mapper-asl:1.9.13'
        //compile 'com.google.android.gms:play-services-gcm:8.3.0'
        compile 'com.google.firebase:firebase-core:10.0.1'
        compile 'com.google.firebase:firebase-messaging:10.0.1'
        compile 'com.android.support:recyclerview-v7:25.2.0'
        compile 'joda-time:joda-time:2.9.2'
        compile 'com.squareup.picasso:picasso:2.5.2'
        compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
        compile 'io.reactivex:rxjava:1.1.6'
        compile 'com.github.Cutta:TagView:1.3'
        compile 'com.github.PhilJay:MPAndroidChart:v3.0.1'
    }
    productFlavors {
    }
    lintOptions {
        checkReleaseBuilds false
        // Or, if you prefer, you can continue to check for errors in release builds,
        // but continue the build even when errors are found:
        abortOnError false
    }
}
apply plugin: 'com.google.gms.google-services'

0 个答案:

没有答案