摇篮返回包不存在 [英] Gradle returns package does not exists

查看:117
本文介绍了摇篮返回包不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想给GSON库添加到我的Andr​​oid项目(我使用的是Andrdoid工作室发民)。

要添加库,我也改变了AppProject / AppName的/ build.gradle文件中是这样的:

  buildscript {
    库{
        mavenCentral()
    }
    依赖{
        类路径com.android.tools.build:gradle:0.4
    }
}
应用插件:'机器人'

库{
    mavenCentral()
}

依赖{
    编译文件(库/ Android的支持 -  v4.jar)
    编译com.google code.gson:GSON:2.2.4
}

安卓{
    compileSdkVersion 17
    buildToolsVersion17.0.0

    defaultConfig {
        的minSdkVersion 4
        targetSdkVersion 16
    }
}
 

一切似乎工作,直到我尝试使用它。

当我试图用它包含:

 进口com.google code.gson。
 

摇篮抱怨申明:

 摇篮:错误:包com.google不存在
 

解决方案

可能的复制:<一href="http://stackoverflow.com/questions/16840982/specifying-maven-dependencies-in-build-gradle-doesnt-work/16841156#16841156">Specifying在build.gradle Maven的依赖不起作用

(使用命令行,在你的项目的根目录下,运行: ./ gradlew清洁和放大器;&安培; ./gradlew建

I'm trying to add the gson library to my android project (I'm devloping using the Andrdoid-studio).

To add the library, I did changed the AppProject/AppName/build.gradle file in this way:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.4'
    }
}
apply plugin: 'android'

repositories {
    mavenCentral()
}

dependencies {
    compile files('libs/android-support-v4.jar')
    compile 'com.google.code.gson:gson:2.2.4'
}

android {
    compileSdkVersion 17
    buildToolsVersion "17.0.0"

    defaultConfig {
        minSdkVersion 4
        targetSdkVersion 16
    }
}

All seems to work until I try to use it.

When I try to include it with:

import com.google.code.gson;

Gradle complains affirming:

Gradle: error: package com.google does not exist

解决方案

Possible duplicate : Specifying Maven dependencies in build.gradle doesn't work

(Using the command line, in the root of your project, run : ./gradlew clean && ./gradlew build)

这篇关于摇篮返回包不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆