Reputation: 11268
I was trying to migrate a few projects to Android Studio this weekend and I've been hitting some roadblocks. My last attempt involved creating a simple Hello World Android project using Eclipse ADT w/ plugin version 22.0.5v201307292155-757759. I created the project, targetted Android version 4.2 w/ minimum SDK 2.3 and built with 4.3. I ran a quick build/run test on the AVD which went fine. I then Did the project export and generated my Gradle build files for Android studio as explained in the migration docs. When I tried to import into Android Studio 0.2.6 Build# AI-130.795381 using bundled gradle distribution (1.7) I get error: "Cause: failed to find target android-18" with a stacktrace in idea.log:
2013-08-31 16:04:31,465 [ 517146] INFO - ject.ProjectImportErrorHandler - Failed to import Gradle project at '/Users/clifton/workspace/MyOtherLilAndroid'
org.gradle.tooling.BuildException: Could not fetch model of type 'AndroidProject' using Gradle distribution 'http://services.gradle.org/distributions/gradle-1.6-bin.zip'.
at org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(ResultHandlerAdapter.java:55)
at org.gradle.tooling.internal.consumer.async.DefaultAsyncConnection$2.run(DefaultAsyncConnection.java:71)
When I try to use Gradle Wrapper (recommended) I get an error: Could not execute build using Gradle distribution 'http://services.gradle.org/distributions/gradle-1.6-bin.zip'. Build file '/Users/clifton/workspace/MyOtherLilAndroid/build.gradle' line: 9 A problem occurred evaluating root project 'MyOtherLilAndroid'. A problem occurred evaluating root project 'MyOtherLilAndroid'. SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
with the following stack trace in idea.log:
2013-08-31 16:05:24,414 [ 570095] INFO - s.plugins.gradle.GradleManager - Instructing gradle to use java from /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
2013-08-31 16:05:24,415 [ 570096] INFO - s.plugins.gradle.GradleManager - Instructing gradle to use java from /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
2013-08-31 16:05:27,840 [ 573521] WARN - nal.AbstractExternalSystemTask - Could not execute build using Gradle distribution 'http://services.gradle.org/distributions/gradle-1.6-bin.zip'.
Build file '/Users/clifton/workspace/MyOtherLilAndroid/build.gradle' line: 9
A problem occurred evaluating root project 'MyOtherLilAndroid'.
A problem occurred evaluating root project 'MyOtherLilAndroid'.
SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
com.intellij.openapi.externalSystem.model.ExternalSystemException: Could not execute build using Gradle distribution 'http://services.gradle.org/distributions/gradle-1.6-bin.zip'.
Build file '/Users/clifton/workspace/MyOtherLilAndroid/build.gradle' line: 9
A problem occurred evaluating root project 'MyOtherLilAndroid'.
A problem occurred evaluating root project 'MyOtherLilAndroid'.
SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
at org.jetbrains.plugins.gradle.service.project.GradleExecutionHelper.ensureInstalledWrapper(GradleExecutionHelper.java:198)
at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:66)
at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:44)
I tried downloading Gradle 1.7 and using that for the import but I get another error: "Cause: failed to find target android-18
Build file: '/Users/clifton/workspace/MyOtherLilAndroid/build.gradle'"
With the following stack trace in idea.log:
2013-08-31 16:08:01,214 [ 726895] INFO - s.plugins.gradle.GradleManager - Instructing gradle to use java from /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
2013-08-31 16:08:01,214 [ 726895] INFO - s.plugins.gradle.GradleManager - Instructing gradle to use java from /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
2013-08-31 16:08:09,075 [ 734756] INFO - ject.ProjectImportErrorHandler - Failed to import Gradle project at '/Users/clifton/workspace/MyOtherLilAndroid'
org.gradle.tooling.BuildException: Could not fetch model of type 'AndroidProject' using Gradle installation '/Users/clifton/java-apps/gradle-1.7'.
at org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(ResultHandlerAdapter.java:55)
at org.gradle.tooling.internal.consumer.async.DefaultAsyncConnection$2.run(DefaultAsyncConnection.java:71)
at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:680)
at org.gradle.tooling.internal.consumer.BlockingResultHandler.getResult(BlockingResultHandler.java:46)
at org.gradle.tooling.internal.consumer.DefaultModelBuilder.get(DefaultModelBuilder.java:46)
at com.android.tools.idea.gradle.project.ProjectResolver$1.fun(ProjectResolver.java:206)
at com.android.tools.idea.gradle.project.ProjectResolver$1.fun(ProjectResolver.java:199)
at org.jetbrains.plugins.gradle.service.project.GradleExecutionHelper.execute(GradleExecutionHelper.java:148)
at com.android.tools.idea.gradle.project.ProjectResolver.getAndroidProject(ProjectResolver.java:199)
at com.android.tools.idea.gradle.project.ProjectResolver.resolveProjectInfo(ProjectResolver.java:136)
at com.android.tools.idea.gradle.project.AndroidGradleProjectResolver$ProjectResolverFunctionFactory$1.fun(AndroidGradleProjectResolver.java:151)
at com.android.tools.idea.gradle.project.AndroidGradleProjectResolver$ProjectResolverFunctionFactory$1.fun(AndroidGradleProjectResolver.java:145)
at org.jetbrains.plugins.gradle.service.project.GradleExecutionHelper.execute(GradleExecutionHelper.java:148)
I've confirmed that ANDROID_HOME is set on my Mac via "~/.MacOSX/environment.plist" and in my "~/.bashrc" which is sourced by my "~/.bash_profile" lastly I've tried setting sdk.dir and ndk.dir in the project's local.prooperties. Using the bundled gradle I get this error in idea.log:
2013-08-31 16:14:15,943 [1101624] INFO - dle.util.AndroidGradleSettings - Found Android SDK home at '/Users/clifton/android-sdk-macosx' (from local.properties file)
2013-08-31 16:14:18,207 [1103888] INFO - ject.ProjectImportErrorHandler - Failed to import Gradle project at '/Users/clifton/workspace/MyOtherLilAndroid'
org.gradle.tooling.BuildException: Could not fetch model of type 'AndroidProject' using Gradle distribution 'http://services.gradle.org/distributions/gradle-1.6-bin.zip'.
and this stack trace with gradle wrapper:
2013-08-31 16:15:59,616 [1205297] WARN - nal.AbstractExternalSystemTask - Could not execute build using Gradle distribution 'http://services.gradle.org/distributions/gradle-1.6-bin.zip'.
Task 'wrapper' not found in root project 'MyOtherLilAndroid'.
com.intellij.openapi.externalSystem.model.ExternalSystemException: Could not execute build using Gradle distribution 'http://services.gradle.org/distributions/gradle-1.6-bin.zip'.
Task 'wrapper' not found in root project 'MyOtherLilAndroid'.
at org.jetbrains.plugins.gradle.service.project.GradleExecutionHelper.ensureInstalledWrapper(GradleExecutionHelper.java:198)
at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:66)
at
What gives? Has anyone managed to successfully migrate a project to Android Studio? Am I trying at a bad time? I understand the tools are still under heavy development. Please advise.
Upvotes: 3
Views: 3222
Reputation: 11268
I've found most of my answers to the above problems. My issues stemmed from having just opened a brand new MAcbook Pro and having installed all the tools (ADT/IntelliJ/Android Studio) fresh. The one compounding issue was the fact that I had two different Android SDKs installed, one bundled with ADT and the other bundled with Android Studio. I originally made a symlink to the ADT bundle SDK in my home drive (~/android-sdk-macosx) as all of my command line tools (in my other projects) were configured to look there. I started noticing the AVDs created in one wouldn't launch properly in the other which prompted me to replace my symlink above and point it to the AS SDK.
Long story lengthened... my mixup of the SDKs caused a project exported from ADT, which was still seeing build tools 18 in its bundled SDK to be non-importable in Android studio. The other errors were merely masking and confusing the underlying problem. (They were from futile attempts to force the project to import.)
Upvotes: 3