[英]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:编辑:我发现的几件事:
e: Wrong plugin option format: null, should be plugin:<pluginId>:<optionName>=<value>
is apparently a message from kotlinc
(I guess, the kotlin compiler), as noted in KT-41303: CLI: "wrong plugin option format: null, should be plugin::=" with compiler plugins e: Wrong plugin option format: null, should be plugin:<pluginId>:<optionName>=<value>
显然是来自kotlinc
(我猜是 kotlin 编译器)的消息,如KT-41303 中所述:CLI:“错误插件选项格式:null,应该是 plugin::=" 带有编译器插件./gradlew
calls kotlinc
- however, not even --debug
does not output such a command line, because "That's not possible. Simply, because most of the Gradle tasks do not invoke CLI commands."./gradlew
何时以及如何调用kotlinc
- 然而,甚至--debug
也不会输出这样的命令行,因为“这是不可能的。简单地说,因为大多数 Gradle 任务不会调用CLI 命令。” ( How can I view the CLI command executed by a Gradle task in Android Studio? ) .idea
folder, reimported again - did not get that message anymore, but still same plugin null error.idea
文件夹,再次重新导入 - 不再收到该消息,但仍然是相同的插件 null 错误compileDebugKotlin
step is the one failing, which can be triggered with ./gradlew :app:compileDebugKotlin --info
- but still the same error.compileDebugKotlin
步骤是失败的一步,可以使用./gradlew :app:compileDebugKotlin --info
触发 - 但仍然是相同的错误。Well, finally opened the project with Android Studio 4.0.1, and:好了,终于用Android Studio 4.0.1打开了项目,并且:
ext.kotlin_version = '1.3.72'
from 1.2.0ext.kotlin_version = '1.3.72'
... 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.