【问题标题】:jfxmobile plugin doesn't add android.jar and javafxports jarjfxmobile 插件不添加 android.jar 和 javafxports jar
【发布时间】:2016-05-14 16:24:23
【问题描述】:

我在两个地方从事一个项目,现在我在家工作,我从 Git 中提取了这个项目。

在工作中,我在 IntelliJ 的外部库中看到 android.jar 和 jfx.jar(不知道确切名称),并且这些类可用。但是在家里,jar 是不可见的,因此无法识别 android 类和 JFXActivity 类。

我现在不知道为什么 Gradle 不加载它,build.gradle 是一样的。

build.gradle:

buildscript {
    repositories {
        jcenter()
        maven {
            url 'http://xxxx.com:8080/artifactory/plugins-release'
        }
    }
    dependencies {
        classpath 'org.javafxports:jfxmobile-plugin:1.0.8'
        classpath "org.jfrog.buildinfo:build-info-extractor-gradle:+"
    }
}

apply plugin: 'com.jfrog.artifactory'
apply plugin: 'org.javafxports.jfxmobile'

artifactory {
    contextUrl = "${artifactory_contextUrl}"
    publish {
        repository {
            repoKey = 'libs-release-local'
            maven = true
        }
    }
    resolve {
        repository {
            repoKey = 'libs-release'
            maven = true
        }
    }
}

repositories {
    jcenter()
    mavenLocal()
    maven {
        url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
    }
}

mainClassName = 'com.xxxx.scan.application.gluon.MainApplication'

dependencies {
    compile 'com.gluonhq:charm:2.1.1'
    compile 'com.airhacks:afterburner.mfx:1.6.2'
    androidRuntime 'com.gluonhq:charm-android:2.1.1'
    iosRuntime 'com.gluonhq:charm-ios:2.1.1'
    desktopRuntime 'com.gluonhq:charm-desktop:2.1.1'

    compile(group: 'com.essers.pxl2016', name: 'scan-server-definition', version: '0.0.1-SNAPSHOT')
    compile(group: 'com.essers.pxl2016', name: 'client', version: '1.0-SNAPSHOT')
    compile(group: 'com.essers.pxl2016', name: 'configuration', version: '1.0-SNAPSHOT')
    compile('com.google.code.gson:gson:2.2.4')
    testCompile "junit:junit:4.12"
}

task print << {
    println("$System.env.ANDROID_HOME")
}

jfxmobile {
    android {
        androidSdk = "$System.env.ANDROID_HOME"
        manifest = 'src/android/AndroidManifest.xml'
        compileSdkVersion = 21
    }
    ios {
        infoPList = file('src/ios/Default-Info.plist')
        forceLinkClasses = [
                'com.xxxx.scan.application.gluon.**.*',
                'com.gluonhq.**.*',
                'io.datafx.**.*',
                'javax.annotations.**.*',
                'javax.inject.**.*',
                'javax.json.**.*',
                'org.glassfish.json.**.*'
        ]
    }
}

test {
    exclude 'com/xxxx/scan/application/gluon/**'
}

【问题讨论】:

  • 你定义了ANDROID_HOME吗?你下载了Android SDK吗?您需要在每台机器上执行此操作。当你运行gradlew --info android 时,你得到了什么错误?
  • 嗨 José,我在系统环境变量中定义了 ANDROID_HOME,我知道 Gradle 可以找到它们,因为我使用 println("$System.env.ANDROID_HOME") 执行了一个任务。 gradlew --info android 显示没有错误并以构建成功结束,它表明 $System.env.ANDROID_HOME 已解决,我看到它添加了 jfxrt.jar。 AndroidInstall 也可以工作,并且该 apk 可以与包含的 Android 特定功能一起工作。唯一不起作用的是 IntelliJ 不会将 android.jar 和 jfxdvk.jar 添加到外部库中。我想我可以从 .gradle 缓存中手动添加依赖项..
  • 如果您构建并运行应用程序,肯定这些依赖项就在那里。在 IntelliJ 中,也许您需要单击 Gradle 面板上的刷新按钮来更新依赖项列表。在 External Libraries 下,您应该会看到:android.jar、jdk1.8、charm 依赖项、javax-json、jfxdvk、afterburner、robovm 依赖项和您自己的。
  • 我尝试了刷新按钮,但没有成功。 Charm、afterburner 和 1.8 在外部库下可见。 Android.jar、jfxdvk、robovm、javax-json 不是。我尝试了诸如“使缓存无效并重新启动”之类的方法,甚至删除了整个 .gradle 目录。 Gradle 然后如上所述导入库。由于某种原因,Gradle 或 IntelliJ 似乎对脚本的 jfxmobile 部分没有反应。
  • 试试这个:确保你已经为 IntelliJ 安装了 Gluon 插件,创建一个新项目,Gluon Mobile,Single View 项目。检查它是否有效并显示这些依赖项

标签: mobile gradle javafxports gluon


【解决方案1】:

您在这一行中引用了 Android SDK:

androidSdk = "$System.env.ANDROID_HOME"

确保可以在该位置找到SDK,或根据Gluon Documentation引用:

你必须让 jfxmobile 插件知道在哪里寻找 Android SDK安装目录使用以下方式之一:

  • 在 build.gradle 中 jfxmobile.android 下定义的 androidSdk 属性

  • 一个名为 ANDROID_HOME 的 gradle 属性:在 ~/.gradle/gradle.properties 中定义或通过将 -PANDROID_HOME 传递给 毕业典礼 构建

  • 一个名为 ANDROID_HOME 的系统环境变量

jfxmobile 插件将首先尝试查看 androidSdk 属性是否具有 被设置。如果没有,它将寻找 ANDROID_HOME gradle 属性 最后求助于 ANDROID_HOME 系统环境变量。

【讨论】:

  • 我验证了 Gradle 可以通过执行 println("$System.env.ANDROID_HOME") 的任务找到“$System.env.ANDROID_HOME”。输出是正确的。
【解决方案2】:

我安装了 IntelliJ 2016.1.2 社区版,我可以确认所有依赖项都加载良好,包括 android.jar、jfxdvk.jar 和 robovm jar。由于某种原因,它在 IntelliJ 15.0.6 终极版上失败了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-07
    • 2019-07-02
    • 2019-12-04
    • 1970-01-01
    相关资源
    最近更新 更多