Intellij Idea import gradle project error - “Cause

2019-01-26 07:09发布

While importing project as gradle have error Cause: unexpected end of block data. Project has several modules. I'm using Idea 132.719 and 1.8 gradle.

9条回答
smile是对你的礼貌
2楼-- · 2019-01-26 07:26

I had the same problem. Turned out the build.gradle specified a buildToolsVersion that was not installed:

android {
    buildToolsVersion "18.1"
    ...
}

while I only had 18.1.1 installed. Changing the buildToolsVersion in build.gradle fixed the problem for me. If this doesn't fix it for you, carefully inspecting the Intellij log might reveal the problem.

You can use the Android SDK Manager to see which version of the build tools is installed.

查看更多
做个烂人
3楼-- · 2019-01-26 07:35

I see in your comments, @SergeyB, that deleting .gradle in your user dir didn't help, but these steps resolved my issue (which had similar symptoms):

  • Delete .gradle directory from user dir (\Users\Mark.gradle)
  • Delete GRADLE_HOME environment variable, if it's set
  • Delete "manual" installs of Gradle (which shouldn't be needed, since Gradle will automatically download the necessary files when you run the gradlew wrapper)
  • Run "gradlew" from command-line, and confirm that new files are downloaded
  • Run a gradle build from the command-line (e.g., "gradlew clean assemble")
  • If you get an SDK version mismatch error, such as "failed to find target android-18", be sure to download the corresponding Android SDK (which can be done via the SDK Manager in Android Studio)
  • Once you can build from the command-line, try again from within the IDE
查看更多
你好瞎i
4楼-- · 2019-01-26 07:38

I had the same problem just after installation Android Studio version 0.6.1. The buildToolsVersion in \app\build.gradle pointed to correct version (19.0.3) however problem was fixed by changing it to version 19.1

android {
compileSdkVersion 19
buildToolsVersion "19.1" // <- This was changed from 19.0.3
...
查看更多
啃猪蹄的小仙女
5楼-- · 2019-01-26 07:42

Very late answer, and I'm sure you don't care anymore, but someone else might.

  1. File -> Invalidate caches / Restart
  2. Shutdown Android Studio
  3. Rename/remove .gradle folder in the user home directory
  4. Restart Android Studio let it download all the Gradle stuff it needs
  5. Gradle build success !
  6. Rebuild project.... success !

Hope this helps .

查看更多
Viruses.
6楼-- · 2019-01-26 07:45

I also had the same problem. I resolved this issue by setting ANDROID_HOME environmental variable. export ANDROID_HOME=/android_sdk_root_dir

Hope this helps.

查看更多
爷、活的狠高调
7楼-- · 2019-01-26 07:47

A good tip in with these type of problems if to use the command line version of gradlew, it can give you much more useful information, for the above problem it might look like this:

Error code from Android studio

Gradle 'bluetooth-new-circle' project refresh failed

Error:Cause: unexpected end of block data

Error code from command line gradlew with the same project:

~/source_code/bluetooth$ ./gradlew clean assembleDebug :AccessoryController:clean UP-TO-DATE :BluetoothAudioProxy:clean UP-TO-DATE :BluetoothGatt:clean UP-TO-DATE :ScaleMonitor:clean UP-TO-DATE :UsbMonitor:clean UP-TO-DATE :AccessoryController:preBuild FAILED

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':AccessoryController:preBuild'.

    The SDK Build Tools revision (19.0.2) is too low for project ':AccessoryController'. Minimum required is 19.1.0

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 10.078 secs ~/source_code/bluetooth$

查看更多
登录 后发表回答