Android Studio中无法找到文件 [英] Android Studio can't find file

查看:188
本文介绍了Android Studio中无法找到文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将我的签名密钥到文件夹中的项目的根目录:

I added my signing keys into keys folder in root of the project:

.\

   keys\
       sign.properties
   src\
       main\
   build.gradle

我添加下一行到我的构建脚本:

I added next lines to my build script:

signingConfigs {
    release {
        Properties p = new Properties()
        p.load(new FileInputStream('keys/sign.properties'))

        storeFile file(p.file)
        storePassword p.password
        keyAlias p.alias
        keyPassword p.keyPassword
    }
}

命令行构建的gradle是能够组装构建。然而Android的工作室给了我错误文件 sign.properties 是找不到的。

如何AS指向它?

推荐答案

它看起来像的工作目录是在命令行中与从Android的工作室编译在编译时有问题。我看到的差异存在,我需要进一步调查,并可能提交错误的。在任何情况下,最好是明确有关的路径钉降至prevent混乱。

It looks like a problem with what the working directory is when compiling on the command line vs. compiling from Android Studio. I see a discrepancy there that I need to investigate further and possibly file a bug for. In any event, it's better to be explicit about nailing down the path to prevent confusion.

试试这个:

p.load(new FileInputStream(rootProject.file('keys/sign.properties')))

这将明确该文件是相对于<我>项目(不是模块)的根,这也是其中 settings.gradle 文件生命。

This will nail down the file to be relative to the project (not the module) root, which is also where the settings.gradle file lives.

修改

我提交的bug https://开头code .google.com / p /安卓/问题/细节?ID = 64018 这一点。我给你上面的解决办法应该做的很好,而且可能在任何情况下的最佳做法。

I filed bug https://code.google.com/p/android/issues/detail?id=64018 for this. The workaround I showed you above should do nicely, and is maybe a best practice in any event.

这篇关于Android Studio中无法找到文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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