android - 将 IntelliJ 项目导入 Android Studio

标签 android gradle android-studio

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

"You must use a newer version of the Android Gradle plugin. The minimum supported version is 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
}
}

最佳答案

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

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'

但是,我强烈建议您重新处理对 support 和 Google 库的其他依赖项。最好不要将这些作为 jar 文件包含在内,而是通过它们的 Maven 坐标访问它们,就像使用 appcompat 和 Play Services 库一样。 (事实上​​,由于您已经包含了此处所示的 Play Services 库,因此您也不需要包含它的 jar)。

如果您删除那些依赖语句并转到 项目结构 > (你的模块) > 依赖 > + > 库依赖 它应该可以帮助你。

此外,使用 +不鼓励使用 appcompat 依赖项的符号;如果您下方的库更新,它可能会导致意外的构建损坏。 Project Structure 对话框可以帮助您提供此依赖项的显式版本号。

关于android - 将 IntelliJ 项目导入 Android Studio,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27336305/

相关文章:

java - IntelliJ 不显示堆栈跟踪

java - 如何在 Gradle >2.0 中查找 PMD 规则集名称

android - 如何从android中的gradle依赖项添加的外部库目录中删除jar文件?

java - 如何根据yml文件生成resttemplate?

使用相机捕获的 Android 图像不会保存在 android nougat 上的指定自定义文件夹中

javascript - react native : Native module AppStateModule tried to override AppStateModule for module name AppState

android - onOptionsItemSelected android 中的警报对话框

android - 如果 webview 中的 url 相同,如何开始第三个 Activity

firebase - 如何满足 'filter in' 条件的 'contains' firestore 数据?

android - 如何使用选择器设置文字大小?