在离线模式下使用Gradle在Redhat中构建Android APK

时间:2016-05-03 12:05:25

标签: android linux gradle android-gradle offline

我正在使用Gradle 2.13并尝试在readhat中构建android apk并且系统无法访问Internet。 我想在线下建立android apk。但它会抛出一些异常而无法弄清楚出了什么问题。

Main build.gradle

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

错误:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'PROJECT'.
> Could not resolve all dependencies for configuration ':classpath'.
   > Could not resolve com.android.tools.build:gradle:2.1.0.
     Required by:
         :PROJECT:unspecified
      > No cached version of com.android.tools.build:gradle:2.1.0 available for offline mode.
      > No cached version of com.android.tools.build:gradle:2.1.0 available for offline mode.

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

版本:

gradle -version
  

Gradle 2.13

有没有可用于在redhat / linux机器上构建离线apk的教程?

编辑:更新问题。

1 个答案:

答案 0 :(得分:1)

这是因为Android 2.13 的gradle插件不存在

最新的稳定版本是2.1.0。使用:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.0'
    }
}

请勿混淆 gradle distribution 用于gradle的android插件

您可以定义文件中项目使用的gradle分布  gradle/wrapper/gradle-wrapper.properties

例如:

   distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip