如何在Android Studio 3.0上解决这个问题Canary 1:无法解决:com.google.android:android:2.3.1

时间:2017-05-26 02:31:34

标签: android

当我更新Android Studio IDE时,一些问题阻止了我。 我非常感谢你的帮助。 像这样:

Error:Failed to resolve: com.google.android:android:2.3.1

安装存储库和同步项目
打开文件
在项目结构对话框中显示

这是信息:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':Lightning:preEnv_42DebugBuild'.
> Could not resolve all dependencies for configuration ':Lightning:env_42DebugCompileClasspath'.
   > Could not find com.google.android:android:2.3.1.
     Searched in the following locations:
         file:/Users/gongyasen/Desktop/Android/android-sdk-macosx/extras/m2repository/com/google/android/android/2.3.1/android-2.3.1.pom
         file:/Users/gongyasen/Desktop/Android/android-sdk-macosx/extras/m2repository/com/google/android/android/2.3.1/android-2.3.1.jar
         file:/Users/gongyasen/Desktop/Android/android-sdk-macosx/extras/google/m2repository/com/google/android/android/2.3.1/android-2.3.1.pom
         file:/Users/gongyasen/Desktop/Android/android-sdk-macosx/extras/google/m2repository/com/google/android/android/2.3.1/android-2.3.1.jar
         file:/Users/gongyasen/Desktop/Android/android-sdk-macosx/extras/android/m2repository/com/google/android/android/2.3.1/android-2.3.1.pom
         file:/Users/gongyasen/Desktop/Android/android-sdk-macosx/extras/android/m2repository/com/google/android/android/2.3.1/android-2.3.1.jar
         file:/Applications/Android Studio 3.0 Preview.app/Contents/gradle/m2repository/com/google/android/android/2.3.1/android-2.3.1.pom
         file:/Applications/Android Studio 3.0 Preview.app/Contents/gradle/m2repository/com/google/android/android/2.3.1/android-2.3.1.jar
         https://jitpack.io/com/google/android/android/2.3.1/android-2.3.1.pom
         https://jitpack.io/com/google/android/android/2.3.1/android-2.3.1.jar
         http://repo.baichuan-android.taobao.com/content/groups/BaichuanRepositories/com/google/android/android/2.3.1/android-2.3.1.pom
         http://repo.baichuan-android.taobao.com/content/groups/BaichuanRepositories/com/google/android/android/2.3.1/android-2.3.1.jar
         file:/Users/gongyasen/Desktop/Android/workspace/LightningWS/LightningWS/Lightning/libs/android-2.3.1.jar
         file:/Users/gongyasen/Desktop/Android/workspace/LightningWS/LightningWS/Lightning/libs/android.jar
     Required by:
         project :Lightning > org.jetbrains.anko:anko:0.10.0 > org.jetbrains.anko:anko-coroutines:0.10.0 > org.jetbrains.kotlinx:kotlinx-coroutines-android:0.13

* Try:
Run with --info or --debug option to get more log output.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':Lightning:preEnv_42DebugBuild'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:98)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:68)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:60)
    at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
    at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
    at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.execute(DefaultTaskGraphExecuter.java:248)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.execute(DefaultTaskGraphExecuter.java:239)
    at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:114)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:68)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:239)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:226)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:120)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:77)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:101)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:95)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:527)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:95)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
    at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:46)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: org.gradle.api.artifacts.ResolveException: Could not resolve all dependencies for configuration ':Lightning:env_42DebugCompileClasspath'.
    at org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$1.visitArtifacts(DefaultLenientConfiguration.java:148)
    at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration$ConfigurationArtifactCollection.ensureResolved(DefaultConfiguration.java:1198)
    at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration$ConfigurationArtifactCollection.getArtifacts(DefaultConfiguration.java:1176)
    at com.android.build.gradle.internal.tasks.AppPreBuildTask.checkAppWithAndroidLibAsCompileOnly(AppPreBuildTask.java:56)
    at com.android.build.gradle.internal.tasks.AppPreBuildTask.run(AppPreBuildTask.java:52)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
    at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.doExecute(DefaultTaskClassInfoStore.java:139)
    at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:132)
    at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:121)
    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:706)
    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:689)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.execute(ExecuteActionsTaskExecuter.java:115)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.execute(ExecuteActionsTaskExecuter.java:109)
    at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:114)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:63)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:109)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:90)
    ... 26 more
Caused by: org.gradle.internal.resolve.ModuleVersionNotFoundException: Could not find com.google.android:android:2.3.1.
Searched in the following locations:
    file:/Users/gongyasen/Desktop/Android/android-sdk-macosx/extras/m2repository/com/google/android/android/2.3.1/android-2.3.1.pom
    file:/Users/gongyasen/Desktop/Android/android-sdk-macosx/extras/m2repository/com/google/android/android/2.3.1/android-2.3.1.jar
    file:/Users/gongyasen/Desktop/Android/android-sdk-macosx/extras/google/m2repository/com/google/android/android/2.3.1/android-2.3.1.pom
    file:/Users/gongyasen/Desktop/Android/android-sdk-macosx/extras/google/m2repository/com/google/android/android/2.3.1/android-2.3.1.jar
    file:/Users/gongyasen/Desktop/Android/android-sdk-macosx/extras/android/m2repository/com/google/android/android/2.3.1/android-2.3.1.pom
    file:/Users/gongyasen/Desktop/Android/android-sdk-macosx/extras/android/m2repository/com/google/android/android/2.3.1/android-2.3.1.jar
    file:/Applications/Android Studio 3.0 Preview.app/Contents/gradle/m2repository/com/google/android/android/2.3.1/android-2.3.1.pom
    file:/Applications/Android Studio 3.0 Preview.app/Contents/gradle/m2repository/com/google/android/android/2.3.1/android-2.3.1.jar
    https://jitpack.io/com/google/android/android/2.3.1/android-2.3.1.pom
    https://jitpack.io/com/google/android/android/2.3.1/android-2.3.1.jar
    http://repo.baichuan-android.taobao.com/content/groups/BaichuanRepositories/com/google/android/android/2.3.1/android-2.3.1.pom
    http://repo.baichuan-android.taobao.com/content/groups/BaichuanRepositories/com/google/android/android/2.3.1/android-2.3.1.jar
    file:/Users/gongyasen/Desktop/Android/workspace/LightningWS/LightningWS/Lightning/libs/android-2.3.1.jar
    file:/Users/gongyasen/Desktop/Android/workspace/LightningWS/LightningWS/Lightning/libs/android.jar
Required by:
    project :Lightning > org.jetbrains.anko:anko:0.10.0 > org.jetbrains.anko:anko-coroutines:0.10.0 > org.jetbrains.kotlinx:kotlinx-coroutines-android:0.13
    at org.gradle.internal.resolve.result.DefaultBuildableComponentResolveResult.notFound(DefaultBuildableComponentResolveResult.java:38)
    at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainComponentMetaDataResolver.resolveModule(RepositoryChainComponentMetaDataResolver.java:88)
    at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainComponentMetaDataResolver.resolve(RepositoryChainComponentMetaDataResolver.java:59)
    at org.gradle.api.internal.artifacts.ivyservice.resolveengine.ComponentResolversChain$ComponentMetaDataResolverChain.resolve(ComponentResolversChain.java:85)
    at org.gradle.api.internal.artifacts.ivyservice.clientmodule.ClientModuleResolver.resolve(ClientModuleResolver.java:45)
    at org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder$ModuleVersionResolveState.resolve(DependencyGraphBuilder.java:661)
    at org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder$ModuleVersionResolveState.getMetaData(DependencyGraphBuilder.java:672)
    at org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder$DependencyEdge.calculateTargetConfigurations(DependencyGraphBuilder.java:297)
    at org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder$DependencyEdge.attachToTargetConfigurations(DependencyGraphBuilder.java:270)
    at org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder.traverseGraph(DependencyGraphBuilder.java:167)
    at org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder.resolve(DependencyGraphBuilder.java:104)
    at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DefaultArtifactDependencyResolver.resolve(DefaultArtifactDependencyResolver.java:88)
    at org.gradle.api.internal.artifacts.ivyservice.DefaultConfigurationResolver.resolveGraph(DefaultConfigurationResolver.java:137)
    at org.gradle.api.internal.artifacts.ivyservice.ShortCircuitEmptyConfigurationResolver.resolveGraph(ShortCircuitEmptyConfigurationResolver.java:73)
    at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingConfigurationResolver.resolveGraph(ErrorHandlingConfigurationResolver.java:66)
    at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration$8.execute(DefaultConfiguration.java:493)
    at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration$8.execute(DefaultConfiguration.java:485)
    at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:114)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:63)
    at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.resolveGraphIfRequired(DefaultConfiguration.java:485)
    at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.resolveToStateOrLater(DefaultConfiguration.java:461)
    at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.access$1500(DefaultConfiguration.java:115)
    at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration$ConfigurationFileCollection.getSelectedArtifacts(DefaultConfiguration.java:862)
    at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration$ConfigurationFileCollection.access$2500(DefaultConfiguration.java:797)
    ... 43 morea

项目gradle文件:

buildscript {
    ext.kotlin_version = '1.1.2-4'
    ext.anko_version = '0.10.0'
    ext.support_lib_version = '25.3.1'
    repositories {
        jcenter()
   }
   dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0-alpha1'
       classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
   }
}

模块gradle文件:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

repositories {
    jcenter()
    mavenCentral()
    maven { url "https://jitpack.io" }
    maven {
        url "http://repo.baichuan-android.taobao.com/content/groups/BaichuanRepositories"
    }

    flatDir {
        dirs 'libs'
    }
}

dependencies {
    compile project(':pulltorefresh')
    compile project(':ViewPagerIndicator')
    compile project(':ToggleButtonLib')
    compile project(':SlidingMenu')
    compile project(':gesture-imageview')
    compile project(':xutilslib')
    compile project(':MPChartLib')
    compile files('libs/date4j.jar')
    compile files('libs/httpmime-4.1.3.jar')
    compile files('libs/SocialSDK_email.jar')
    compile files('libs/SocialSDK_sms.jar')
    compile files('libs/umeng-update-v2.6.0.1.jar')
    compile project(':multi-image-selector')
    compile project(':AutoFitTextView')
    compile files('libs/libphonenumber-5.8.jar')
    compile project(':RapidFloatingActionButton')
    compile project(':photoView')
    compile files('libs/umeng-onlineconfig_v1.0.0.jar')
    compile files('libs/renderscript-v8.jar')
    compile files('libs/umeng-analytics-v5.6.1.jar')
    compile 'com.android.support:multidex:1.0.1'
    compile files('libs/okhttp-2.6.0.jar')
    compile project(':xrecyclerview')
    compile project(':RecyclerViewStickyHeader')
    compile project(':AdvancedRecyclerview')
    compile project(':RecyclerTabLayout')
    compile project(':AndroidDesign')
    compile project(':Udesk_Separate_UI')
    compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
    compile 'io.reactivex.rxjava2:rxkotlin:2.0.1-RC1'
    compile 'io.reactivex.rxjava2:rxjava:2.0.9'
    compile 'com.github.florent37:expectanim:1.0.0'
    compile project(':topsnackbar')
    compile files('libs/libammsdk.jar')
    //    compile 'com.fenchtose:tooltip:0.1.5'
    compile project(':tooltip')
    compile('com.google.android:flexbox:0.3.0-alpha2') {
        exclude(module: 'appcompat-v7')
        exclude(module: 'support-annotations')
    }
    compile 'com.google.zxing:android-core:3.3.0'
    compile project(':PushSDK')
    compile 'pl.droidsonroids.gif:android-gif-drawable:1.2.4'
    compile 'com.github.wrdlbrnft:sorted-list-adapter:0.1.0.5'
    compile('com.github.wooplr:Spotlight:1.2.3') {
        exclude(module: 'appcompat-v7')
        exclude(module: 'support-annotations')
    }
    compile files('libs/SocialSDK_WeiXin_Full.jar')
    compile files('libs/umeng_social_net.jar')
    compile files('libs/umeng_social_api.jar')
    compile files('libs/umeng_social_tool.jar')
    compile files('libs/umeng_social_shareboard.jar')
    compile files('libs/zxing_core.jar')
    compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
    compile "org.jetbrains.anko:anko:$anko_version"
    compile "com.android.support:cardview-v7:$support_lib_version"
    compile 'com.zaaach:citypicker:1.1'
    testCompile 'junit:junit:4.12'

    compile 'com.tencent.bugly:crashreport:latest.release'
    //BUGLY SDK
    compile('com.taobao.android:alisdk-hotfix:2.0.9') {
        exclude(module: 'utdid4all')
    }
    compile 'com.squareup.retrofit2:adapter-rxjava2:2.2.0'
    compile 'com.squareup.retrofit2:retrofit:2.2.0'
    compile('com.squareup.retrofit2:converter-gson:2.2.0') {
        exclude(module: 'gson')
    }
    compile 'com.google.code.gson:gson:2.8.0'
    compile 'com.squareup.okhttp3:logging-interceptor:3.7.0'
    compile 'com.squareup.okhttp3:okhttp:3.7.0'
    compile 'com.squareup.okio:okio:1.12.0'
    compile 'com.github.simonpercic:oklog3:2.1.0'

}

android {
    dataBinding {
        enabled = true
    }

    signingConfigs {
        releaseSign {
            keyAlias KEY_ALIAS
            keyPassword KEY_PASSWORD
            storeFile file(STORE_FILE)
            storePassword STORE_PASSWORD
            v2SigningEnabled false
        }
    }
    compileSdkVersion COMPILE_SDK_VERSION as int
    buildToolsVersion BUILD_TOOLS_VERSION
    lintOptions {
        abortOnError false
    }
    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
            jniLibs.srcDirs = ['libs']
        }
        instrumentTest.setRoot('tests')
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }

    dexOptions {
        preDexLibraries true
        dexInProcess = true
        javaMaxHeapSize "4g"
    }

    packagingOptions {
        exclude 'LICENSE.txt'
        exclude 'META-INF/maven/com.squareup.okio/okio/pom.xml'
        exclude 'META-INF/maven/com.squareup.okio/okio/pom.properties'
    }

    applicationVariants.all { variant ->
        variant.outputs.all {
            def fileName = "Lightning_${variant.name}.apk"
            if(fileName.contains("website")){
                fileName = "lightning.apk"
            }

            outputFileName = fileName

        }
    }

    lintOptions {
        disable 'InvalidPackage'
        disable 'MissingTranslation'
    }

    defaultConfig {
        minSdkVersion MIN_SDK_VERSION as int
        targetSdkVersion TARGET_SDK_VERSION as int
        multiDexEnabled true
    }


    flavorDimensions "release"

    productFlavors {
        website {
            dimension 'release'
            buildConfigField("String", "CHANNEL_ID", '""')
        }

        jinritoutiao {
            buildConfigField("String", "CHANNEL_ID", '"170"')
        }

        qihu360 {
            buildConfigField("String", "CHANNEL_ID", '"171"')
        }

        baidutuiguang {
            buildConfigField("String", "CHANNEL_ID", '"172"')
        }

        wangyixinwen {
            buildConfigField("String", "CHANNEL_ID", '"173"')
        }

        qita {
            buildConfigField("String", "CHANNEL_ID", '"174"')
        }

        env_42 {
            buildConfigField("String", "CHANNEL_ID", '""')
        }
        env_production {
            buildConfigField("String", "CHANNEL_ID", '"102"')
        }
        env_local {
            buildConfigField("String", "CHANNEL_ID", '""')
        }
    }

    productFlavors.all {
        flavor ->
            flavor.manifestPlaceholders = [
                    CHANNEL_VALUE: name,
            ]

            buildConfigField("String", "CHANNEL_VALUE", '"' + name + '"')

            versionName '2.7.7'
            versionCode 45
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFile PROGUARD_FILE
            signingConfig signingConfigs.releaseSign
        }
        debug {
            debuggable true
            minifyEnabled true
            proguardFile PROGUARD_FILE
            signingConfig signingConfigs.releaseSign
        }
    }

    useLibrary 'org.apache.http.legacy'
}

afterEvaluate {
    def task = tasks.findByName('assembleWebsiteRelease')
    if(task != null){
        task.doLast {
            copy {
                from 'build/outputs/mapping/website/release/mapping.txt'
                into './'
            }
        }
    }
}

1 个答案:

答案 0 :(得分:10)

显然问题出在Anko上,新的 Android Studio 版本没有兼容性。正如 m43bloe (请参阅GitHub Anko issue)所示,您可以解决此问题:

compile("org.jetbrains.anko:anko:0.10.0") {
    exclude group: 'com.google.android', module: 'android'
}

写作的那一刻,一切正常。希望有所帮助!