将Android Studio项目导入到Intellij错误的gradle版本

时间:2014-12-23 12:41:29

标签: android intellij-idea gradle android-studio

我将Android Studio项目导入到Intellij Idea 14.0.2时遇到了一些问题我使用了gradle版本的包装器。我和我的朋友在一个项目上合作,但是他在Android Studio工作,我更喜欢Intellij Idea(我知道它几乎一样,但我不喜欢有一堆IDE做同样的工作)...有什么建议吗?下面是来自intellij的日志

2014-12-23 13:27:20,243 [  94097]   INFO - s.plugins.gradle.GradleManager - Instructing gradle to use java from C:\Program Files\Java\jdk1.8.0_25 
2014-12-23 13:27:20,248 [  94102]   INFO - s.plugins.gradle.GradleManager - Instructing gradle to use java from C:\Program Files\Java\jdk1.8.0_25 
2014-12-23 13:27:20,271 [  94125]   INFO - .project.GradleExecutionHelper - Passing command-line args to Gradle Tooling API: [-Pandroid.injected.build.model.only=true, -Pandroid.injected.invoked.from.ide=true, --init-script, C:\Users\Hajto-Lenovo\AppData\Local\Temp\ijinit1.gradle] 
2014-12-23 13:27:25,409 [  99263]  ERROR - vice.AndroidProjectDataService - Failed to set up Android modules in project 'LanceIt' 
org.gradle.tooling.model.UnsupportedMethodException: Unsupported method: BaseArtifact.getJavaCompileTaskName().
The version of Gradle you connect to does not support that method.
To resolve the problem you can change/upgrade the target version of Gradle you connect to.
Alternatively, you can ignore this exception and read other information from the model.
    at org.gradle.tooling.model.internal.Exceptions.unsupportedMethod(Exceptions.java:33)
    at org.gradle.tooling.internal.adapter.ProtocolToModelAdapter$InvocationHandlerImpl.invoke(ProtocolToModelAdapter.java:240)
    at com.sun.proxy.$Proxy136.getJavaCompileTaskName(Unknown Source)
    at org.jetbrains.android.facet.AndroidFacet.updateGradleTaskNames(AndroidFacet.java:1154)
    at org.jetbrains.android.facet.AndroidFacet.syncSelectedVariant(AndroidFacet.java:1145)
    at com.android.tools.idea.gradle.customizer.android.AndroidFacetModuleCustomizer.configureFacet(AndroidFacetModuleCustomizer.java:96)
    at com.android.tools.idea.gradle.customizer.android.AndroidFacetModuleCustomizer.customizeModule(AndroidFacetModuleCustomizer.java:56)
    at com.android.tools.idea.gradle.customizer.android.AndroidFacetModuleCustomizer.customizeModule(AndroidFacetModuleCustomizer.java:42)
    at com.android.tools.idea.gradle.service.AndroidProjectDataService.customizeModule(AndroidProjectDataService.java:191)
    at com.android.tools.idea.gradle.service.AndroidProjectDataService.access$100(AndroidProjectDataService.java:64)
    at com.android.tools.idea.gradle.service.AndroidProjectDataService$1.run(AndroidProjectDataService.java:126)
    at com.intellij.openapi.command.WriteCommandAction$Simple.run(WriteCommandAction.java:166)
    at com.intellij.openapi.application.RunResult.run(RunResult.java:38)
    at com.intellij.openapi.command.WriteCommandAction$2$1.run(WriteCommandAction.java:114)
    at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:974)
    at com.intellij.openapi.command.WriteCommandAction$2.run(WriteCommandAction.java:111)
    at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:124)
    at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:99)
    at com.intellij.openapi.command.WriteCommandAction.performWriteCommandAction(WriteCommandAction.java:108)
    at com.intellij.openapi.command.WriteCommandAction.execute(WriteCommandAction.java:80)
    at com.android.tools.idea.gradle.service.AndroidProjectDataService.doImport(AndroidProjectDataService.java:114)
    at com.android.tools.idea.gradle.service.AndroidProjectDataService.importData(AndroidProjectDataService.java:97)
    at com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager.importData(ProjectDataManager.java:116)
    at com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager.importData(ProjectDataManager.java:98)
    at com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager.importData(ProjectDataManager.java:124)
    at com.android.tools.idea.gradle.project.ProjectSetUpTask$2$1$1.run(ProjectSetUpTask.java:117)
    at com.intellij.openapi.roots.impl.ProjectRootManagerImpl.mergeRootsChangesDuring(ProjectRootManagerImpl.java:325)
    at com.android.tools.idea.gradle.project.ProjectSetUpTask$2$1.execute(ProjectSetUpTask.java:112)
    at com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange.run(DisposeAwareProjectChange.java:36)
    at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil$6$1.run(ExternalSystemApiUtil.java:374)
    at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:974)
    at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil$6.run(ExternalSystemApiUtil.java:371)
    at com.intellij.util.ui.UIUtil.invokeLaterIfNeeded(UIUtil.java:2108)
    at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil.executeOnEdt(ExternalSystemApiUtil.java:391)
    at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil.executeProjectChangeAction(ExternalSystemApiUtil.java:369)
    at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil.executeProjectChangeAction(ExternalSystemApiUtil.java:365)
    at com.android.tools.idea.gradle.project.ProjectSetUpTask$2.run(ProjectSetUpTask.java:109)
    at com.intellij.ide.startup.impl.StartupManagerImpl$8.run(StartupManagerImpl.java:329)
    at com.intellij.ide.startup.impl.StartupManagerImpl$9.run(StartupManagerImpl.java:340)
    at com.intellij.util.ui.UIUtil.invokeLaterIfNeeded(UIUtil.java:2108)
    at com.intellij.ide.startup.impl.StartupManagerImpl.runWhenProjectIsInitialized(StartupManagerImpl.java:337)
    at com.android.tools.idea.gradle.project.ProjectSetUpTask.populateProject(ProjectSetUpTask.java:106)
    at com.android.tools.idea.gradle.project.ProjectSetUpTask.access$000(ProjectSetUpTask.java:46)
    at com.android.tools.idea.gradle.project.ProjectSetUpTask$1.run(ProjectSetUpTask.java:68)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:744)
    at java.awt.EventQueue.access$400(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:697)
    at java.awt.EventQueue$3.run(EventQueue.java:691)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:714)
    at com.intellij.ide.IdeEventQueue.e(IdeEventQueue.java:748)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:577)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:384)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
2014-12-23 13:27:25,410 [  99264]  ERROR - vice.AndroidProjectDataService - IntelliJ IDEA 14.0.2  Build #IU-139.659.2 
2014-12-23 13:27:25,410 [  99264]  ERROR - vice.AndroidProjectDataService - JDK: 1.8.0_25 
2014-12-23 13:27:25,410 [  99264]  ERROR - vice.AndroidProjectDataService - VM: Java HotSpot(TM) Server VM 
2014-12-23 13:27:25,410 [  99264]  ERROR - vice.AndroidProjectDataService - Vendor: Oracle Corporation 
2014-12-23 13:27:25,411 [  99265]  ERROR - vice.AndroidProjectDataService - OS: Windows 7 
2014-12-23 13:27:25,766 [  99620]   INFO - indexing.UnindexedFilesUpdater - Indexable files iterated in 21 ms 

gradle文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "myAppID"
        minSdkVersion 15
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile 'com.google.android.gms:play-services:6.1.71'
    compile 'com.mcxiaoke.volley:library:1.0.+'
    compile project(':swipeToDismissUndoListmaster')
}

道具:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.0.0'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

Gradle-wrapper.properties:

#Wed Apr 10 15:27:10 PDT 2013
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip

2 个答案:

答案 0 :(得分:3)

IntelliJ 14.0.2使用旧版本的Android gradle工具。

现在你应该只在build.gradle中恢复gradle工具:

Android工作室项目build.gradle

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

你的build.gradle

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

我想我在某处读过IntelliJ 14.0.3会解决这个问题。

答案 1 :(得分:1)

对于在尝试从VC构建最新Gradle项目时在Android Studio Beta中出现此错误的其他人,请转到帮助 - >再次检查更新以下载最新的可用Android Studio Beta版本以及您的项目应该成功构建(这可能会在将来发生变化,因为对Gradle进行了更多更改)。

您必须redownload Android Studio entirely,因为Android Studio Beta不允许将自身自动修补到1.0及更高版本。