获取 "Cause: failed to decrypt safe contents entry: javax.crypto.BadPaddingException: Given final block not properly padded"
Getting "Cause: failed to decrypt safe contents entry: javax.crypto.BadPaddingException: Given final block not properly padded"
我正在尝试测试 LibGDX 开发,但在我 android phone 上尝试将最基本的应用程序设置为 运行 时出现错误,因为我的密钥库或它的使用方式存在一些问题,我不确定到底是什么问题。
在更详细地描述问题和我尝试过的方法之前,我将首先描述一些关于我的环境的事情:
我正在使用:
- `Android Studio 3.1.4,` with
- `Gradle 4.6` inside of it, my os is
- `Linux Mint 18.1 (Serena) (which is based on...
- `Ubuntu 16.04`, my kernel is
- `Linux 4.4.0-53-generic`.
为了解决这个问题,我多次生成新的密钥密码s, sometimes using the command line, and sometimes through Android Studio's "Build" -> "Generate Signed APK" -> "Create New..."
选项。
我生成的最新一个是使用“Build" -> "Generate Signed SPK" -> "Create New..."
选项
然后经过一番努力,我最终意识到我必须将我的密钥库添加到我的 gradle 文件中,这是我做错的第一件事,我最终偶然发现了 "File" -> "Project Structure" -> "android" -> "Signing"
选项,点击绿色“+”号并填写名称,"Key Alias"、"Key Password"、"Store File" 和 "Store Password",确保它们与最新的 keypass 匹配我创造了。
创建签名后,我选择了它,然后单击 "OK",然后确实在我的 gradle 文件中看到它,它已添加到我的 gradle android模块
我将 gradle 文件与我的应用程序重新同步,然后清理了我的应用程序。
但是,当我尝试重建我的应用程序时,或者 运行 它并通过我插入的 Android Phone 单击 运行 宁它的选项,我收到错误消息:
Cause: failed to decrypt safe contents entry: javax.crypto.BadPaddingException: Given final block not properly padded
我做了一些研究试图解决这个问题,一种可能是我使用了错误的密码,但我一直小心确保我使用了正确的密码,但并没有解决这个问题.
我在做一些研究后发现的另一种可能性是,密钥库的密码有一定的规则,我认为不使用特殊字符是其中之一,所以我确保我遵循了那个规则。
但我也知道有 2 个不同的密码,也许它们有不同的规则,但我不确定这是我的问题,我认为是其他原因。
非常感谢您帮助解决此签名问题,非常感谢。
编辑:我要添加一些我的 gradle 文件内容:
Gradle Scripts
- `build.gradle` (Project: MyGDXGame4)
buildscript {
repositories {
//mavenLocal()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
jcenter()
google()
}
dependencies {
classpath 'org.wisepersist:gwt-gradle-plugin:1.0.6'
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.mobidevelop.robovm:robovm-gradle-plugin:2.3.3'
classpath 'org.multi-os-engine:moe-gradle:1.4.0'
}
}
allprojects {
apply plugin: "eclipse"
apply plugin: "idea"
version = '1.0'
ext {
appName = "my-gdx-game4"
gdxVersion = '1.9.8'
roboVMVersion = '2.3.3'
box2DLightsVersion = '1.4'
ashleyVersion = '1.7.0'
aiVersion = '1.8.0'
}
repositories {
//mavenLocal()
mavenCentral()
jcenter()
google()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
}
}
project(":desktop") {
apply plugin: "java"
dependencies {
implementation project(":core")
implementation "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
implementation "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
implementation "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
implementation "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
implementation "com.badlogicgames.gdx:gdx-controllers-desktop:$gdxVersion"
implementation "com.badlogicgames.gdx:gdx-controllers-platform:$gdxVersion:natives-desktop"
implementation "de.tomgrill.gdxfacebook:gdx-facebook-desktop:1.4.1"
implementation "de.tomgrill.gdxdialogs:gdx-dialogs-desktop:1.2.5"
}
}
project(":android") {
apply plugin: "android"
configurations { natives }
dependencies {
implementation project(":core")
implementation "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
implementation "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86_64"
implementation "com.badlogicgames.gdx:gdx-controllers:$gdxVersion"
implementation "com.badlogicgames.gdx:gdx-controllers-android:$gdxVersion"
implementation "com.badlogicgames.gdx:gdx-ai:$aiVersion"
implementation "com.badlogicgames.ashley:ashley:$ashleyVersion"
implementation "com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion"
implementation "de.tomgrill.gdxfacebook:gdx-facebook-android:1.4.1"
implementation "de.tomgrill.gdxdialogs:gdx-dialogs-android:1.2.5"
}
}
project(":ios") {
apply plugin: "java"
apply plugin: "robovm"
dependencies {
implementation project(":core")
implementation "com.mobidevelop.robovm:robovm-rt:$roboVMVersion"
implementation "com.mobidevelop.robovm:robovm-cocoatouch:$roboVMVersion"
implementation "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion"
implementation "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"
implementation "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-ios"
implementation "de.tomgrill.gdxfacebook:gdx-facebook-ios:1.4.1"
implementation "de.tomgrill.gdxdialogs:gdx-dialogs-ios:1.2.5"
}
}
project(":html") {
apply plugin: "gwt"
apply plugin: "war"
dependencies {
implementation project(":core")
implementation "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion"
implementation "com.badlogicgames.gdx:gdx:$gdxVersion:sources"
implementation "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion:sources"
implementation "com.badlogicgames.gdx:gdx-box2d:$gdxVersion:sources"
implementation "com.badlogicgames.gdx:gdx-box2d-gwt:$gdxVersion:sources"
implementation "com.badlogicgames.gdx:gdx-controllers:$gdxVersion:sources"
implementation "com.badlogicgames.gdx:gdx-controllers-gwt:$gdxVersion"
implementation "com.badlogicgames.gdx:gdx-controllers-gwt:$gdxVersion:sources"
implementation "com.badlogicgames.gdx:gdx-ai:$aiVersion:sources"
implementation "com.badlogicgames.ashley:ashley:$ashleyVersion:sources"
implementation "com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion:sources"
implementation "net.dermetfan.libgdx-utils:libgdx-utils:0.13.4:sources"
implementation "com.kotcrab.vis:vis-ui:1.3.0:sources"
implementation "net.dermetfan.libgdx-utils:libgdx-utils:0.13.4:sources"
implementation "net.dermetfan.libgdx-utils:libgdx-utils-box2d:0.13.4:sources"
implementation "de.tomgrill.gdxfacebook:gdx-facebook-core:1.4.1:sources"
implementation "de.tomgrill.gdxfacebook:gdx-facebook-html:1.4.1:sources"
implementation "de.tomgrill.gdxdialogs:gdx-dialogs-html:1.2.5"
implementation "de.tomgrill.gdxdialogs:gdx-dialogs-html:1.2.5:sources"
compile "de.tomgrill.gdxdialogs:gdx-dialogs-core:1.2.5:sources"
implementation "com.github.czyzby:gdx-kiwi:1.9.1.9.6:sources"
implementation "com.github.czyzby:gdx-kiwi:1.9.1.9.6:sources"
implementation "com.github.czyzby:gdx-lml:1.9.1.9.6:sources"
implementation "com.github.czyzby:gdx-lml-vis:1.9.1.9.6:sources"
implementation "com.kotcrab.vis:vis-ui:1.3.0:sources"
implementation "com.github.czyzby:gdx-kiwi:1.9.1.9.6:sources"
implementation "com.github.czyzby:gdx-lml:1.9.1.9.6:sources"
}
}
project(":core") {
apply plugin: "java"
dependencies {
implementation "com.badlogicgames.gdx:gdx:$gdxVersion"
implementation "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
implementation "com.badlogicgames.gdx:gdx-controllers:$gdxVersion"
implementation "com.badlogicgames.gdx:gdx-ai:$aiVersion"
implementation "com.badlogicgames.ashley:ashley:$ashleyVersion"
implementation "com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion"
implementation "net.dermetfan.libgdx-utils:libgdx-utils:0.13.4"
implementation "com.kotcrab.vis:vis-ui:1.3.0"
implementation "net.dermetfan.libgdx-utils:libgdx-utils-box2d:0.13.4"
implementation "de.tomgrill.gdxfacebook:gdx-facebook-core:1.4.1"
compile "de.tomgrill.gdxdialogs:gdx-dialogs-core:1.2.5"
implementation "com.github.czyzby:gdx-kiwi:1.9.1.9.6"
implementation "com.github.czyzby:gdx-lml-vis:1.9.1.9.6"
implementation "com.github.czyzby:gdx-lml:1.9.1.9.6"
}
}
project(":ios-moe") {
apply plugin: "moe"
configurations { natives }
dependencies {
implementation project(":core")
implementation "com.badlogicgames.gdx:gdx-backend-moe:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-ios"
implementation "de.tomgrill.gdxfacebook:gdx-facebook-ios-moe:1.4.1"
implementation "de.tomgrill.gdxdialogs:gdx-dialogs-ios-moe:1.2.5"
}
}
tasks.eclipse.doLast {
delete ".project"
}
build.gradle (Module: android)
(请注意,我已将 key_pass keyAlias、keyPassword、storeFile 和 storePassword 替换为 '*****',在实际的 gradle 文件中,它们是不同的
android {
signingConfigs {
key_pass {
keyAlias '*****'
keyPassword '******'
storeFile file('*****')
storePassword '*****'
}
}
buildToolsVersion "27.0.3"
compileSdkVersion 27
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
}
packagingOptions {
exclude 'META-INF/robovm/ios/robovm.xml'
}
defaultConfig {
applicationId "com.mygdx.game4"
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
// called every time gradle gets executed, takes the native dependencies of
// the natives configuration, and extracts them to the proper libs/ folders
// so they get packed with the APK.
task copyAndroidNatives() {
file("libs/armeabi/").mkdirs();
file("libs/armeabi-v7a/").mkdirs();
file("libs/arm64-v8a/").mkdirs();
file("libs/x86_64/").mkdirs();
file("libs/x86/").mkdirs();
configurations.natives.files.each { jar ->
def outputDir = null
if (jar.name.endsWith("natives-arm64-v8a.jar")) outputDir = file("libs/arm64-v8a")
if (jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a")
if (jar.name.endsWith("natives-armeabi.jar")) outputDir = file("libs/armeabi")
if (jar.name.endsWith("natives-x86_64.jar")) outputDir = file("libs/x86_64")
if (jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86")
if (outputDir != null) {
copy {
from zipTree(jar)
into outputDir
include "*.so"
}
}
}
}
task run(type: Exec) {
def path
def localProperties = project.file("../local.properties")
if (localProperties.exists()) {
Properties properties = new Properties()
localProperties.withInputStream { instr ->
properties.load(instr)
}
def sdkDir = properties.getProperty('sdk.dir')
if (sdkDir) {
path = sdkDir
} else {
path = "$System.env.ANDROID_HOME"
}
} else {
path = "$System.env.ANDROID_HOME"
}
def adb = path + "/platform-tools/adb"
commandLine "$adb", 'shell', 'am', 'start', '-n', 'com.mygdx.game4/com.mygdx.game4.AndroidLauncher'
}
// sets up the Android Eclipse project, using the old Ant based build.
eclipse {
// need to specify Java source sets explicitly, SpringSource Gradle Eclipse plugin
// ignores any nodes added in classpath.file.withXml
sourceSets {
main {
java.srcDirs "src", 'gen'
}
}
jdt {
sourceCompatibility = 1.6
targetCompatibility = 1.6
}
classpath {
plusConfigurations += [project.configurations.compile]
containers 'com.android.ide.eclipse.adt.ANDROID_FRAMEWORK', 'com.android.ide.eclipse.adt.LIBRARIES'
}
project {
name = appName + "-android"
natures 'com.android.ide.eclipse.adt.AndroidNature'
buildCommands.clear();
buildCommand "com.android.ide.eclipse.adt.ResourceManagerBuilder"
buildCommand "com.android.ide.eclipse.adt.PreCompilerBuilder"
buildCommand "org.eclipse.jdt.core.javabuilder"
buildCommand "com.android.ide.eclipse.adt.ApkBuilder"
}
}
// sets up the Android Idea project, using the old Ant based build.
idea {
module {
sourceDirs += file("src");
scopes = [COMPILE: [plus: [project.configurations.compile]]]
iml {
withXml {
def node = it.asNode()
def builder = NodeBuilder.newInstance();
builder.current = node;
builder.component(name: "FacetManager") {
facet(type: "android", name: "Android") {
configuration {
option(name: "UPDATE_PROPERTY_FILES", value: "true")
}
}
}
}
}
}
}
dependencies {
}
- `build.gradle (Module: core)`
apply plugin: "java"
sourceCompatibility = 1.6
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
sourceSets.main.java.srcDirs = [ "src/" ]
eclipse.project {
name = appName + "-core"
}
- `gradle-wrapper.properties (Gradel Version)`
#Sun Dec 30 13:51:33 EST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
- `proguard-rules.pro`
# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
-verbose
-dontwarn android.support.**
-dontwarn com.badlogic.gdx.backends.android.AndroidFragmentApplication
-dontwarn com.badlogic.gdx.utils.GdxBuild
-dontwarn com.badlogic.gdx.physics.box2d.utils.Box2DBuild
-dontwarn com.badlogic.gdx.jnigen.BuildTarget*
-dontwarn com.badlogic.gdx.graphics.g2d.freetype.FreetypeBuild
-keep class com.badlogic.gdx.controllers.android.AndroidControllers
-keepclassmembers class com.badlogic.gdx.backends.android.AndroidInput* {
<init>(com.badlogic.gdx.Application, android.content.Context, java.lang.Object, com.badlogic.gdx.backends.android.AndroidApplicationConfiguration);
}
-keepclassmembers class com.badlogic.gdx.physics.box2d.World {
boolean contactFilter(long, long);
void beginContact(long);
void endContact(long);
void preSolve(long, long);
void postSolve(long, long);
boolean reportFixture(long);
float reportRayFixture(long, float, float, float, float, float);
}
- `gradle.properties`
org.gradle.daemon=true
org.gradle.jvmargs=-Xms128m -Xmx1500m
org.gradle.configureondemand=false
- `settings.gradle`
include 'desktop', 'android', 'ios', 'html', 'core', 'ios-moe'
- `local.properties`
# Location of the android SDK
sdk.dir=/home/Android/Sdk
好吧,我发现了问题,我只是少了一个额外的步骤,我不得不在 "Project Properties"->Modules: android 和 [=15= 下进行 "Build Types" ] 密钥库,我以为我已经 selected,通过在签名下突出显示它。
我的解决方案:
1.- 在 Android Studio 4.0.1 中:构建/生成签名构建/APK
生成New Key Store 没有的情况下,把所有参数都放上去。
2.- 一旦你已经有了密钥库,就可以生成 APK 的签名版本,使用与点 1
相同的密码和别名
3.- 我选择调试并启用检查:V2(完整 APK 签名)并按下按钮完成
4.- 最后,在文件/项目结构中,转到模块/签名配置并再次对参数进行数字化并确定。
按照 Android 工作室中的这些步骤,我可以毫无问题地将我的应用程序部署到我的 AVD 中。
Click here: This is the image with the steps, for a better understanding
问候和愉快的编码研究员。
我正在尝试测试 LibGDX 开发,但在我 android phone 上尝试将最基本的应用程序设置为 运行 时出现错误,因为我的密钥库或它的使用方式存在一些问题,我不确定到底是什么问题。
在更详细地描述问题和我尝试过的方法之前,我将首先描述一些关于我的环境的事情:
我正在使用:
- `Android Studio 3.1.4,` with
- `Gradle 4.6` inside of it, my os is
- `Linux Mint 18.1 (Serena) (which is based on...
- `Ubuntu 16.04`, my kernel is
- `Linux 4.4.0-53-generic`.
为了解决这个问题,我多次生成新的密钥密码s, sometimes using the command line, and sometimes through Android Studio's "Build" -> "Generate Signed APK" -> "Create New..."
选项。
我生成的最新一个是使用“Build" -> "Generate Signed SPK" -> "Create New..."
选项
然后经过一番努力,我最终意识到我必须将我的密钥库添加到我的 gradle 文件中,这是我做错的第一件事,我最终偶然发现了 "File" -> "Project Structure" -> "android" -> "Signing"
选项,点击绿色“+”号并填写名称,"Key Alias"、"Key Password"、"Store File" 和 "Store Password",确保它们与最新的 keypass 匹配我创造了。
创建签名后,我选择了它,然后单击 "OK",然后确实在我的 gradle 文件中看到它,它已添加到我的 gradle android模块
我将 gradle 文件与我的应用程序重新同步,然后清理了我的应用程序。
但是,当我尝试重建我的应用程序时,或者 运行 它并通过我插入的 Android Phone 单击 运行 宁它的选项,我收到错误消息:
Cause: failed to decrypt safe contents entry: javax.crypto.BadPaddingException: Given final block not properly padded
我做了一些研究试图解决这个问题,一种可能是我使用了错误的密码,但我一直小心确保我使用了正确的密码,但并没有解决这个问题.
我在做一些研究后发现的另一种可能性是,密钥库的密码有一定的规则,我认为不使用特殊字符是其中之一,所以我确保我遵循了那个规则。
但我也知道有 2 个不同的密码,也许它们有不同的规则,但我不确定这是我的问题,我认为是其他原因。
非常感谢您帮助解决此签名问题,非常感谢。
编辑:我要添加一些我的 gradle 文件内容:
Gradle Scripts
- `build.gradle` (Project: MyGDXGame4)
buildscript {
repositories {
//mavenLocal()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
jcenter()
google()
}
dependencies {
classpath 'org.wisepersist:gwt-gradle-plugin:1.0.6'
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.mobidevelop.robovm:robovm-gradle-plugin:2.3.3'
classpath 'org.multi-os-engine:moe-gradle:1.4.0'
}
}
allprojects {
apply plugin: "eclipse"
apply plugin: "idea"
version = '1.0'
ext {
appName = "my-gdx-game4"
gdxVersion = '1.9.8'
roboVMVersion = '2.3.3'
box2DLightsVersion = '1.4'
ashleyVersion = '1.7.0'
aiVersion = '1.8.0'
}
repositories {
//mavenLocal()
mavenCentral()
jcenter()
google()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
}
}
project(":desktop") {
apply plugin: "java"
dependencies {
implementation project(":core")
implementation "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
implementation "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
implementation "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
implementation "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
implementation "com.badlogicgames.gdx:gdx-controllers-desktop:$gdxVersion"
implementation "com.badlogicgames.gdx:gdx-controllers-platform:$gdxVersion:natives-desktop"
implementation "de.tomgrill.gdxfacebook:gdx-facebook-desktop:1.4.1"
implementation "de.tomgrill.gdxdialogs:gdx-dialogs-desktop:1.2.5"
}
}
project(":android") {
apply plugin: "android"
configurations { natives }
dependencies {
implementation project(":core")
implementation "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
implementation "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86_64"
implementation "com.badlogicgames.gdx:gdx-controllers:$gdxVersion"
implementation "com.badlogicgames.gdx:gdx-controllers-android:$gdxVersion"
implementation "com.badlogicgames.gdx:gdx-ai:$aiVersion"
implementation "com.badlogicgames.ashley:ashley:$ashleyVersion"
implementation "com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion"
implementation "de.tomgrill.gdxfacebook:gdx-facebook-android:1.4.1"
implementation "de.tomgrill.gdxdialogs:gdx-dialogs-android:1.2.5"
}
}
project(":ios") {
apply plugin: "java"
apply plugin: "robovm"
dependencies {
implementation project(":core")
implementation "com.mobidevelop.robovm:robovm-rt:$roboVMVersion"
implementation "com.mobidevelop.robovm:robovm-cocoatouch:$roboVMVersion"
implementation "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion"
implementation "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"
implementation "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-ios"
implementation "de.tomgrill.gdxfacebook:gdx-facebook-ios:1.4.1"
implementation "de.tomgrill.gdxdialogs:gdx-dialogs-ios:1.2.5"
}
}
project(":html") {
apply plugin: "gwt"
apply plugin: "war"
dependencies {
implementation project(":core")
implementation "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion"
implementation "com.badlogicgames.gdx:gdx:$gdxVersion:sources"
implementation "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion:sources"
implementation "com.badlogicgames.gdx:gdx-box2d:$gdxVersion:sources"
implementation "com.badlogicgames.gdx:gdx-box2d-gwt:$gdxVersion:sources"
implementation "com.badlogicgames.gdx:gdx-controllers:$gdxVersion:sources"
implementation "com.badlogicgames.gdx:gdx-controllers-gwt:$gdxVersion"
implementation "com.badlogicgames.gdx:gdx-controllers-gwt:$gdxVersion:sources"
implementation "com.badlogicgames.gdx:gdx-ai:$aiVersion:sources"
implementation "com.badlogicgames.ashley:ashley:$ashleyVersion:sources"
implementation "com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion:sources"
implementation "net.dermetfan.libgdx-utils:libgdx-utils:0.13.4:sources"
implementation "com.kotcrab.vis:vis-ui:1.3.0:sources"
implementation "net.dermetfan.libgdx-utils:libgdx-utils:0.13.4:sources"
implementation "net.dermetfan.libgdx-utils:libgdx-utils-box2d:0.13.4:sources"
implementation "de.tomgrill.gdxfacebook:gdx-facebook-core:1.4.1:sources"
implementation "de.tomgrill.gdxfacebook:gdx-facebook-html:1.4.1:sources"
implementation "de.tomgrill.gdxdialogs:gdx-dialogs-html:1.2.5"
implementation "de.tomgrill.gdxdialogs:gdx-dialogs-html:1.2.5:sources"
compile "de.tomgrill.gdxdialogs:gdx-dialogs-core:1.2.5:sources"
implementation "com.github.czyzby:gdx-kiwi:1.9.1.9.6:sources"
implementation "com.github.czyzby:gdx-kiwi:1.9.1.9.6:sources"
implementation "com.github.czyzby:gdx-lml:1.9.1.9.6:sources"
implementation "com.github.czyzby:gdx-lml-vis:1.9.1.9.6:sources"
implementation "com.kotcrab.vis:vis-ui:1.3.0:sources"
implementation "com.github.czyzby:gdx-kiwi:1.9.1.9.6:sources"
implementation "com.github.czyzby:gdx-lml:1.9.1.9.6:sources"
}
}
project(":core") {
apply plugin: "java"
dependencies {
implementation "com.badlogicgames.gdx:gdx:$gdxVersion"
implementation "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
implementation "com.badlogicgames.gdx:gdx-controllers:$gdxVersion"
implementation "com.badlogicgames.gdx:gdx-ai:$aiVersion"
implementation "com.badlogicgames.ashley:ashley:$ashleyVersion"
implementation "com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion"
implementation "net.dermetfan.libgdx-utils:libgdx-utils:0.13.4"
implementation "com.kotcrab.vis:vis-ui:1.3.0"
implementation "net.dermetfan.libgdx-utils:libgdx-utils-box2d:0.13.4"
implementation "de.tomgrill.gdxfacebook:gdx-facebook-core:1.4.1"
compile "de.tomgrill.gdxdialogs:gdx-dialogs-core:1.2.5"
implementation "com.github.czyzby:gdx-kiwi:1.9.1.9.6"
implementation "com.github.czyzby:gdx-lml-vis:1.9.1.9.6"
implementation "com.github.czyzby:gdx-lml:1.9.1.9.6"
}
}
project(":ios-moe") {
apply plugin: "moe"
configurations { natives }
dependencies {
implementation project(":core")
implementation "com.badlogicgames.gdx:gdx-backend-moe:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-ios"
implementation "de.tomgrill.gdxfacebook:gdx-facebook-ios-moe:1.4.1"
implementation "de.tomgrill.gdxdialogs:gdx-dialogs-ios-moe:1.2.5"
}
}
tasks.eclipse.doLast {
delete ".project"
}
build.gradle (Module: android)
(请注意,我已将 key_pass keyAlias、keyPassword、storeFile 和 storePassword 替换为 '*****',在实际的 gradle 文件中,它们是不同的
android {
signingConfigs {
key_pass {
keyAlias '*****'
keyPassword '******'
storeFile file('*****')
storePassword '*****'
}
}
buildToolsVersion "27.0.3"
compileSdkVersion 27
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
}
packagingOptions {
exclude 'META-INF/robovm/ios/robovm.xml'
}
defaultConfig {
applicationId "com.mygdx.game4"
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
// called every time gradle gets executed, takes the native dependencies of
// the natives configuration, and extracts them to the proper libs/ folders
// so they get packed with the APK.
task copyAndroidNatives() {
file("libs/armeabi/").mkdirs();
file("libs/armeabi-v7a/").mkdirs();
file("libs/arm64-v8a/").mkdirs();
file("libs/x86_64/").mkdirs();
file("libs/x86/").mkdirs();
configurations.natives.files.each { jar ->
def outputDir = null
if (jar.name.endsWith("natives-arm64-v8a.jar")) outputDir = file("libs/arm64-v8a")
if (jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a")
if (jar.name.endsWith("natives-armeabi.jar")) outputDir = file("libs/armeabi")
if (jar.name.endsWith("natives-x86_64.jar")) outputDir = file("libs/x86_64")
if (jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86")
if (outputDir != null) {
copy {
from zipTree(jar)
into outputDir
include "*.so"
}
}
}
}
task run(type: Exec) {
def path
def localProperties = project.file("../local.properties")
if (localProperties.exists()) {
Properties properties = new Properties()
localProperties.withInputStream { instr ->
properties.load(instr)
}
def sdkDir = properties.getProperty('sdk.dir')
if (sdkDir) {
path = sdkDir
} else {
path = "$System.env.ANDROID_HOME"
}
} else {
path = "$System.env.ANDROID_HOME"
}
def adb = path + "/platform-tools/adb"
commandLine "$adb", 'shell', 'am', 'start', '-n', 'com.mygdx.game4/com.mygdx.game4.AndroidLauncher'
}
// sets up the Android Eclipse project, using the old Ant based build.
eclipse {
// need to specify Java source sets explicitly, SpringSource Gradle Eclipse plugin
// ignores any nodes added in classpath.file.withXml
sourceSets {
main {
java.srcDirs "src", 'gen'
}
}
jdt {
sourceCompatibility = 1.6
targetCompatibility = 1.6
}
classpath {
plusConfigurations += [project.configurations.compile]
containers 'com.android.ide.eclipse.adt.ANDROID_FRAMEWORK', 'com.android.ide.eclipse.adt.LIBRARIES'
}
project {
name = appName + "-android"
natures 'com.android.ide.eclipse.adt.AndroidNature'
buildCommands.clear();
buildCommand "com.android.ide.eclipse.adt.ResourceManagerBuilder"
buildCommand "com.android.ide.eclipse.adt.PreCompilerBuilder"
buildCommand "org.eclipse.jdt.core.javabuilder"
buildCommand "com.android.ide.eclipse.adt.ApkBuilder"
}
}
// sets up the Android Idea project, using the old Ant based build.
idea {
module {
sourceDirs += file("src");
scopes = [COMPILE: [plus: [project.configurations.compile]]]
iml {
withXml {
def node = it.asNode()
def builder = NodeBuilder.newInstance();
builder.current = node;
builder.component(name: "FacetManager") {
facet(type: "android", name: "Android") {
configuration {
option(name: "UPDATE_PROPERTY_FILES", value: "true")
}
}
}
}
}
}
}
dependencies {
}
- `build.gradle (Module: core)`
apply plugin: "java"
sourceCompatibility = 1.6
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
sourceSets.main.java.srcDirs = [ "src/" ]
eclipse.project {
name = appName + "-core"
}
- `gradle-wrapper.properties (Gradel Version)`
#Sun Dec 30 13:51:33 EST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
- `proguard-rules.pro`
# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
-verbose
-dontwarn android.support.**
-dontwarn com.badlogic.gdx.backends.android.AndroidFragmentApplication
-dontwarn com.badlogic.gdx.utils.GdxBuild
-dontwarn com.badlogic.gdx.physics.box2d.utils.Box2DBuild
-dontwarn com.badlogic.gdx.jnigen.BuildTarget*
-dontwarn com.badlogic.gdx.graphics.g2d.freetype.FreetypeBuild
-keep class com.badlogic.gdx.controllers.android.AndroidControllers
-keepclassmembers class com.badlogic.gdx.backends.android.AndroidInput* {
<init>(com.badlogic.gdx.Application, android.content.Context, java.lang.Object, com.badlogic.gdx.backends.android.AndroidApplicationConfiguration);
}
-keepclassmembers class com.badlogic.gdx.physics.box2d.World {
boolean contactFilter(long, long);
void beginContact(long);
void endContact(long);
void preSolve(long, long);
void postSolve(long, long);
boolean reportFixture(long);
float reportRayFixture(long, float, float, float, float, float);
}
- `gradle.properties`
org.gradle.daemon=true
org.gradle.jvmargs=-Xms128m -Xmx1500m
org.gradle.configureondemand=false
- `settings.gradle`
include 'desktop', 'android', 'ios', 'html', 'core', 'ios-moe'
- `local.properties`
# Location of the android SDK
sdk.dir=/home/Android/Sdk
好吧,我发现了问题,我只是少了一个额外的步骤,我不得不在 "Project Properties"->Modules: android 和 [=15= 下进行 "Build Types" ] 密钥库,我以为我已经 selected,通过在签名下突出显示它。
我的解决方案:
1.- 在 Android Studio 4.0.1 中:构建/生成签名构建/APK 生成New Key Store 没有的情况下,把所有参数都放上去。
2.- 一旦你已经有了密钥库,就可以生成 APK 的签名版本,使用与点 1
相同的密码和别名3.- 我选择调试并启用检查:V2(完整 APK 签名)并按下按钮完成
4.- 最后,在文件/项目结构中,转到模块/签名配置并再次对参数进行数字化并确定。
按照 Android 工作室中的这些步骤,我可以毫无问题地将我的应用程序部署到我的 AVD 中。
Click here: This is the image with the steps, for a better understanding
问候和愉快的编码研究员。