将IntelliJ项目导入Android studio

时间:2014-12-06 20:44:41

标签: android gradle android-studio

我有一个在Intellij 12.1.4中编译得很好的项目,但我想使用android studio因为xml编辑器。我的问题是,当我尝试将项目导入android studio 1.0 RC 4时,我得到的第一个错误是:

  

“您必须使用较新版本的Android Gradle插件。支持的最低版本为0.14.0”

我的原始build.gradle文件包含:

dependencies {
    classpath 'com.android.tools.build:gradle:0.5+'
}

现在只需将其更改为:

dependencies {
    classpath 'com.android.tools.build:gradle:0.14.0'
}

导致此错误:

Error:(17, 0) Could not find property 'files' on  org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler_Decorated@2e93ad.

有关尝试什么的任何建议?我的整个Build.gradle文件位于

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

dependencies {
compile files('libs/android-support-v4.jar')
compile files('libs/android-support-v7.jar')
//compile files('libs/GoogleAdMobAds.jar')
compile files('libs/libGoogleAnalyticsV2')
compile files('libs/google-play-services.jar')
compile files 'com.android.support:appcompat-v7:+'

compile files 'com.google.android.gms:play-services:4.0.30'
compile files('libs/amazon-ads-5.4.46.jar')

}

android {
compileSdkVersion 17
buildToolsVersion "17.0.0"

defaultConfig {
    minSdkVersion 7
    targetSdkVersion 16
}
}

1 个答案:

答案 0 :(得分:1)

此错误消息是因为您的两个依赖项语句无效。

compile files 'com.android.support:appcompat-v7:+'
compile files 'com.google.android.gms:play-services:4.0.30'

应该是:

compile 'com.android.support:appcompat-v7:+'
compile 'com.google.android.gms:play-services:4.0.30'

但是,我强烈建议您重新设计支持和Google库的其他依赖项。最好的做法是不要将这些包含在jar文件中,而是通过它们的Maven坐标访问它们,就像appcompat和Play Services库一样。 (事实上​​,既然您已经包含了Play Services库,如此处所示,您也不需要包含它的jar。)

如果删除这些依赖性声明并转到项目结构> (您的模块)>依赖性> +>图书馆依赖它可以帮助你。

此外,不鼓励对appcompat依赖项使用+表示法;如果库在您下面更新,它可能会导致意外的构建破坏。 “项目结构”对话框可以帮助您提供此依赖项的显式版本号。