【问题标题】:Error while building android application using gradle via command line通过命令行使用gradle构建android应用程序时出错
【发布时间】:2020-07-26 16:34:17
【问题描述】:

我正在开发一个 Java 反混淆应用程序,我需要通过 gradle 使用命令行从其源代码构建多个 android 应用程序。我去了 gradle 文件夹以及 build.gradle 和 gradle.properties 文件所在的项目目录,并在终端中运行了命令gradle wrapper。这是我得到的:

$ gradle wrapper
Starting a Gradle Daemon, 1 stopped Daemon could not be reused, use --status for details

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':lib'.
> Could not create an instance of type com.novoda.release.internal.compat.gradle5_3.AndroidSoftwareComponentCompat_Gradle_5_3.
   > org/gradle/api/internal/java/usagecontext/LazyConfigurationUsageContext

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

谁能解释我为什么会收到这个错误并告诉我我做错了什么? 还有谁能解释或提供合适的资源来解释如何使用 gradle 以易于理解的方式从源代码构建 APK?

感谢和抱歉英语不好。

我的 gradle 版本:

Gradle 6.5.1
------------------------------------------------------------

Build time:   2020-06-30 06:32:47 UTC
Revision:     66bc713f7169626a7f0134bf452abde51550ea0a

Kotlin:       1.3.72
Groovy:       2.5.11
Ant:          Apache Ant(TM) version 1.10.7 compiled on September 1 2019
JVM:          11.0.8 (Ubuntu 11.0.8+10-post-Ubuntu-0ubuntu118.04.1)
OS:           Linux 5.4.0-42-generic amd64

我的java版本:

$ java -version
openjdk version "11.0.8" 2020-07-14
OpenJDK Runtime Environment (build 11.0.8+10-post-Ubuntu-0ubuntu118.04.1)
OpenJDK 64-Bit Server VM (build 11.0.8+10-post-Ubuntu-0ubuntu118.04.1, mixed mode, sharing)

编辑:运行gradle init 得到与上面相同的结果。

【问题讨论】:

    标签: android gradle build.gradle


    【解决方案1】:

    您应该使用命令assemble{YourBuildVariantHere} 执行./gradlew 文件。

    例如:./gradlew assembleDevelopDebug

    然后你应该把你的APK放在app/build/outputs/apk/your/build/variant

    【讨论】:

    • 不幸的是,项目目录中没有名为 gradlew 的脚本文件,这就是为什么我首先运行包装函数以希望生成它。
    猜你喜欢
    • 2014-08-15
    • 1970-01-01
    • 2013-05-22
    • 2018-09-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-27
    相关资源
    最近更新 更多