2016-05-03 65 views
0

我正在使用Gradle 2.13并尝试在readhat中构建Android apk并且系统没有Internet访问权限。 我正在尝试构建Android离线版。但是它抛出了一些异常,无​​法弄清楚出了什么问题。使用Gradle在离线模式下在Redhat中构建Android APK

主要的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

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

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

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

不要混淆gradle这个分布和gradle这个的Android插件。

您可以将文件 gradle/wrapper/gradle-wrapper.properties

例如,在定义一个项目中使用的gradle这个分布:

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

谢谢加布里埃莱,我会尝试。 它会影响正常的android studio构建? 我正在签出Linux环境中的代码并进行构建。 我能否将distributionURL指向本地路径? –

+0

不能正常工作:( –

+0

@MadhukarHebbar当然,您不能更改该插件的离线工作方式,您至少需要连接一次。 –

相关问题