android - Gluon Mobile:使用 ExoPlayer
问题描述
我正在使用 GluonMobile 开发一个 android 应用程序。对于一个功能,我需要一个 ExoPlayer。所以我包含了依赖项 com.google.android.exoplayer:exoplayer:+ 。似乎依赖是一个 aar 文件,而 InteliJ 找不到任何 ExoPlayers 类。这是我的构建脚本:
buildscript {
repositories {
mavenCentral()
jcenter()
google()
maven {
url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
}
}
dependencies {
classpath 'org.javafxports:jfxmobile-plugin:+'
classpath 'com.github.jengelman.gradle.plugins:shadow:+'
}
}
apply plugin: 'org.javafxports.jfxmobile'
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'java'
apply plugin: 'idea'
idea {
module {
downloadJavadoc = true
downloadSources = true
}
}
repositories {
mavenCentral()
jcenter()
google()
maven {
url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
}
maven {
url uri('libs')
}
}
mainClassName = '[...].main.Main'
version = '2.0_Alpha'
dependencies {
compile "com.gluonhq:charm:+"
compile "com.gluonhq:glisten-afterburner:+"
compile "com.google.apis:google-api-services-youtube:+"
compile "com.google.api-client:google-api-client-java6:+"
compile "com.google.oauth-client:google-oauth-client-jetty:+"
compile "com.google.code.gson:gson:+"
compileOnly 'lib.idea:annotations:0'
androidImplementation "org.javafxports:jfxdvk:+"
androidImplementation 'com.google.android.exoplayer:exoplayer:+@aar'
}
jfxmobile {
downConfig {
version = '+'
// Do not edit the line below. Use Gluon Mobile Settings in your project context menu instead
//noinspection GroovyAssignabilityCheck
plugins 'browser', 'display', 'lifecycle', 'statusbar', 'storage'
}
android {
manifest = 'src/android/AndroidManifest.xml'
//androidSdk = "${ANDROID_HOME}"
compileSdkVersion = 28
targetSdkVersion = 22
minSdkVersion = 16
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
}
}
task installApk{
group = "gluon mobile for android"
doLast{
exec {
workingDir "${ANDROID_HOME}\\platform-tools"
commandLine "${workingDir}\\adb.exe", "install", "${buildDir}/javafxports/android/YouJavaTubeApp.apk"
}
}
}
我已经发现了一些关于 explodeAarDependencies(...) 的东西,但它没有用。所以有人知道如何将(任何)aar 依赖项包含到我的 GluonMobile 项目中。
感谢您的帮助。
解决方案
你在正确的轨道上explodeAarDependencies
,这是 jfxmobile 插件用来将 .aar 依赖项解压到 .jar 和其他资源中的任务。
您可以在此处找到有关该任务的信息。
如何使用它:
在您的 build.gradle 文件中,包含依赖项:
dependencies {
...
androidCompile 'com.google.android.exoplayer:exoplayer:2.9.0'
}
注意1:不要使用
@aar
注意 2:jfxmobile 插件使用一些已定义的配置,例如
androidCompile
代替androidImplementation
.注意 3:我宁愿使用给定的版本,而不是
+
.
并在文件末尾添加任务:
project.afterEvaluate {
explodeAarDependencies(project.configurations.androidCompile)
}
就是这样。
保存并应用/同步/重新加载构建,您应该会看到exoplayer
Android 编译依赖项中包含一堆传递依赖项,包括 .aar 和 .jar 文件。
推荐阅读
- c# - 如何在 Wpf 中绑定图像大小和画布
- node.js - 尝试使用 Angular 作为我的路由器,但出现 NodeJS Server 'Cannot GET /[something]' 错误
- python - 如何将 Pandas 数据框保存到配置单元表?
- javascript - 在数字范围之间过滤以隐藏表格行(HTML,javascript)
- gradle - gradle build :使用变量作为工件名称
- java - 如何修复无法解析“CELL_TYPE_BLANK”?
- javascript - react-native 如何将功能组件更改为类组件
- c# - LdapDistinguishedNameEncode 如何与 C# DirectoryServices 库一起使用?
- javascript - 在没有 JavaScript SDK 的页面上创建 Facebook“Like”按钮
- react-native - TypeError : undefined is not an object (evaluating 'style.width')