微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

无法使用Gradle构建Android应用程序,但使用sudo除外

我正在尝试使用gradle构建一个简单的’hello world’安卓应用程序.如果我发出命令它会建立好

sudo ./gradlew build –> builds fine

但没有sudo,

./gradlew build –> shows following error

FAILURE: Build Failed with an exception.

* What went wrong:
A problem occurred configuring project ':MyStudioApplication'.
> Failed to notify project evaluation listener.
   > Could not resolve all dependencies for configuration ':MyStudioApplication:_DebugCompile'.
      > Could not find any version that matches com.android.support:appcompat-v7:+.
        required by:
            workspace:MyStudioApplication:unspecified

* 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: 12.621 secs

以下是我的build.gradle

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.6.+'
    }
}
apply plugin: 'android'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 19
    buildToolsversion "19.0.0"

    defaultConfig {
        minSdkVersion 7
        targetSdkVersion 19
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:+'
}

请帮忙

最佳答案
在这里黑暗中拍摄,您可能已经使用sudo运行初始gradle构建,这可能导致工件被下载并且被打包为root并且普通用户无法访问.要测试此假设,您可能需要重命名本地存储库,其中gradle下载依赖项并重新运行gradle作为标准用户.

原文地址:https://www.jb51.cc/android/430991.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐