如何从命令行(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)?
问题描述
我找到了这篇文章: https://android. jlelse.eu/yet-another-awesome-kotlin-feature-parcelize-5439718ba220 -我想在那里查看代码, https://github.com/burakeregar/KotlinParcelize .
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.
我正在使用Ubuntu 18.04,我想到了在终端中运行./gradlew
.
I am using Ubuntu 18.04, and I thought of running ./gradlew
in terminal.
我的Android SDK目录位于例如/path/to/adt-bundle-linux-x86-20140321/sdk
...
My Android SDK dir is in, say, /path/to/adt-bundle-linux-x86-20140321/sdk
...
所以,我做到了:
$ 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
嗯,这是Java问题;我的默认值是Java 11,但是我也有Java 8,所以请尝试:
Eh, so a Java problem; my default is java 11, but I have java 8 too, so try that:
$ 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
好,再试一次:
$ ./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
对,所以我这样做:
$ echo sdk.dir=/path/to/adt-bundle-linux-x86-20140321/sdk > local.properties
好,再试一次:
$ ./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
好吧,所以我运行/path/to/adt-bundle-linux-x86-20140321/sdk/tools/android
,安装Build-Tools 26.0.2(显然,仓库中gradle版本的最低版本,以及我以前没有的那些构建工具),再试一次:
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:
$ 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
如果您运行./gradlew assembleDebug --debug
,您将获得包含约6400多个行的大量日志,我将其粘贴在此处:
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:
...
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?
我发现的一些东西:
-
e: Wrong plugin option format: null, should be plugin:<pluginId>:<optionName>=<value>
显然是来自kotlinc
的消息(我想是kotlin编译器),如 - 因此,很高兴看到
./gradlew
何时以及如何调用kotlinc
-但是,即使--debug
也不输出这样的命令行,因为这是不可能的".简而言之,因为大多数Gradle任务不调用CLI命令. (如何可以在Android Studio中查看Gradle任务执行的CLI命令吗?) - 我尝试在Android Studio 4.0.1中导入它,并在某个时间收到消息
e: Wrong plugin option format: null, should be plugin:<pluginId>:<optionName>=<value>
is apparently a message fromkotlinc
(I guess, the kotlin compiler), as noted in KT-41303: CLI: "wrong plugin option format: null, should be plugin::=" with compiler plugins- So, it would have been nice to see when and how
./gradlew
callskotlinc
- 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." ( How can I view the CLI command executed by a Gradle task in Android Studio? ) - I tried importing this in Android Studio 4.0.1, and at a certain time, I got the message Unsupported Modules Detected: Unfortunately you can't have non-Gradle Java modules and Android-Gradle modules in one project ; then I deleted
.idea
folder, reimported again - did not get that message anymore, but still same plugin null error - Bit more digging in the debug log, it can be determined that the
compileDebugKotlin
step is the one failing, which can be triggered with./gradlew :app:compileDebugKotlin --info
- but still the same error.
推荐答案
好吧,终于使用Android Studio 4.0.1打开了该项目,并且:
Well, finally opened the project with Android Studio 4.0.1, and:
- 将项目中的gradle更新为6.1.1(从原始的4.1)
- 从1.2.0更新到
ext.kotlin_version = '1.3.72'
- 使用kotlin-stdlib-jdk7代替kotlin-stdlib-jre7(因为我在某处收到了弃用消息)
...,现在我没有得到错误的插件选项格式"不再-但现在我得到类'PersonModel'不是抽象的,并且不实现抽象成员公共抽象..." -我会问一个新问题.
... 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.
这篇关于如何从命令行(Ubuntu 18.04,失败:错误的插件选项格式)构建此gradle项目(KotlinParcelize)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!