Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Relative path in build.gradle differs between Windows and OS X

My project have a folder with the keystore file (file.keystore). This is the structure:

+---.gradle
|   \---2.2
|       \---taskArtifacts
+---.idea
|   +---copyright
|   \---libraries
+---app
|   +---build
|   |   +---generated
|   +---libs
|   \---src
|       +---androidTest
|       \---main
+---build
|   \---intermediates
|       \---dex-cache
+---gradle
|   \---wrapper
\---keystore

To use it in build.gradle I use this:

signingConfigs {
    project {
        keyAlias 'project'
        keyPassword 'blabla'
        storeFile file('keystore\\file.keystore')
        storePassword 'blabla'
    }

In windows everything is correct because it searches in:

/project/keystore/file.keystore

But in OS X it is searching in:

/project/app/keystore/file.keystore

How should I code in the build.gradle?

like image 463
Javier Sivianes Avatar asked Jun 19 '15 12:06

Javier Sivianes


People also ask

How to specify dependencies in Gradle?

To add a dependency to your project, specify a dependency configuration such as implementation in the dependencies block of your module's build. gradle file. This declares a dependency on an Android library module named "mylibrary" (this name must match the library name defined with an include: in your settings.

Where is the path of Gradle?

The global properties file should be located in your home directory: On Windows: C:\Users\<you>\. gradle\gradle.

Where does Gradle store dependencies locally?

Gradle's local repository folder is: $USER_HOME/. gradle/caches/modules-2/files-2.1.


3 Answers

Use groovy String Interpolation $rootDir property.

project {
   ...     
   storeFile file("$rootDir\keystore\file.keystore")
   ...
}

note that it uses "double quotation"

like image 87
Rohit Karadkar Avatar answered Oct 10 '22 22:10

Rohit Karadkar


Linh Nguyen Vu is Correct! Below the Test! the keyword is Resolved: Testing the Solution

like image 27
CryptoCode Avatar answered Oct 10 '22 20:10

CryptoCode


Try

project {
    keyAlias 'project'
    keyPassword 'blabla'
    storeFile file('../keystore/file.keystore')
    storePassword 'blabla'
}

I think it was too late. But maybe this will help someone has the same problem.

like image 25
Linh Nguyen Vu Avatar answered Oct 10 '22 22:10

Linh Nguyen Vu