我想让我的Gradle构建使用Gradle创建一个发布签名的apk文件.
我不确定代码是否正确或者我在做gradle build什么时缺少参数?
这是我的gradle文件中的一些代码:
android {
...
signingConfigs {
release {
storeFile file("release.keystore")
storePassword "******"
keyAlias "******"
keyPassword "******"
}
}
}
Run Code Online (Sandbox Code Playgroud)
gradle构建完成SUCCESSFUL,在我的build/apk文件夹中我只看到...-release-unsigned.apk和...-debug-unaligned.apk文件.
关于如何解决这个问题的任何建议?
我已sdk.dir和ndk.dir在local.properties.
如何阅读中定义的值sdk.dir和ndk.dir中build.gradle文件?
我遇到的问题是System.getenv()为环境变量返回null.我的密码存储在RELEASE_PASSWORD环境变量中.当我做:
$ echo $RELEASE_PASSWORD
它打印出正确的值,所以我知道变量已设置.
我最初signingConfig signingConfigs.release在发布版本中设置了类型,一切都运行正常,但我需要不同的签名配置,以适应不同的产品风格.如果我对密码进行硬编码,它的工作原理就像它想象的那样.当我尝试从环境变量中读取密码时,事情就变得很糟糕.
这是某种范围问题吗?
这就是我目前所拥有的build.gradle.
android {
...
signingConfigs {
release {
storeFile ...;
keyAlias ...;
storePassword System.getenv("RELEASE_PASSWORD");
keyPassword System.getenv("RELEASE_PASSWORD");
}
unsigned {
keyAlias "";
storePassword "";
keyPassword "";
}
}
buildTypes {
debug {
versionNameSuffix = "-DEBUG"
}
release {
}
}
flavorGroups "storeFront"
productFlavors {
def googleVariable = signingConfigs.release
def amazonVariable = signingConfigs.unsigned
google {
flavorGroup "storeFront"
signingConfig googleVariable
}
amazon {
flavorGroup "storeFront"
signingConfig amazonVariable …Run Code Online (Sandbox Code Playgroud) When I want to upload an Android application to the Play Store, which one should I use?
I have tried the above but I am still confused about which one is the most effective?
./gradlew assembleRelease
./gradlew installRelease
./gradlew bundleRelease
Run Code Online (Sandbox Code Playgroud)
I expect the best way to do the above.
似乎Gradle zipAlign任务对我不起作用,不确定我做错了什么.我尝试过包含zipAlign任务,但不包括它,但它似乎没有什么区别.我的gradle脚本吐出了一个"release"版本,但是当我尝试上传我的.apk时,根据开发者控制台它永远不会压缩对齐.
这是我的构建脚本:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4.2'
}
}
apply plugin: 'android'
dependencies {
compile project(':facebook-android-sdk-3.0.1:facebook')
compile project(':google-play-services_lib')
compile project(':nineoldandroids')
compile project(':SlidingMenu-master:library')
compile project(':ViewPagerIndicator')
compile project(':volley')
compile project(':windowed-seek-bar')
compile files('compile-libs/androidannotations-2.7.1.jar', 'libs/Flurry_3.2.1.jar', 'libs/google-play-services.jar', 'libs/gson-2.2.4.jar', 'libs/picasso-1.1.1.jar', 'libs/crittercism_v3_0_11_sdkonly.jar', 'libs/gcm.jar', 'libs/apphance-library.jar')
}
android {
buildToolsVersion "17.0"
compileSdkVersion 17
signingConfigs {
debug {
storeFile file('keystores/debug.keystore')
}
}
buildTypes {
debug {
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src'] …Run Code Online (Sandbox Code Playgroud) 在Gradle for Android中,似乎是公共实践来定义发布版本的签名配置,如下所示:
android {
signingConfigs {
debug {
storeFile file("debug.keystore")
}
myConfig {
storeFile file("other.keystore")
storePassword "android"
keyAlias "androiddebugkey"
keyPassword "android"
}
}
buildTypes {
foo {
debuggable true
jniDebugBuild true
signingConfig signingConfigs.myConfig
}
}
}
Run Code Online (Sandbox Code Playgroud)
事实上,我想将我的build.gradle文件保留在版本控制中,并且在一些git服务器上没有很好的感觉我的密钥库的密码(我用于其他东西,愚蠢,我知道).
有没有办法从我的硬盘驱动器上的某个地方加载来自外部文件的signingConfig?
android gradle android-studio build.gradle android-gradle-plugin
我有build.gradle一个local.properties文件.我想声明一个值local.properties,用于未在版本控制中签入build.gradle.
我有buildConfigField合作:
buildTypes {
debug {
buildConfigField "String", "TEST", "test"
}
}
Run Code Online (Sandbox Code Playgroud)
不幸的是,这会导致错误:
buildTypes {
debug {
buildConfigField "String", "TEST", local.properties.get("test")
}
}
Run Code Online (Sandbox Code Playgroud) 我正在Windows上开发本机应用程序。为了能够生成已签名的发行版APK,我已经添加了该文件MYAPP_RELEASE_STORE_PASSWORD=***并将MYAPP_RELEASE_KEY_PASSWORD=***其添加到我的/projectname/android/gradle.properties文件中(就像在这里这样说)。现在我想知道是否应该将文件添加到gitignore,以防止将其上传到github,或者是否可以将密码存储在其他文件中?
我已经回顾了关于这个主题的一些帖子,
对于初学者.但我仍然无法通过第Error:(69, 0) Could not find method storeFile() for arguments [/path/to/my.keystore]69行的Gradle错误:
storeFile file(keystoreProperties['storeFile'])
Run Code Online (Sandbox Code Playgroud)
在模块gradle构建文件中 - 我的模块gradle.build文件的内容:
apply plugin: 'com.android.application'
apply plugin: 'signing'
android {
...
buildTypes {
...
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
def keystorePropertiesFile = rootProject.file("keystore.properties");
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
}
...
}
...
}
...
Run Code Online (Sandbox Code Playgroud)
我加载keystore.properties文件(位于项目根目录),其中包含:
storeFile=/path/to/my.keystore
storePassword=storepwd
keyPassword=keypwd
keyAlias=keyalias
Run Code Online (Sandbox Code Playgroud)
如您所见,我在gradle.build文件的storeFile引用中有一个文件构造函数,在属性文件中有一个keystore的路径.
错误在哪里,或者我错过了什么,不理解?
参考
该build.gradle (app)文件包含应用程序的keystore位置和密码。所以我想知道,我是否应该将它们包含在公共 GitHub 存储库中?
我的猜测是“不”,如果是这样,我该如何解决这个问题?我可以以某种方式审查它,还是应该简单地不在提交中包含这些文件?
如果我应该将它们从提交中保留,我该如何解决拉动项目的问题,因为文件会丢失?