简体   繁体   English

如何从命令行(Ubuntu 18.04,失败:错误的插件选项格式)构建这个 gradle 项目 (KotlinParcelize)?

[英]How can I build this gradle project (KotlinParcelize) from the command line (Ubuntu 18.04, fail: Wrong plugin option format)?

I found this article: https://android.jlelse.eu/yet-another-awesome-kotlin-feature-parcelize-5439718ba220 - and I wanted to look at the code there, https://github.com/burakeregar/KotlinParcelize .我找到了这篇文章: https : //android.jlelse.eu/yet-another-awesome-kotlin-feature-parcelize-5439718ba220 - 我想看看那里的代码, https://github.com/burakeregar/KotlinParcelize .

I am using Ubuntu 18.04, and I thought of running ./gradlew in terminal.我正在使用 Ubuntu 18.04,我想在终端中运行./gradlew

My Android SDK dir is in, say, /path/to/adt-bundle-linux-x86-20140321/sdk ...我的 Android SDK 目录在/path/to/adt-bundle-linux-x86-20140321/sdk ...

So, I did:所以我做了:

$ cd /tmp
$ git clone https://github.com/burakeregar/KotlinParcelize.git KotlinParcelize_git
Cloning into 'KotlinParcelize_git'...
remote: Enumerating objects: 75, done.
remote: Total 75 (delta 0), reused 0 (delta 0), pack-reused 75
Unpacking objects: 100% (75/75), done.
$ cd KotlinParcelize_git/
$ ./gradlew assembleDebug
Downloading https://services.gradle.org/distributions/gradle-4.1-all.zip
.....................................................................
Unzipping //home/user/.gradle/wrapper/dists/gradle-4.1-all/bzyivzo6n839fup2jbap0tjew/gradle-4.1-all.zip to //home/user/.gradle/wrapper/dists/gradle-4.1-all/bzyivzo6n839fup2jbap0tjew
Set executable permissions for: //home/user/.gradle/wrapper/dists/gradle-4.1-all/bzyivzo6n839fup2jbap0tjew/gradle-4.1/bin/gradle

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine java version from '11.0.8'.

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

* Get more help at https://help.gradle.org

Eh, so a Java problem;嗯,这是一个 Java 问题; my default is java 11, but I have java 8 too, so try that:我的默认是 java 11,但我也有 java 8,所以试试:

$ apt-show-versions -r openjdk | grep uptodate
openjdk-11-jre:amd64/bionic-security 11.0.8+10-0ubuntu1~18.04.1 uptodate
openjdk-11-jre-headless:amd64/bionic-security 11.0.8+10-0ubuntu1~18.04.1 uptodate
openjdk-8-jdk:amd64/bionic-security 8u265-b01-0ubuntu2~18.04 uptodate
openjdk-8-jdk-headless:amd64/bionic-security 8u265-b01-0ubuntu2~18.04 uptodate
openjdk-8-jre:amd64/bionic-security 8u265-b01-0ubuntu2~18.04 uptodate
openjdk-8-jre-headless:amd64/bionic-security 8u265-b01-0ubuntu2~18.04 uptodate

$ sudo update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                            Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1111      auto mode
  1            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1111      manual mode
  2            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1081      manual mode

Press <enter> to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java to provide /usr/bin/java (java) in manual mode

Ok, try again:好的,再试一次:

$ ./gradlew assembleDebug

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.

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

* Get more help at https://help.gradle.org

BUILD FAILED in 0s

Right, so I do:是的,所以我这样做:

$ echo sdk.dir=/path/to/adt-bundle-linux-x86-20140321/sdk > local.properties 

Ok, try again:好的,再试一次:

$ ./gradlew assembleDebug

> Configure project :app
Configuration 'compile' in project ':app' is deprecated. Use 'implementation' instead.
Observed package id 'build-tools;19.0.3' in inconsistent location '/path/to/adt-bundle-linux-x86-20140321/sdk/build-tools/android-4.4.2' (Expected '/path/to/adt-bundle-linux-x86-20140321/sdk/build-tools/19.0.3')
Checking the license for package Android SDK Build-Tools 26.0.2 in /path/to/adt-bundle-linux-x86-20140321/sdk/licenses
Warning: License for package Android SDK Build-Tools 26.0.2 not accepted.


FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> You have not accepted the license agreements of the following SDK components:
  [Android SDK Build-Tools 26.0.2].
  Before building your project, you need to accept the license agreements and complete the installation of the missing components using the Android Studio SDK Manager.
  Alternatively, to learn how to transfer the license agreements from one workstation to another, go to http://d.android.com/r/studio-ui/export-licenses.html

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

* Get more help at https://help.gradle.org

BUILD FAILED in 1s

Ok, so I run /path/to/adt-bundle-linux-x86-20140321/sdk/tools/android , install Build-Tools 26.0.2 (apparently the minimum version for the gradle version in the repo, and those build tools I did not have before), try again:好的,所以我运行/path/to/adt-bundle-linux-x86-20140321/sdk/tools/android ,安装 Build-Tools 26.0.2(显然是 repo 中 gradle 版本的最低版本,以及那些构建工具我以前没有),再试一次:

$ git add -f local.properties # so it does not get deleted by git clean

$ git clean -dxf

$ ./gradlew --stop
Stopping Daemon(s)
1 Daemon stopped

$ ./gradlew assembleDebug
Starting a Gradle Daemon, 5 stopped Daemons could not be reused, use --status for details

> Configure project :app
Configuration 'compile' in project ':app' is deprecated. Use 'implementation' instead.
Observed package id 'build-tools;19.0.3' in inconsistent location '/path/to/adt-bundle-linux-x86-20140321/sdk/build-tools/android-4.4.2' (Expected '/path/to/adt-bundle-linux-x86-20140321/sdk/build-tools/19.0.3')
Observed package id 'build-tools;19.0.3' in inconsistent location '/path/to/adt-bundle-linux-x86-20140321/sdk/build-tools/android-4.4.2' (Expected '/path/to/adt-bundle-linux-x86-20140321/sdk/build-tools/19.0.3')

e: Wrong plugin option format: null, should be plugin:<pluginId>:<optionName>=<value>

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugKotlin'.
> Compilation error. See log for more details

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

* Get more help at https://help.gradle.org

BUILD FAILED in 10s
12 actionable tasks: 12 executed

If you run ./gradlew assembleDebug --debug , you get a massive log of some 6400+ lines, which I pasted here: KotlinParcelize_gradlew_debug.log , the only relevant part seems to be:如果你运行./gradlew assembleDebug --debug ,你会得到大约 6400+ 行的大量日志,我粘贴在这里: KotlinParcelize_gradlew_debug.log ,唯一相关的部分似乎是:

...
12:05:09.468 [DEBUG] [sun.rmi.transport.tcp] RMI TCP Connection(2)-127.0.0.1: accepted socket from [127.0.0.1:26356]
12:05:09.469 [DEBUG] [sun.rmi.transport.tcp] RMI TCP Connection(2)-127.0.0.1: (port 1757) op = 80
12:05:09.469 [DEBUG] [sun.rmi.loader] RMI TCP Connection(2)-127.0.0.1: name = "[Ljava.rmi.server.ObjID;", codebase = "", defaultLoader = sun.misc.Launcher$ExtClassLoader@3d7dbe2d
12:05:09.469 [DEBUG] [sun.rmi.loader] RMI TCP Connection(2)-127.0.0.1: name = "java.rmi.server.ObjID", codebase = "", defaultLoader = sun.misc.Launcher$ExtClassLoader@3d7dbe2d
12:05:09.470 [DEBUG] [sun.rmi.loader] RMI TCP Connection(2)-127.0.0.1: name = "java.rmi.server.UID", codebase = "", defaultLoader = sun.misc.Launcher$ExtClassLoader@3d7dbe2d
12:05:09.470 [DEBUG] [sun.rmi.loader] RMI TCP Connection(2)-127.0.0.1: name = "java.rmi.dgc.Lease", codebase = "", defaultLoader = sun.misc.Launcher$ExtClassLoader@3d7dbe2d
12:05:09.472 [DEBUG] [sun.rmi.loader] RMI TCP Connection(2)-127.0.0.1: name = "java.rmi.dgc.VMID", codebase = "", defaultLoader = sun.misc.Launcher$ExtClassLoader@3d7dbe2d
12:05:09.473 [DEBUG] [sun.rmi.loader] RMI TCP Connection(2)-127.0.0.1: name = "[B", codebase = "", defaultLoader = sun.misc.Launcher$ExtClassLoader@3d7dbe2d
12:05:09.488 [DEBUG] [sun.rmi.transport.tcp] RMI TCP Connection(2)-127.0.0.1: (port 1757) op = 82
12:05:09.488 [DEBUG] [sun.rmi.transport.tcp] RMI TCP Connection(2)-127.0.0.1: (port 1757) op = 80
12:05:09.521 [DEBUG] [sun.rmi.transport.tcp] RMI TCP Connection(2)-127.0.0.1: (port 1757) op = 82
12:05:09.526 [DEBUG] [sun.rmi.transport.tcp] RMI TCP Connection(2)-127.0.0.1: (port 1757) op = 80
12:05:09.526 [ERROR] [org.gradle.api.Task] e: Wrong plugin option format: null, should be plugin:<pluginId>:<optionName>=<value>
12:05:09.532 [DEBUG] [sun.rmi.transport.tcp] RMI TCP Connection(2)-127.0.0.1: (port 1757) op = 80
12:05:09.533 [DEBUG] [sun.rmi.loader] RMI TCP Connection(2)-127.0.0.1: name = "org.jetbrains.kotlin.daemon.report.CompileIterationResult", codebase = ""
12:05:09.533 [DEBUG] [sun.rmi.loader] RMI TCP Connection(2)-127.0.0.1: name = "java.util.LinkedHashSet", codebase = ""
12:05:09.533 [DEBUG] [sun.rmi.loader] RMI TCP Connection(2)-127.0.0.1: name = "java.util.HashSet", codebase = ""
12:05:09.533 [DEBUG] [sun.rmi.loader] RMI TCP Connection(2)-127.0.0.1: name = "java.io.File", codebase = ""
12:05:09.534 [DEBUG] [org.gradle.api.Project] [KOTLIN] compile iteration: app/src/main/java/com/burakeregar/kotlinparcelize/MainActivity.kt, app/src/main/java/com/burakeregar/kotlinparcelize/PersonModel.kt, app/src/main/java/com/burakeregar/kotlinparcelize/SecondActivity.kt
...

... but I still cannot understand - what plugin is in "Wrong plugin option format"? ...但我仍然无法理解 - “错误的插件选项格式”是什么插件?

Well, I'm stuck here .... How can I get this example to compile?好吧,我被困在这里.... 我怎样才能编译这个例子?


EDIT: few things I found:编辑:我发现的几件事:

Well, finally opened the project with Android Studio 4.0.1, and:好了,终于用Android Studio 4.0.1打开了项目,并且:

  • Updated gradle in project to 6.1.1 (from the original 4.1)将项目中的 gradle 更新到 6.1.1(从原来的 4.1)
  • Updated to ext.kotlin_version = '1.3.72' from 1.2.0从 1.2.0 更新为ext.kotlin_version = '1.3.72'
  • Used kotlin-stdlib-jdk7 instead of kotlin-stdlib-jre7 (because I got a deprecation message somewhere)使用 kotlin-stdlib-jdk7 而不是 kotlin-stdlib-jre7(因为我在某处收到了弃用消息)

... and now I do not get the "Wrong plugin option format" anymore - but now I get "Class 'PersonModel' is not abstract and does not implement abstract member public abstract ..." - which I'll ask a new question about. ......现在我不再得到“错误的插件选项格式” - 但现在我得到“类'PersonModel'不是抽象的并且没有实现抽象成员公共抽象......” - 我会问一个新的关于问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Windows上使用Ubuntu的Windows JDK构建Gradle项目? - How can I build my Gradle project using a Windows JDK from Ubuntu on Windows? 我如何将命令行选项传递给phantomjs Maven插件 - How can i pass command line option to phantomjs maven plugin 如何从gradle项目中的命令行覆盖集成测试中的属性? - How can I override a property in an integration test from the command line in a gradle project? 如何从命令行将 VM arguments 传递给 gradle? - How can I pass VM arguments to gradle from command line? 如何为现有项目构建Gradle? - How can I build Gradle for existing project? 如何从命令行禁用 Maven Javadoc 插件? - How can I disable the Maven Javadoc plugin from the command line? 如何从命令行在 Java Gradle 项目中运行 main 方法? - How do I run a main method in a Java Gradle project from command line? 如何使用Gradle构建作为根项目依赖项的Maven项目? - How can I build a Maven project, as a dependency to the root project, with Gradle? 如何从命令行运行springmvc + gradle项目? - How to run a springmvc+gradle project from command line? 如何在 gradle 构建期间通过命令行提供 -noverify VM 选项? - How to supply -noverify VM option via command line during gradle build?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM