如何从Android的摇篮FTP文件建立? [英] How to FTP a file from an Android Gradle build?

查看:146
本文介绍了如何从Android的摇篮FTP文件建立?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过FTP传输签署APK之后摇篮建设。我已经添加了新的版本的配置,将签署APK,但我卡试图弄清楚如何调用一个FTP任务。

然而,我发现它在部分59.6 正式看样品,抱怨说,它不能解析的依赖org.apache.ant:蚂蚁公网:1.8.4。因此很明显,我失去了一些东西明显在这里,就像往哪里放一个给定的jar文件或引用它,但我以为行家会处理这样的事情?

有关引用,这里是链接样品从而未能与有关依赖消息:

 配置{
    ftpAntTask
}

依赖{
    ftpAntTask(org.apache.ant:蚁公网:1.8.4){
        模块(公网:公网:1.4.1){
            依赖奥罗:奥罗:2.0.8:罐子
        }
    }
}

任务FTP<< {
    蚂蚁 {
        的taskdef(名称:FTP,
                类名:org.apache.tools.ant.taskdefs.optional.net.FTP,
                类路径:configurations.ftpAntTask.asPath)
        FTP(服务器:ftp.apache.org,用户标识:匿名,密码:me@myorg.com){
            文件集(导演:htdocs中/手动)
        }
    }
}
 

这失败的消息:

 >找不到org.apache.ant:蚂蚁公网:1.8.4。
 

下面是我的完整gradle.build文件,一些敏感信息删除:

  buildscript {
    库{
        mavenCentral()
    }
    依赖{
        类路径com.android.tools.build:gradle:0.4
    }
}

应用插件:'机器人'

依赖{
    编译文件(库/ Android的支持 -  v4.jar)
}

安卓{
    compileSdkVersion 17
    buildToolsVersion17.0.0

    defaultConfig {
        的minSdkVersion 14
        targetSdkVersion 17
    }

    signingConfigs {
        签订{
            storeFile文件((删除))
            storePassword(删除)
            keyAlias​​(删除)
            keyPassword(删除)
        }
     }

    buildTypes {
        签订{
            调试的假
            jniDebugBuild假
            signingConfig signingConfigs.signed
        }
    }
}

配置{
    ftpAntTask
}

依赖{
    ftpAntTask(org.apache.ant:蚁公网:1.8.4){
        模块(公网:公网:1.4.1){
            依赖奥罗:奥罗:2.0.8:罐子
        }
    }
}

任务FTP<< {
    蚂蚁 {
        的taskdef(名称:FTP,
                类名:org.apache.tools.ant.taskdefs.optional.net.FTP,
                类路径:configurations.ftpAntTask.asPath)
        FTP(服务器:(删除),用户ID(删除),密码:(删除),remoteDir:(删除)){
            文件集(导演:(删除)){
                包括:(名称:(删除))
            }
        }
    }
}
 

解决方案

您没有带宣称可用于解决宣布文物的仓库。尝试添加下面的代码片段到你的build.gradle文件:

 库{
    mavenCentral()
}
 

欢呼声中,

I'm trying to FTP the signed APK after a Gradle build. I've already added the new build config that will sign the APK, but I'm stuck trying to figure out how to invoke an FTP task.

I found an official looking sample at section 59.6, however it complains that it cannot resolve dependency org.apache.ant:ant-commons-net:1.8.4. So apparently I'm missing something obvious here, like where to put a given jar file or reference it, although I thought maven would handle this sort of thing?

For reference, here is the linked sample which fails with a message about the dependency:

configurations {
    ftpAntTask
}

dependencies {
    ftpAntTask("org.apache.ant:ant-commons-net:1.8.4") {
        module("commons-net:commons-net:1.4.1") {
            dependencies "oro:oro:2.0.8:jar"
        }
    }
}

task ftp << {
    ant {
        taskdef(name: 'ftp',
                classname: 'org.apache.tools.ant.taskdefs.optional.net.FTP',
                classpath: configurations.ftpAntTask.asPath)
        ftp(server: "ftp.apache.org", userid: "anonymous", password: "me@myorg.com") {
            fileset(dir: "htdocs/manual")
        }
    }
}

This fails with the message:

> Could not find org.apache.ant:ant-commons-net:1.8.4.

Here is my complete gradle.build file, with some sensitive information removed:

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

apply plugin: 'android'

dependencies {
    compile files('libs/android-support-v4.jar')
}

android {
    compileSdkVersion 17
    buildToolsVersion "17.0.0"

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 17
    }

    signingConfigs {
        signed {
            storeFile file("(removed)")
            storePassword "(removed)"
            keyAlias "(removed)"
            keyPassword "(removed)"
        }
     }

    buildTypes {
        signed {
            debuggable false
            jniDebugBuild false
            signingConfig signingConfigs.signed
        }
    }
}

configurations {
    ftpAntTask
}

dependencies {
    ftpAntTask("org.apache.ant:ant-commons-net:1.8.4") {
        module("commons-net:commons-net:1.4.1") {
            dependencies "oro:oro:2.0.8:jar"
        }
    }
}

task ftp << {
    ant {
        taskdef(name: 'ftp',
                classname: 'org.apache.tools.ant.taskdefs.optional.net.FTP',
                classpath: configurations.ftpAntTask.asPath)
        ftp(server: "(removed)", userid: "(removed)", password: "(removed)", remoteDir: "(removed)") {
            fileset(dir: "(removed)") {
                include(name: "(removed)")
            }
        }
    }
}

解决方案

You havn't declared a repository that can be used to resolve the declared artifacts. Try adding the following snippet to your build.gradle file:

repositories{
    mavenCentral()
}

cheers,

René

这篇关于如何从Android的摇篮FTP文件建立?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆