Intellij Idea import gradle project error - “Cause: unexpected end of block data”

前端 未结 9 514
一向
一向 2020-12-19 02:02

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条回答
  • 2020-12-19 02:33

    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.

    0 讨论(0)
  • 2020-12-19 02:35

    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 .

    0 讨论(0)
  • 2020-12-19 02:35

    yeah,

    STEP 1: open the module build.gradle and find buildToolsVersion.

    STEP 2: modified the value to the warning value.

    0 讨论(0)
  • 2020-12-19 02:37

    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.

    0 讨论(0)
  • 2020-12-19 02:42

    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$

    0 讨论(0)
  • 2020-12-19 02:52

    Just open app/src/main/build.gradle and Android Studio will probably make a yellow highlight over the text version of buildToolsVersion

    apply plugin: 'android'
    
    android {
        compileSdkVersion 19
        buildToolsVersion "19.1.0"  //<--- THIS PART WILL BE HIGHLIGHTED
    
        defaultConfig {
        ...
    

    This means that Gradle has tried to compile with the wrong version of Gradle build tool installed. Usually the version will be lower.

    Open then Tools->Android->SDK Manager and find the highest version of Android SDK Build-Tools and wrote that version. In my case, it's 19.1.

    enter image description here

    Recompile and it will work.

    0 讨论(0)
提交回复
热议问题