2014-01-10 38 views
5

我正嘗試使用gradle構建運行簡單的「hello world」android應用。如果我發出命令無法使用Gradle構建Android應用,除了使用sudo

須藤./gradlew建立它建立精細 - >建立精細

但沒有sudo,

./gradlew構建 - >顯示以下錯誤

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:+' 
} 

請幫

+0

是您發佈完整文件的「build.gradle」嗎?我沒有看到appcompat lib的依賴。 – owe

回答

4

以在黑暗中拍攝在這裏,你可能已經運行您最初的gradle這個建立與可能造成的假象下載和permisionned根,並且不訪問須藤你普通用戶。爲了測試這個假設,你可能需要重命名你的本地倉庫,在這個倉庫中,Gradle下載依賴關係,並以標準用戶身份重新運行Gradle。

+2

還要查看SDK文件夾中所有內容的權限。如果您以純根權限安裝了Google存儲庫,那麼當您構建爲非超級用戶時,它將無法讀取它。 –

相關問題