Could not resolve com.android.support:appcompat-v7:26.1.0 in Android Studio new project

后端 未结 14 1865
一生所求
一生所求 2020-11-30 07:22

I know about this questions:

Failed to resolve: com.android.support:cardview-v7:26.0.0 android

Could not resolve com.android.support:appcompat-v7:26.1.0 [dup

相关标签:
14条回答
  • 2020-11-30 08:11

    goto Android->sdk->build-tools directory make sure you have all the versions required . if not , download them . after that goto File-->Settigs-->Build,Execution,Depoyment-->Gradle

    choose use default gradle wapper (recommended)

    and untick Offline work

    gradle build finishes successfully for once you can change the settings

    If it dosent simply solve the problem

    check this link to find an appropriate support library revision

    https://developer.android.com/topic/libraries/support-library/revisions

    Make sure that the compile sdk and target version same as the support library version. It is recommended maintain network connection atleast for the first time build (Remember to rebuild your project after doing this)

    0 讨论(0)
  • 2020-11-30 08:13

    I tried all of the above and nothing worked for me.

    Then I followed Gradle Settings > Build Execution, Deployment > Gradle > Android Studio and checked "Disable embedded Maven repository".

    Did a build with this checked and the problem was solved.

    0 讨论(0)
  • 2020-11-30 08:13

    This issue seems to like the following.

    How to resolve repository certificate error in Gradle build

    Below steps may help:

    1. Add certificate to keystore-

    Import some certifications into Android Studio JDK cacerts from Android Studio’s cacerts.

    Android Studio’s cacerts may be located in

    {your-home-directory}/.AndroidStudio3.0/system/tasks/cacerts
    

    I used the following import command.

    $ keytool -importkeystore -v -srckeystore {src cacerts} -destkeystore {dest cacerts}
    

    2. Add modified cacert path to gradle.properties-

    systemProp.javax.net.ssl.trustStore={your-android-studio-directory}\\jre\\jre\\lib\\security\\cacerts
    systemProp.javax.net.ssl.trustStorePassword=changeit
    

    Ref : https://www.cresco.co.jp/blog/entry/2014//

    0 讨论(0)
  • 2020-11-30 08:15

    Just go to File\Settings\Gradle. Deselect the "Offline work" box. Now you can connect and download any necessary or missing dependencies

    0 讨论(0)
  • 2020-11-30 08:17

    Finally I fixed the problem by modifying build.gradle like this:

    android {
        compileSdkVersion 26
        buildToolsVersion "26.0.2"
    
        defaultConfig {
            minSdkVersion 16
            targetSdkVersion 26
        }
    }
    
    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation 'com.android.support:appcompat-v7:26.1.0'
        implementation 'com.android.support.constraint:constraint-layout:1.0.2'
        implementation 'com.android.support:design:26.1.0'
    }
    

    I've removed these lines as these will produce more errors:

    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    

    Also I had same problem with migrating an existing project from 2.3 to 3.0.1 and with modifying the project gradle files like this, I came up with a working solution:

    build.gradle (module app)

    android {
        compileSdkVersion 27
        buildToolsVersion "27.0.1"
    
        defaultConfig {
            applicationId "com.mobaleghan.tablighcalendar"
            minSdkVersion 16
            targetSdkVersion 27
        }
    
    dependencies {
        implementation 'com.android.support:appcompat-v7:25.1.0'
        implementation 'com.android.support:design:25.1.0'
        implementation 'com.android.support:preference-v7:25.1.0'
        implementation 'com.android.support:recyclerview-v7:25.1.0'
        implementation 'com.android.support:support-annotations:25.1.0'
        implementation 'com.android.support:support-v4:25.1.0'
        implementation 'com.android.support:cardview-v7:25.1.0'
        implementation 'com.google.android.apps.dashclock:dashclock-api:2.0.0'
    }
    

    Top level build.gradle

    buildscript {
        repositories {
            google()
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.0.1'
        }
    }
    
    allprojects {
        repositories {
            google()
            jcenter()
        }
    }
    
    0 讨论(0)
  • 2020-11-30 08:17

    try this :

    android {
        compileSdkVersion 26
        buildToolsVersion "26.0.1"
    defaultConfig {
    
            targetSdkVersion 26
        }
    
    }
    
    
    compile 'com.android.support:appcompat-v7:25.1.0'
    

    It has worked for me

    0 讨论(0)
提交回复
热议问题