繁体   English   中英

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

[英]android-studio : add libphonenumber library to project

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

因此,我在build.gradle(Module:app)中添加了以下代码:

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

但这给了我如下错误:

错误:在DefaultExternalModuleDependency {group ='com.android.support',name ='appcompat-v7',version ='上找不到参数[com.android.support:support-v4:24.2.1]的方法compile() 24.2.1',配置类型为org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency的“ default”}。

请从Android SDK Manager安装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'

注意:我最终从此处将jar添加到libs文件夹(我不想这样做)。 如果有人知道如何使用gradle完成此任务,欢迎您回答。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM