android-studio:将libphonenumber库添加到项目中

时间:2016-09-16 09:30:55

标签: android build.gradle android-studio-2.2

我想将libphonenumber库添加到我的Android Studio项目中。

所以,我在build.gradle中添加了以下行(Module:app):

compile 'com.googlecode.libphonenumber:libphonenumber:7.6.1'

但是这给我的错误如下:

  

错误:找不到参数的方法compile()   [com.android.support:support-v4:24.2.1]上   DefaultExternalModuleDependency {组= 'com.android.support',   name ='appcompat-v7',version = '24 .2.1',configuration ='default'} of   类型   org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency。

     

请从Android SDK安装Android支持存储库   经理。打开Android SDK Manager

有谁知道原因和解决方案?

的build.gradle(项目:XXX):

// 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.2.0-rc2'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
        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()
    }
}

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

的build.gradle(模块:应用):

apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.2"
    defaultConfig {
        applicationId "com.xxx.android"
        minSdkVersion 17
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        vectorDrawables {
            useSupportLibrary = true
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

def SUPPORT_LIBRARY = "24.2.1"
def BUTTER_KNIFE_LIBRARY = "8.4.0"
def GLIDE_LIBRARY = "3.7.0"
def OK_HTTP_VERSION = "3.4.1"
def RETROFIT_VERSION = "2.1.0"
def GSON_VERSION = "2.7"
def FIREBASE_VERSION = "9.4.0"

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile "com.android.support:appcompat-v7:$SUPPORT_LIBRARY"
    compile "com.android.support:support-v4:$SUPPORT_LIBRARY"
    compile "com.android.support:design:$SUPPORT_LIBRARY"

    compile "com.jakewharton:butterknife:$BUTTER_KNIFE_LIBRARY"
    apt "com.jakewharton:butterknife-compiler:$BUTTER_KNIFE_LIBRARY"

    compile "com.github.bumptech.glide:glide:$GLIDE_LIBRARY"

    compile "com.squareup.okhttp3:okhttp:$OK_HTTP_VERSION"
    compile "com.squareup.okhttp3:logging-interceptor:$OK_HTTP_VERSION"
    compile "com.squareup.retrofit2:retrofit:$RETROFIT_VERSION"
    compile "com.squareup.retrofit2:converter-gson:$RETROFIT_VERSION"
    compile "com.google.code.gson:gson:$GSON_VERSION"

    compile "com.google.firebase:firebase-messaging:$FIREBASE_VERSION"
    compile "com.google.firebase:firebase-crash:$FIREBASE_VERSION"
}

apply plugin: 'com.google.gms.google-services'

注意:我最终在herelibs文件夹中添加了jars(我不想这样做)。如果有人知道如何使用gradle完成此任务,欢迎您回答。

0 个答案:

没有答案