如何使用Gradle实验插件对64位Android APK进行代码签名? [英] How can I codesign a 64-bit Android APK using the Gradle Experimental Plugin?

查看:153
本文介绍了如何使用Gradle实验插件对64位Android APK进行代码签名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用开放框架(一种支持Android的C ++框架)开发Android应用程序.它的Android项目使用Gradle实验性插件来支持C ++. 我已经能够使用这些工具来构建运行得很好的 unsigned APK (使用Android Studio 2.3.2、3.0、3.5或3.5.1,Experimental Gradle Plugin 0.9. 3,Gradle发行版3.3.0). 但是现在我需要对其进行代码签名并包括64位版本,以将其发布到Android应用商店中.

I am developing a Android apps using Open Frameworks, a C++ framework which supports Android. Its Android projects use the Gradle experimental plugin to allow C++. I have been able to get these to build unsigned APK's that run just fine (using Android Studio 2.3.2, 3.0, 3.5 or 3.5.1, Experimental Gradle Plugin 0.9.3, and Gradle distribution 3.3.0). But now I need to codesign them and include 64-bit versions to post them to the Android Store.

Gradle实验性插件始终要求其自己的每个版本都具有特定版本的Gradle发行版.并且该插件的当前文档页面表示我们可以继续在Android Studio 3.0或更高版本上使用实验性插件0.11.0",但是上述内容似乎在Android Studio 3.5和3.5.1中被阻止进行代码签名.

The Gradle Experimental Plugin has always required a specific single version of Gradle distribution for each of its own versions. And the current doc page for the plugin says that we can "keep using experimental plugin 0.11.0 with Android Studio 3.0 or later", but I seem to be blocked from code-signing by the above in Android Studio 3.5 and 3.5.1.

当我尝试使用最新版本的Android Studio(3.5或3.5.1版)生成带签名的APK"时,我被要求4.1版以上的版本"阻止.

当我尝试使用旧版本的Android Studio(版本2.3.2或3.0)来生成签名APK"时,我可以构建32位带代码签名的APK,但是我不知道如何构建64位位APK.我发现的文档似乎不适用于我从Open Frameworks获得的Gradle文件.

When I try to use older versions of Android Studio (version 2.3.2 or 3.0) to "Generate Signed APK", I can build 32-bit codesigned APKs, but I don't know how to build 64-bit APKs. The documentation I have found doesn't seem to apply to the Gradle files I have from Open Frameworks.

关于我试图对此进行处理的注意事项:

Notes on my attempts to get a handle on this:

(据我所知,Gradle插件版本与Gradle发行版所映射的在此表中.)

(As I think I understand it, Gradle Plugin version is different from Gradle distribution version as mapped in this table.)

我在任何地方都可以找到与Gradle Experiment插件0.11.0一起使用的Gradle版本 distribution 的唯一来源是

The only source I have found anywhere for what version of Gradle distribution to use with Gradle Experimental plugin 0.11.0, is this answer to a related question. I asked the answerer what version of Android Studio they were using and they said 3.1, but did not mention codesigning (I've now asked them about that).

"Android Gradle插件"版本看起来总是与Android Studio版本相同,因此似乎没有办法在Android Studio 3.5.1上运行Android Gradle插件3.0版本,对吗?

It looks like the "Android Gradle Plugin" version is always the same as the Android Studio version, so there seems to be no way to run Android Gradle Plugin version 3.0 with Android Studio 3.5.1, correct?

因此,根据以上内容,我尝试了:

So based on the above, I tried:

Android Studio(以及因此的Gradle插件版本)2.3.2和使用Gradle发行版3.3.0的实验性Gradle 0.9.3(共同设计32位APK-不知道如何做64位)

Android Studio (and therefore Gradle Plugin version) 2.3.2 with Experimental Gradle 0.9.3 using Gradle distribution 3.3.0 (codesigns 32-bit APKs - don't know how to do 64-bit)

使用Gradle发行版3.3.0的带有实验Gradle 0.9.3的Android Studio(因此也具有Gradle插件版本)3.0.0(共同设计32位APK-不知道如何做64位)

Android Studio (and therefore Gradle Plugin version) 3.0.0 with Experimental Gradle 0.9.3 using Gradle distribution 3.3.0 (codesigns 32-bit APKs - don't know how to do 64-bit)

使用Gradle发行版4.1.0的带有实验性Gradle 0.11.0的Android Studio(以及由此而来的Gradle插件版本)3.0.0-我收到了Gradle错误:

Android Studio (and therefore Gradle Plugin version) 3.0.0 with Experimental Gradle 0.11.0 using Gradle distribution 4.1.0 - I get a Gradle error:

*Gradle sync failed: Exception thrown while executing model rule: BaseComponentModelPlugin.Rules#createVariantData(ModelMap<AndroidBinaryInternal>, ModelMap<AndroidComponentSpec>, TaskManager) > afterEach()
    Consult IDE log for more details (Help | Show Log) (21s 58ms)*

我找到了有关如何使用Gradle创建64位签名APK的假定文档这里,但建议用于列出ABI过滤器的格式:

I found supposed documentation of how to create 64-bit signed APKs with Gradle HERE, but the format suggested for listing ABI filters:

ndk.abiFilters 'armeabi-v7a','arm64-v8a','x86','x86_64'

导致错误,Open Frameworks项目build.gradle尝试包含所有ABI,如build.gradle底部附近的android.productFlavors部分所示,如下所示:

Resulted in an error, and Open Frameworks' project build.gradle tries to include all ABIs as seen in the android.productFlavors section near the bottom of the build.gradle as shown below:

def ofRoot(){ return '../../../' }

// Load common functions
apply from: ofRoot()+"libs/openFrameworksCompiled/project/android/common-functions.gradle"

buildscript {
    apply from: "../../../libs/openFrameworksCompiled/project/android/ndk-verify.gradle"

    repositories {
        jcenter()
    }
    dependencies {
        // Using the gradle-experimental version that supports c++
        classpath 'com.android.tools.build:gradle-experimental:0.9.3'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

apply plugin: 'com.android.model.application'

model {
    android {
        // openFrameworks currently only supports compiling against SDK 19
        compileSdkVersion = 23
        buildToolsVersion = "25.0.3"

        defaultConfig.with {
            minSdkVersion.apiLevel    = 23
            targetSdkVersion.apiLevel = 28
            versionCode     =  4
            versionName     = "0.1.1"
        }
    }

    android.ndk {
        moduleName = ofAppModuleName()
        toolchain  = buildToolchain()
        stl        = compilerStl()
        platformVersion = "21"
    }

    android.sources {
        main {
            jni {
                source {
                    srcDirs= appSrcDirs(ofRoot())

                    includes = srcIncludes(ofRoot())
                    excludes = srcExcludes(ofRoot())
                }

                // Link to openFrameworks
                dependencies {
                    project ":openFrameworksProject"  linkage "static"
                }
            }

            manifest {
                source {
                    srcDirs = [ "." ]
                }
            }
            res {
                source {
                    srcDirs = [ "res" ]
                }
            }
            java {
                source {
                    srcDirs = [ "srcJava" ]
                }
            }
            aidl {
                source{
                    srcDirs = ['srcJava']
                }
            }
            renderscript{
                source{
                    srcDirs = ['srcJava']
                }
            }
            jniLibs {
                source {
                    srcDirs = ['libs']
                }
            }
            assets {
                source {
                    srcDirs = ['bin/data'] + addonData(ofRoot())
                }
            }
        }
    }

    android.lintOptions {
        abortOnError  = false
    }

    android.buildTypes {
        release {
            minifyEnabled = false
        }
    }

    // Setup the different types of flavors (arm / x86),
    // and add linker flags based on that
    android.productFlavors {
        getAbis().each { abi ->
            create(getFlavorName(abi)) {
                ndk {
                    abiFilters.add(abi)

                    cppFlags.addAll(coreCppFlags(abi, ofRoot()))
                    cppFlags.addAll(addonCppFlags(abi, ofRoot()))

                    ldLibs.addAll(coreLdLibs(abi, ofRoot()))
                    ldLibs.addAll(addonLdLibs(abi, ofRoot()))

                    ldFlags.addAll(coreLdFlags(abi, ofRoot()))
                    ldFlags.addAll(addonLdFlags(abi, ofRoot()))
                }
            }
        }
    }
}


dependencies {
    addonJavaDependencies(ofRoot()).each { dep ->
        compile(project(path: dep[1] ))
    }
    compile project(path: ':ofAndroidLib')
}

但这会在codesign APK向导中仅产生32位Arm和386 ABI选项.

But this results in only 32-bit Arm and 386 ABI options in the codesign APK wizard.

谁能告诉我如何使用Android Studio(任何版本)为实验性插件构建带有代码签名的64位APK?

推荐答案

在开放框架论坛上的帮助下,经过数天的努力,我终于设法使它开始工作.它不仅涉及代码签名,还涉及使用支持64位版本的OpenFrameworks版本以及大量特定设置和步骤.

I managed to eventually get it to work after many days of head-banging, with help on the Open Frameworks forum. It involved not just code-signing but using a version of OpenFrameworks that supports 64-bit builds, and a large number of specific settings and steps.

有关最终可行的步骤,版本和设置的注释在这里:

My notes on the steps, versions and settings that finally worked are here: https://forum.openframeworks.cc/t/notes-on-steps-i-took-to-successfully-get-a-64-bit-apk-published-to-the-google-app-store/33722

同时,如果有人对主题有任何其他有用的信息,请在此处的答案中分享.我会悬赏除我以外的最有用/最相关的答案.

Meanwhile, if anyone has any other useful information the subject, please share it in an answer here. I'll give the bounty to the most useful/relevant answer other than mine.

这篇关于如何使用Gradle实验插件对64位Android APK进行代码签名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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