支持Android P在linux服务器上编译

1.下载android-sdk-linux,默认官网下载的sdk,只有sdk tools,通过tools文件夹 下的android命令可以打开sdk manager,设置好代理,可以更新platform-tools,build-tools,platform,注意太老版本的Android SDK Tools版本,可能看不到最新的platform以及build-tools等。所以要先升级Android SDK Tools,再升级Android SDK Platform-tools以及Android SDK Build-tools以及Platform等。

2.Android SDK升级完后,需要更新Android Plugin for Gradle,就是放在/home/用户名/.m2/repository目录下,为了兼容老的版本,可以把新的版本和老的版本融合在一起,如/home/用户名/.m2/repository/com/android/tools/build/gradle/目录下有很多版本。2.2.3,3.1.3等,可以继续往上添加。

3.android-sdk-linux如果无法联网更新的话,可以下载好放到对应的目录。比较关键的几个就是上面提到的几个文件夹。

4.我在用gradle-4.4,Build-tools是27.0.3,Android Plugin for Gradle是3.1.3,

buildscript {
    repositories {
        mavenLocal()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'
    }
}

allprojects {
    repositories {
        jcenter()
        google()
    }
}

还是遇到了

> Task :UPTSM:compileReleaseJavaWithJavac 
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.


FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all files for configuration ':UPTSM:lintClassPath'.
> Could not resolve com.android.tools.lint:lint-gradle:26.1.3.
  Required by:
      project :UPTSM
   > Could not resolve com.android.tools.lint:lint-gradle:26.1.3.
      > Could not get resource 'https://jcenter.bintray.com/com/android/tools/lint/lint-gradle/26.1.3/lint-gradle-26.1.3.pom'.
         > Could not HEAD 'https://jcenter.bintray.com/com/android/tools/lint/lint-gradle/26.1.3/lint-gradle-26.1.3.pom'.
            > Connect to jcenter.bintray.com:443 [jcenter.bintray.com/108.168.243.150] failed: Connection refused (Connection refused)
   > Could not resolve com.android.tools.lint:lint-gradle:26.1.3.
      > Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/lint/lint-gradle/26.1.3/lint-gradle-26.1.3.pom'.
         > Could not HEAD 'https://dl.google.com/dl/android/maven2/com/android/tools/lint/lint-gradle/26.1.3/lint-gradle-26.1.3.pom'.
            > Connect to dl.google.com:443 [dl.google.com/203.208.41.73, dl.google.com/203.208.41.65, dl.google.com/203.208.41.72, dl.google.com/203.208.41.70, dl.google.com/203.208.41.64, dl.google.com/203.208.41.66, dl.google.com/203.208.41.67, dl.google.com/203.208.41.68, dl.google.com/203.208.41.69, dl.google.com/203.208.41.71, dl.google.com/203.208.41.78, dl.google.com/2401:3800:4002:805:0:0:0:1003] failed: Network is unreachable (connect failed)

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 9s
13 actionable tasks: 12 executed, 1 up-to-date
****************************************************************************
export uptsm.jar ERROR!!!!

这些错误。虽然在/home/ydzf/.m2/repository/com/android/tools/lint/lint-gradle/26.1.3/lint-gradle-26.1.3.jar

/home/ydzf/.m2/repository/com/android/tools/lint/lint-gradle/26.1.3/lint-gradle-26.1.3.pom这两个文件都是存在的,还是报错了。根据根据上一篇帖子,发现本地找的目录后,就把m2repository目录放在/home/ydzf/AndroidDev/android-sdk-linux/extras/m2repository这里就可以了。

终于可以编译通过了

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值