久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在 Android Gradle 項目中復制 APK 文件

Copying APK file in Android Gradle project(在 Android Gradle 項目中復制 APK 文件)
本文介紹了在 Android Gradle 項目中復制 APK 文件的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在嘗試向我的 Android 項目的 build.gradle 添加自定義任務,以將最終 APK 和 Proguard 的 mapping.txt 復制到不同的目錄中.我的任務依賴于 assembleDevDebug 任務:

I'm trying to add a custom task to my Android project's build.gradle to copy the final APK and Proguard's mapping.txt into a different directory. My task depends on the assembleDevDebug task:

task publish(dependsOn: 'assembleDevDebug') << {
    description 'Copies the final APK to the release directory.'

    ...
}

根據文檔,我可以看到如何使用標準 Copy 任務類型進行文件復制:

I can see how to do a file copy using the standard Copy task type, as per the docs:

task(copy, type: Copy) {
    from(file('srcDir'))
    into(buildDir)
}

但前提是您知道要復制的文件的名稱和位置.

but that assumes you know the name and location of the file you want to copy.

如何找到作為 assembleDevDebug 任務的一部分構建的 APK 文件的確切名稱和位置?這可以作為財產嗎?感覺好像我應該能夠將文件聲明為我的任務的輸入,并將它們聲明為 assemble 任務的輸出,但是我的 Gradle-fu 不夠強大.

How can I find the exact name and location of the APK file which was built as part of the assembleDevDebug task? Is this available as a property? It feels as if I should be able to declare the files as inputs to my task, and declare them as outputs from the assemble task, but my Gradle-fu isn't strong enough.

我有一些自定義邏輯將版本號注入 APK 文件名,所以我的 publish 任務不能只假設默認名稱和位置.

I have some custom logic to inject the version number into the APK filename, so my publish task can't just assume the default name and location.

推薦答案

如果你可以得到與 devDebug 關聯的變體對象,你可以使用 getOutputFile() 查詢它.

If you can get the variant object associated with devDebug you could query it with getOutputFile().

因此,如果您想發布所有變體,您需要這樣:

So if you wanted to publish all variants you'd something like this:

def publish = project.tasks.create("publishAll")
android.applicationVariants.all { variant ->
  def task = project.tasks.create("publish${variant.name}Apk", Copy)
  task.from(variant.outputFile)
  task.into(buildDir)

  task.dependsOn variant.assemble
  publish.dependsOn task
}

現在你可以調用 gradle publishAll,它會發布你所有的變體.

Now you can call gradle publishAll and it'll publish all you variants.

映射文件的一個問題是 Proguard 任務沒有為您提供文件位置的 getter,因此您目前無法查詢它.我希望能解決這個問題.

One issue with the mapping file is that the Proguard task doesn't give you a getter to the file location, so you cannot currently query it. I'm hoping to get this fixed.

這篇關于在 Android Gradle 項目中復制 APK 文件的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

IncompatibleClassChangeError after updating to Android Build Tools 25.1.6 GCM / FCM(更新到 Android Build Tools 25.1.6 GCM/FCM 后出現 IncompatibleClassChangeError)
How to get current flavor in gradle(如何在 gradle 中獲取當前風味)
How to fix quot;unexpected element lt;queriesgt; found in lt;manifestgt;quot; error?(如何修復“意外元素lt;查詢gt;在“清單中找到錯誤?)
Multi flavor app based on multi flavor library in Android Gradle(基于 Android Gradle 中多風味庫的多風味應用)
Android dependency has different version for the compile and runtime(Android 依賴在編譯和運行時有不同的版本)
Transitive dependencies for local aar library(本地 aar 庫的傳遞依賴)
主站蜘蛛池模板: 亚洲一二三视频 | 无码一区二区三区视频 | 99在线精品视频 | 欧美日韩国产高清 | 综合激情网 | 在线观看亚 | 一级黄色片在线看 | 免费在线一区二区 | 国产亚洲精品精品国产亚洲综合 | 国产999精品久久久久久 | 影音先锋成人资源 | 欧美精品久久久 | 亚洲福利在线观看 | 日本久久久久久 | 亚洲成av人片在线观看 | 91精品一区 | 免费毛片网 | 天天爽综合网 | 蜜桃在线一区二区三区 | 黄色一级视频免费 | 亚洲成av片人久久久 | 色网站入口 | 久久久久亚洲av毛片大全 | 久久草视频 | 日本大香伊一区二区三区 | 狠狠躁夜夜躁人人爽天天高潮 | 久久噜噜噜精品国产亚洲综合 | 国产小视频在线观看 | 国产精品国产成人国产三级 | 精品国产欧美一区二区三区不卡 | 精品国产欧美一区二区三区成人 | 久久久精品一区 | 91深夜福利视频 | 成年人在线观看 | 日韩伦理一区二区三区 | 欧美成人精品欧美一级 | 影音先锋男 | 91传媒在线观看 | 国产精品日韩 | 波波电影院一区二区三区 | 一区二区三区中文字幕 |