摇篮返回包不存在 [英] Gradle returns package does not exists
问题描述
我想给GSON库添加到我的Android项目(我使用的是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屋!