在android中添加依赖项时出错

时间:2016-05-15 09:46:09

标签: android android-studio dependencies

当我有以下代码时,gradle成功构建。

 compile 'com.afollestad.material-dialogs:core:0.8.5.9'

但是当我添加下面的依赖时,它声明给我错误。

Error:Failed to resolve: com.android.support:appcompat-v7:23.4.0
<a href="install.m2.repo">Install Repository and sync project</a><br><a href="openFile">Open File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog</a>

错误

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.zriton.udhaar"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
ext {
    supportLibVersion = '23.2.1'  // variable that can be referenced to keep support libs consistent
}
repositories {
    jcenter()
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile "com.android.support:appcompat-v7:${supportLibVersion}"
    compile "com.android.support:design:${supportLibVersion}"
    compile 'pl.pawelkleczkowski.customgauge:CustomGauge:1.0.1'
    compile "com.android.support:recyclerview-v7:${supportLibVersion}"
    compile "com.android.support:cardview-v7:${supportLibVersion}"
    compile 'com.rengwuxian.materialedittext:library:2.1.4'
    compile 'com.loopj.android:android-async-http:1.4.9'
    compile 'com.wdullaer:materialdatetimepicker:2.3.0'



    compile 'com.afollestad.material-dialogs:core:0.8.5.9'

}

任何建议。 感谢

完成gradle文件

 function roundRating($rating) {
    if( $rating > 5) {
          return 5; // Note: assuming the >5 case of 0 was a bug and it was meant to cap it to 5
    } elseif( $rating < 0 ) {
          return 0;
    }

    $number = floor($rating);
    $remainder =  $rating * 10 % 10;

    if( $remainder <= 2 ) {
      return $number;
    } elseif( $remainder >= 8 ) {
      return $number + 1;
    } else {
      return $number + 0.5;
    }
  }

  echo roundRating(3.4); // 3.5
  echo roundRating( 3.0) ; // 3
  echo roundRating( 6) ; // 5
  echo roundRating( 3.8) ; // 4

3 个答案:

答案 0 :(得分:3)

您没有安装最新版本的Google库。 23.2.1应为23.4.0。

解决方案位于底部,&#34; Install Repository&#34;

答案 1 :(得分:1)

听起来您需要在Android SDK Manager中安装“Android Support Repository”。

如果您的路径上有Android工具,只需转到终端并运行:

$ android

您也可以通过Android Studio&gt;访问它工具&gt; Android&gt; SDK Manager。

答案 2 :(得分:0)

您使用的支持库是23.2.1,但错误显示为23.4.0,将当前版本替换为23.4.0并尝试同步项目