简体   繁体   English

Kotlin胶囊摇篮错误

[英]Kotlin Capsule Gradle Error

I'm getting an error when trying to create a capsule using Gradle. 尝试使用Gradle创建胶囊时出现错误。

Failed to find Premain-Class manifest attribute in 

E:\Dropbox\Projects\Kotlin\Games\CSGO\Charlatano\build\libs\capsule.jar
Error occurred during initialization of VM
agent library failed to init: instrument
CAPSULE: Client connection failed.
CAPSULE EXCEPTION: Accept timed out while processing null null: null (for stack trace, run with -Dcapsule.log=verbose)
Press any key to continue . . .

Here is my build.script 这是我的build.script

buildscript {
    ext.kotlin_version = '1.1-M01'
    ext.jna_version = '4.3.0-SNAPSHOT'
    ext.quasar_version = '0.7.6'
    ext.gdxVersion = '1.9.4'

    repositories {
        mavenCentral()
        maven { url 'https://dl.bintray.com/kotlin/kotlin-eap-1.1' }
    }

    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

apply plugin: 'java'
apply plugin: 'kotlin'
apply plugin: 'application'

group 'com.charlatano'
version '0.4.3'

mainClassName = 'com.charlatano.Charlatano'

sourceCompatibility = JavaVersion.VERSION_1_8

repositories {
    mavenCentral()
    maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
    maven { url 'https://dl.bintray.com/kotlin/kotlin-eap-1.1' }
}

configurations {
    quasar
    capsule
}

dependencies {
    compile group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib', version: kotlin_version

    compile group: 'net.java.dev.jna', name: 'jna', version: jna_version
    compile group: 'net.java.dev.jna', name: 'jna-platform', version: jna_version

    compile group: 'org.jire.arrowhead', name: 'arrowhead', version: '1.2.1'

    capsule group: 'co.paralleluniverse', name: 'capsule', version: '1.0.3'
    quasar group: 'co.paralleluniverse', name: 'quasar-core', version: quasar_version

    compile group: 'co.paralleluniverse', name: 'quasar-core', version: quasar_version
    compile group: 'co.paralleluniverse', name: 'quasar-actors', version: quasar_version
    compile group: 'co.paralleluniverse', name: 'quasar-kotlin', version: quasar_version

    compile "com.badlogicgames.gdx:gdx:$gdxVersion"
    compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"

    compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
    compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
    compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
}

task capsule(type: Jar, dependsOn: jar) {
    archiveName = "capsule.jar"
    from jar // embed our application jar
    from { configurations.runtime } // embed dependencies

    from(configurations.capsule.collect { zipTree(it) }) { include 'Capsule.class' } // we just need the single Capsule class

    manifest {
        attributes(
                'Main-Class'  :    'Capsule',
                'Application-Class'   : mainClassName,
                'Extract-Capsule' : 'false', // no need to extract the capsule
                'Min-Java-Version' : '1.8.0',
                'JVM-Args' : run.jvmArgs.join(' '),
                'System-Properties' : run.systemProperties.collect { k,v -> "$k=$v" }.join(' '),
                'Java-Agents' : configurations.quasar.iterator().next().getName()
        )
    }
}

run {
    jvmArgs "-javaagent:${configurations.quasar.iterator().next()}"
}

Here are the jar files it generates. 这是它生成的jar文件。 https://dl.dropboxusercontent.com/u/91292881/ShareX/2016/09/libs.zip https://dl.dropboxusercontent.com/u/91292881/ShareX/2016/09/libs.zip

Please tell me what is wrong, thanks! 请告诉我有什么问题,谢谢!

It seems that MANIFEST.md in capsule is broken and it misses a Premain-Class attribute like below: capsule中的MANIFEST.md似乎已损坏,并且Premain-Class如下的Premain-Class属性:

Premain-Class: org.eclipse.package.ObjectSizeFetcher

Your's capsule manifest file should look like: 您的capsule清单文件应如下所示:

Manifest-Version: 1.0
Created-By: 1.5.0_18 (Sun Microsystems Inc.)
Premain-Class: org.eclipse.package.ObjectSizeFetcher

Check similar issue to find more: "Failed to load Premain-Class manifest attribute" while trying to get the size of an object using java agent 检查类似问题以查找更多信息: 尝试使用Java代理获取对象的大小时,“无法加载Premain-Class清单属性”

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

相关问题 错误:Kotlin:在 Spring 的项目中使用不兼容版本的 Kotlin 编译模块使用 Java 而非 Kotlin 而非 gradle 启动 - Error:Kotlin: Module was compiled with an incompatible version of Kotlin in a project of Spring Boot with Java not Kotlin not gradle kotlin 和 gradle jar 出现“错误:无法找到或加载主 class” - kotlin with gradle jar got 'Error: Could not find or load main class ' Kotlin DSL配置Java规范时发生Gradle编译错误 - Gradle Compilation Error with Kotlin DSL configuring Java Spec 没有 org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21 的缓存版本可用于离线模式错误 - No cached version of org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21 available for offline mode Error Gradle Kotlin、Cucumber 和 OKHttp - Gradle Kotlin, Cucumber, and OKHttp Kotlin警告与gradle构建 - Kotlin warnings with gradle build 错误:Android Gradle插件仅支持Kotlin Gradle插件版本1.3.0及更高版本 - ERROR: The Android Gradle plugin supports only Kotlin Gradle plugin version 1.3.0 and higher 使用Kotlin配置Gradle - Configuring Gradle with Kotlin 使用Kotlin和Gradle - using Kotlin with Gradle 当我运行 gradle kotlin 应用程序时,我收到一个编译错误 ` 只有 Kotlin 标准库被允许使用 'kotlin' 包` - I get a compile error ` Only the Kotlin standard library is allowed to use the 'kotlin' package` when I run a gradle kotlin application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM