0

After updating cordova to new version 6.1.0 and android platform in cordova to 5.1.1, when run coroda build android.

What went wrong:

A problem occurred configuring root project 'android'.

Could not resolve all dependencies for configuration ':classpath'.

Could not find com.android.tools.build:gradle:1.5.0.

Required by:

:android:unspecified

Could not HEAD 'https://repo1.maven.org/maven2/com/android/tools/build/gradle/1.5.0/gradle-1.5.0.pom'

Required by:

peer not authenticated

Try:

Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Do you have any idea how to solve my problem?

Tazani
  • 39
  • 6

1 Answers1

0

I have faced a similar problem behind a proxy, and I have not been able to let maven download gradle, so I did this solution.

Download gradle manually, place it in your root of folders project.

My folders schema

1. Developer (folder)
  1.1 Projects (folder)
     1.1.1 project1 (folder)
     1.1.2 project2 (folder)
  1.2 gradle-2.2.1-all.zip (file)

Then I made this hook, to override the url to gradle in the gradeBuilder.js, to a local one

#!/usr/bin/env node

//Hook to change the path to the gradle to find the local one, because the proxy doesn't allow
//to connect o an https server

var fs = require('fs');
var path = require('path');

var rootdir = ".",
  androidroot = rootdir + "/platforms/android";

function replace_string_in_file(filename, to_replace, replace_with) {
  var data = fs.readFileSync(filename, 'utf8');

  if(data.indexOf(replace_with) > -1){
    console.log('File already contains required text. Nothing to do.');
  } else {
    console.log(new RegExp(to_replace, "g"));
    var result = data.replace(new RegExp(to_replace, "g"), replace_with);
    //console.log(result);
    fs.writeFileSync(filename, result, 'utf8');
    console.log('Changed Build Gradle Path to local successfully');
  }
}

if(fs.existsSync(androidroot)){
  var targetFile = androidroot + '/cordova/lib/builders/GradleBuilder.js';
  try{

    replace_string_in_file(targetFile, 'http\\\\\\\\://services.gradle.org/distributions/gradle-2.2.1-all.zip', '../../../../../../gradle-2.2.1-all.zip');
  } catch(e){
    console.log("File " + targetFile + " modified successfully");
  }
}

And placed it in the hooks/before_build folder of the project.

Hope it helps!

Víctor
  • 3,029
  • 3
  • 28
  • 43