解析失败:com.google.code.gson:gson.2.2.2
Failed to resolve: com.google.code.gson:gson.2.2.2
我将项目从 eclipse 导入到 android studio,并在将项目与 gradle 文件同步后收到上述消息。我是 android studio 的新手,不知道如何解决这个错误。
以下是 Gradle 文件。
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
defaultConfig {
applicationId "com.s5.selfiemonkey1"
minSdkVersion 14
targetSdkVersion 14
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_6
targetCompatibility JavaVersion.VERSION_1_6
}
productFlavors {
}
}
dependencies {
compile 'com.android.support:support-v4:18.0.0'
compile 'com.google.android.gms:play-services:+'
compile 'com.google.code.gson:gson:2.2.2'
compile files('libs/AF-Android-SDK.jar')
compile files('libs/AndroidSwipeLayout-v1.1.8.jar')
compile files('libs/FlurryAnalytics-5.3.0.jar')
compile files('libs/android-viewbadger.jar')
compile files('libs/commons-codec-1.4.jar')
compile files('libs/google-play-services.jar')
compile files('libs/okhttp-2.5.0.jar')
compile files('libs/okio-1.6.0.jar')
compile files('libs/parcelgen.jar')
compile files('libs/scribe-1.1.2.jar')
}
从项目
构建 Gradle
// 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:1.2.3'
}
}
allprojects {
repositories {
jcenter()
}
}
请指教。提前致谢。
目前Gson的最新版本是2.3.1https://github.com/google/gson/releases
试试 compile 'com.google.code.gson:gson:2.3.1'
您必须使用项目结构在依赖项中添加 Gson 库,现在要更新 gradle,以便将 .jar 文件添加到您的 build.gradle 文件中,例如
dependencies {
compile files('libs/gson-2.2.4.jar')
}
如果有效,请尝试将其更改为
dependencies{
compile 'com.google.code.gson:gson:2.2.+'
}
确保您也已连接到互联网,以便通过 maven 存储库在线下载 jar。
由于 GSon 在 mavenCentral 中,您必须在 buidscripts 阶段添加 mavenCentral()。
我将项目从 eclipse 导入到 android studio,并在将项目与 gradle 文件同步后收到上述消息。我是 android studio 的新手,不知道如何解决这个错误。
以下是 Gradle 文件。
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
defaultConfig {
applicationId "com.s5.selfiemonkey1"
minSdkVersion 14
targetSdkVersion 14
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_6
targetCompatibility JavaVersion.VERSION_1_6
}
productFlavors {
}
}
dependencies {
compile 'com.android.support:support-v4:18.0.0'
compile 'com.google.android.gms:play-services:+'
compile 'com.google.code.gson:gson:2.2.2'
compile files('libs/AF-Android-SDK.jar')
compile files('libs/AndroidSwipeLayout-v1.1.8.jar')
compile files('libs/FlurryAnalytics-5.3.0.jar')
compile files('libs/android-viewbadger.jar')
compile files('libs/commons-codec-1.4.jar')
compile files('libs/google-play-services.jar')
compile files('libs/okhttp-2.5.0.jar')
compile files('libs/okio-1.6.0.jar')
compile files('libs/parcelgen.jar')
compile files('libs/scribe-1.1.2.jar')
}
从项目
构建 Gradle// 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:1.2.3'
}
}
allprojects {
repositories {
jcenter()
}
}
请指教。提前致谢。
目前Gson的最新版本是2.3.1https://github.com/google/gson/releases
试试 compile 'com.google.code.gson:gson:2.3.1'
您必须使用项目结构在依赖项中添加 Gson 库,现在要更新 gradle,以便将 .jar 文件添加到您的 build.gradle 文件中,例如
dependencies {
compile files('libs/gson-2.2.4.jar')
}
如果有效,请尝试将其更改为
dependencies{
compile 'com.google.code.gson:gson:2.2.+'
}
确保您也已连接到互联网,以便通过 maven 存储库在线下载 jar。
由于 GSon 在 mavenCentral 中,您必须在 buidscripts 阶段添加 mavenCentral()。