Cannot build an Android app with Gradle, except with sudo

android, android-gradle-plugin, gradle, ubuntu, unix

Solution

Taking a shot in the dark here, you may have run your initial gradle build with sudo which may have caused the artifacts to be downloaded and permisionned to root and are not accessible to your regular user. To test this assumption you may want to rename your local repository where gradle downloads the dependencies and rerun gradle as the standard user.

Problem

I am trying to run a simple 'hello world' android app with gradle build. It builds fine if I issue the command sudo ./gradlew build --> builds fine But without 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 ``` following is my 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:+' } ``` Please help

Original source