热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

androidgradle本地路径不存在-androidgradleLocalpathdoesn'texist

Whenirunmyappeverytime,versionNameisincrementedinManifestfile.20389meansthatisoldv

When i run my app every time, versionName is incremented in Manifest file. 20389 means that is old version name, 20390 is incremented number.

当我每次运行我的应用程序时,versionName在Manifest文件中递增。 20389表示旧版本名称,20390表示递增编号。

enter image description here

Project is built successfully like BUILD SUCCESSFUL. But the question is that why Android studio caches previous apk version. Here is what is error:

项目建立成功,如BUILD SUCCESSFUL。但问题是为什么Android studio会缓存以前的apk版本。这是什么错误:

Target device: lge-nexus_5-061642fd00511249 Uploading file local path: H:\customFolder\app\build\outputs\apk\MyAppName-0.6.200_20383-debug.apk remote path: /data/local/tmp/com.example.app Local path doesn't exist.

目标设备:lge-nexus_5-061642fd00511249上传文件本地路径:H:\ customFolder \ app \ build \ outputs \ apk \ MyAppName-0.6.200_20383-debug.apk远程路径:/data/local/tmp/com.example.app本地路径不存在。

As you pay attention when app runs on a device, android studio try to instal 20383 version of apk. It is wrong. Could anyone help me? I've googeled and saw this link.

当应用程序在设备上运行时你注意,android studio尝试安装20383版本的apk。这是错误的。谁能帮助我?我已经googeled并看到了这个链接。

Here is how i can change manifest file with gradle script:

以下是我可以使用gradle脚本更改清单文件的方法:

def updateRevisionNumber () {//autoIncrement Version Name
  def currentVersion = getVersionName();
  def currentRevisiOnInManifest=           currentVersion.substring(currentVersion.indexOf("_")+1);
  def lastRevision = Integer.parseInt(currentRevisionInManifest) + 1;
  println("currentRevisionInManifest: " + currentRevisionInManifest);
  println("lastRevision: " + lastRevision);

  def oldText = manifestFile.getText();
  def changedText =      oldText.replace(currentRevisionInManifest,lastRevision+"");
  manifestFile.setText(changedText);}

1 个解决方案

#1


Instead of editing your manifest file during the build, you can override the version name in the android section of your manifest :

您可以在清单的android部分覆盖版本名称,而不是在构建期间编辑清单文件:

android {
    ...
    defaultConfig {
        versionName someScriptToComputeVersionName()
        ...

And there is at least 2 good reasons to do it that way :

并且至少有两个很好的理由这样做:

  • the build process won't change your source code (i.e. AndroidManifest.xml will not be modified - at least the AndroidManifest.xml in your editable sources won't be modified)
  • 构建过程不会更改您的源代码(即AndroidManifest.xml不会被修改 - 至少您的可编辑源中的AndroidManifest.xml不会被修改)

  • there are good chances that Android Studio will be happy.
  • Android Studio很有可能会很开心。

Now your problem is to define correctly the function someScriptToComputeVersionName() , that's up to you.

现在你的问题是正确定义someScriptToComputeVersionName()函数,这取决于你。

IMO, simply incrementing a number is probably not the best choice and you should probably go for a solution were you build the version name based on VCS revision number.

IMO,简单地增加一个数字可能不是最佳选择,如果你根据VCS版本号构建版本名称,你应该寻求解决方案。


推荐阅读
author-avatar
galsu99
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有