Android 按gradle签名apk-特殊字符的编码无效
根据许多关于配置gradle来签署apk的主题,我使用了这个。 它似乎需要适当的价值观,但我不能成功的整个行动。可能是字母ł的问题,它甚至在终端中显示错误。我需要帮助,因为我现在不知道该怎么办。我花了大约4个小时在上面 这是主项目应用程序gradle Properties文件:Android 按gradle签名apk-特殊字符的编码无效,android,encoding,gradle,android-studio,apk,Android,Encoding,Gradle,Android Studio,Apk,根据许多关于配置gradle来签署apk的主题,我使用了这个。 它似乎需要适当的价值观,但我不能成功的整个行动。可能是字母ł的问题,它甚至在终端中显示错误。我需要帮助,因为我现在不知道该怎么办。我花了大约4个小时在上面 这是主项目应用程序gradle Properties文件: apply plugin: 'android' android { compileSdkVersion 19 buildToolsVersion "19.1.0" defaultCon
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
minSdkVersion 10
targetSdkVersion 19
}
signingConfigs {
release {
storeFile file(RELEASE_STORE_FILE)
storePassword RELEASE_KEY_ALIAS
keyAlias RELEASE_KEY_ALIAS
keyPassword RELEASE_KEY_PASSWORD
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
}
dependencies {
//...
}
此文件从窗口的用户目录中的~/.gradle/gradle.properties文件获取数据
org.gradle.parallel=true
org.gradle.daemon=false
RELEASE_STORE_FILE=C:/users/xxx/f1/f1/android_market_key
RELEASE_STORE_PASSWORD=lololo
RELEASE_KEY_ALIAS=łłłł
RELEASE_KEY_PASSWORD=lololo
我试过使用:
compileOptions.encoding = "UTF-8"
或
甚至在gradlew.bat中添加一些选项-D*来设置编码,但仍然失败
请帮忙,我结巴了。检查gradle.properties文件的编码,确保它是UTF-8
某些编辑器(如记事本)默认为ANSI编码,如果文件包含非ASCII字符,则会导致问题
示例:在记事本:文件->另存为->编码中,我找到了部分解决方案,在每个需要使用特殊字符的地方,我都使用了从控制台读取的字符,最后它成功了: 解决方案:
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
defaultConfig {
minSdkVersion 10
targetSdkVersion 19
}
signingConfigs {
release {
storeFile file(RELEASE_STORE_FILE)
storePassword RELEASE_STORE_PASSWORD
def console = System.console()
if (console != null) {
keyAlias System.console().readLine("\n\$ Enter key alias: ")
}
keyPassword RELEASE_KEY_PASSWORD
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
productFlavors {
}
}
dependencies {
//my dependencies
}
在遇到同样的问题并花了几个小时之后,我成功地进行了如下构建: 按照说明进行操作。因此,我没有使用gradle.properties来存储这些值,而是将它们存储在一个自定义文件signing.properties中 将文件读取部分更改如下: props.load新InputStreamReader新文件InputStreamPropFile,UTF-8 我希望有帮助
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
defaultConfig {
minSdkVersion 10
targetSdkVersion 19
}
signingConfigs {
release {
storeFile file(RELEASE_STORE_FILE)
storePassword RELEASE_STORE_PASSWORD
def console = System.console()
if (console != null) {
keyAlias System.console().readLine("\n\$ Enter key alias: ")
}
keyPassword RELEASE_KEY_PASSWORD
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
productFlavors {
}
}
dependencies {
//my dependencies
}