简体   繁体   English

导入android项目时出错(“Gradle location not incorrect”或“Cause:block data of block data”)

[英]Error while importing android project (“Gradle location is incorrect” or “Cause: unexpected end of block data”)

I want to import Android project in Android Studio and this is where the problem begins: 1) If I set Gradle home and click OK, I get the info: 我想在Android Studio中导入Android项目,这就是问题的开始:1)如果我将Gradle设置为Home并单击OK,我会得到以下信息: 在此输入图像描述

2) And secondly, if I try to run project I get the message: 2)其次,如果我尝试运行项目,我会收到消息: 在此输入图像描述

Trying both ways result in displaying messages above. 尝试两种方式都会导致显示上面的消息。 I have GRADLE_HOME, JAVA_HOME set correctly and ANDROID_HOME points to "sdk" directory in android-studio directory. 我正确设置了GRADLE_HOME,JAVA_HOME,并且ANDROID_HOME指向android-studio目录中的“sdk”目录。 Much appreciation for answer with the solution. 非常感谢您对解决方案的回答。

Point to the folder <gradle root folder>/libexec . 指向文件夹<gradle root folder>/libexec Things should start working. 事情应该开始奏效了。

Ok, I missed to download some build tools for specified android version, arrgh.. Anyway, thank you for your interest and the answers. 好吧,我错过了为指定的android版本下载一些构建工具,arrgh ..无论如何,谢谢你的兴趣和答案。 I am quite new to gradle and Android studio. 我是gradle和Android工作室的新手。 I have been developing android apps with intellij so far. 到目前为止,我一直在使用intellij开发Android应用程序。

That worked for me: 1. Open Android SDK Manager. 这对我有用:1。打开Android SDK Manager。 2. Make sure that "Build tools ..." libraries are downloaded and it should work properly. 2.确保下载“构建工具...”库并使其正常工作。

I'm going to respond to this cause I had a ton of problems. 我要回应这个原因我遇到了很多问题。

what I did was in linux 我做的是在linux中

in terminal 在终端

type "which gradle" 键入“哪个gradle”

if there is a symlink follow this until you see where your gradle is located. 如果有符号链接,请按照此操作,直到您看到您的gradle所在的位置。

mine was located in the following. 我的位于以下。

/usr/lib/gradle/4.2/bin/gradle /usr/lib/gradle/4.2/bin/gradle

so now just use 所以现在就用吧

/usr/lib/gradle/4.2/lib is what you want to put in intelliJ /usr/lib/gradle/4.2/lib是你想要放入intelliJ的东西

Try to use default gradle wrapper. 尝试使用默认的gradle包装器。 Android studio will do everything correctly. Android studio将正确完成所有工作。

I had the same problem (Cause: unexpected end of block data) while importing a project, and resolved by setting ANDROID_HOME. 我在导入项目时遇到了同样的问题(原因:块数据意外结束),并通过设置ANDROID_HOME解决了。 export ANDROID_HOME=/android_sdk_root_dir

I had a "Cause: unexpected end of block data" as well. 我有一个“原因:意外的块数据结束”。 What I did was installing the right SDK version for Android. 我所做的是为Android安装正确的SDK版本。 Check your build.gradle file. 检查build.gradle文件。 In my case I needed API level 18: 在我的情况下,我需要API级别18:

android {
    compileSdkVersion 18
    buildToolsVersion "18.1"

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 17
        versionCode 1
    }
...

}

I was facing the same issue, I went to http://gradle.org/gradle-download/ and downloaded the latest gradle. 我遇到了同样的问题,我去了http://gradle.org/gradle-download/并下载了最新的gradle。 I then linked my project to the path where i had saved the gradle, and everything worked 然后我将我的项目链接到我保存gradle的路径,一切正常

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM