Could not fetch model of type 'IdeaProject'

2019-01-18 11:39发布

问题:

I've downloaded and installed Android Studio with all the required dependencies such as JDK 1.7 and Gradle 1.6. I am able to import the projects and modules quite comfortably in Studio, but when I try to create a new project I am getting errors like this:

Since this is the new born IDE I couldn't find much details on this, except for this and this. Any help would be greatly appreciated.

回答1:

After to pass much time trying to resolve this, i reached a solution :

Are you using "Windows Version" of AS ?

Please follow these steps :

1 - Install the last version of JDK with respective JAVA_HOME variable.

2 - Download and Install Gradle1.6 with respective GRADLE_HOME variable,

http://www.gradle.org/docs/current/userguide/userguide_single.html#installation.

2 - Delete these folders:

    C:\Users\youruser\.AndroidStudioPreview
    C:\Users\youruser\.android
    C:\Users\youruser\.gradle

3 - Reopen Android Studio

Now probably it will works

There are a lot of bugs in "Early Access Preview"....



回答2:

The error dialog mentions Gradle 1.4

Android Studio requires the Gradle plugin 0.4 which requires Gradle 1.6



回答3:

I tried the environment variable and folder location stuff suggested, also made sure I had the latest version of Gradle, but that made no improvement. Then I ran Android Studio using an admin account, at which point all the errors disappeared. If you are able to, I suggest you do the same. This was on a Windows 7 box.



回答4:

For me, this problem was caused by my local.properties file showing a different path to the Android SDK. I do development on both Mac OS X and Windows and the properties file was showing my Mac OS X SDK path. Turns out, this file shouldnt even be checked into source control. Ooops!



回答5:

The fix for me was on the Known Issues page here: http://tools.android.com/knownissues

I changed

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

to:

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

Reopened Android Studio and voila!



回答6:

The best solution I found is to check-out some empty project, then import it rather than use the "New project" utility.



回答7:

I fixed the problem by downloading a fresh copy of AndroidStudio. During one of the updates something went wrong so I delete all config files and freshly downloaded the file from the Internet and then it worked fine for me.

(I'm on a Mac)



回答8:

If you are still receiving this error when creating a new project, then try opening the project (after error) and removing the following from your build.gradle file in your module.

dependencies {
compile 'com.android.support:support-v4:13.0.+'
}


回答9:

I resolved this by installing some extras from Android SDK what I did not think I needed: Google Repository and Google Play services. In addition of Android Support Repository.

When manually running gradle you get more meaningful error messages.