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

前端之家收集整理的这篇文章主要介绍了无法使用Gradle构建Android应用程序,但使用sudo除外前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

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

sudo ./gradlew build –> builds fine

但没有sudo,

./gradlew build –> shows following error

  1. FAILURE: Build Failed with an exception.
  2. * What went wrong:
  3. A problem occurred configuring project ':MyStudioApplication'.
  4. > Failed to notify project evaluation listener.
  5. > Could not resolve all dependencies for configuration ':MyStudioApplication:_DebugCompile'.
  6. > Could not find any version that matches com.android.support:appcompat-v7:+.
  7. required by:
  8. workspace:MyStudioApplication:unspecified
  9. * Try:
  10. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
  11. BUILD Failed
  12. Total time: 12.621 secs

以下是我的build.gradle

  1. buildscript {
  2. repositories {
  3. mavenCentral()
  4. }
  5. dependencies {
  6. classpath 'com.android.tools.build:gradle:0.6.+'
  7. }
  8. }
  9. apply plugin: 'android'
  10. repositories {
  11. mavenCentral()
  12. }
  13. android {
  14. compileSdkVersion 19
  15. buildToolsVersion "19.0.0"
  16. defaultConfig {
  17. minSdkVersion 7
  18. targetSdkVersion 19
  19. }
  20. }
  21. dependencies {
  22. compile 'com.android.support:appcompat-v7:+'
  23. }

请帮忙

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

猜你在找的Android相关文章