- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在从 google gradle 插件 3.1.4 更新到现在最新的 3.2.1 后,我试图让我的应用程序重新构建,我认为我首先让我的 instantapp 工作的方法可能有问题,所以我发布这个问题是为了放弃或确认这一点,在这种情况下要求采用不同的方法。
简而言之,我的应用程序是一个在 Assets 文件夹中有很多图形的游戏。为了使 instantapp 符合 Google Play 施加的 10 MB 限制,我不得不删除一些我在 instant 版本中不需要的 Assets 以及分辨率更高的 Assets ,同时保留其余 Assets 。此外,instantapp 的代码与安装的代码略有不同,因此我重写了其中的一些方法和类。
最小的 com.android.instantapp 模块似乎不能包含 Assets 和代码,所以我创建了一个中间功能模块来代替它们。
因此,经过大量努力(主要是使用 firebase 和 com.google.gms.google-services 插件),我想出了这种方法,该方法最终适用于 gradle 插件的 3.1.4 版 (com.android .tools.build:gradle:3.1.4)
唯一奇怪的是,我必须将标志“baseFeature”同时设置为 android_instant_feature 和 android_common 功能模块。但它奏效了,我终于可以发布我的游戏的即时版本,同时安装版本也继续构建得很好。
现在,只要我更新到 google gradle 插件的 3.2.1 版,即使我不做任何其他更改,问题也开始了。我在尝试构建项目时遇到了很多此类错误:
Unable to find a matching variant of project :android_common:
- Variant 'debugApiElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
- Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Metadata' and found incompatible value 'Aar'.
- Found org.gradle.usage 'java-api' but wasn't required.
- Variant 'debugFeatureApiElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
- Found com.android.build.api.attributes.VariantAttr 'debugFeature' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Metadata' and found incompatible value 'Feature'.
- Found org.gradle.usage 'java-api' but wasn't required.
- Variant 'debugFeatureRuntimeElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
- Found com.android.build.api.attributes.VariantAttr 'debugFeature' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Metadata' and found incompatible value 'Feature'.
- Found org.gradle.usage 'java-runtime' but wasn't required.
- Variant 'debugRuntimeElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
- Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Metadata' and found incompatible value 'Aar'.
- Found org.gradle.usage 'java-runtime' but wasn't required.
- Variant 'releaseApiElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found incompatible value 'release'.
- Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Metadata' and found incompatible value 'Aar'.
- Found org.gradle.usage 'java-api' but wasn't required.
- Variant 'releaseFeatureApiElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found incompatible value 'release'.
- Found com.android.build.api.attributes.VariantAttr 'releaseFeature' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Metadata' and found incompatible value 'Feature'.
- Found org.gradle.usage 'java-api' but wasn't required.
- Variant 'releaseFeatureRuntimeElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found incompatible value 'release'.
- Found com.android.build.api.attributes.VariantAttr 'releaseFeature' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Metadata' and found incompatible value 'Feature'.
- Found org.gradle.usage 'java-runtime' but wasn't required.
- Variant 'releaseRuntimeElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found incompatible value 'release'.
- Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Metadata' and found incompatible value 'Aar'.
- Found org.gradle.usage 'java-runtime' but wasn't required.
在对 gradle 脚本进行一些调整后,包括从 android_instant_feature 模块中删除 baseFeature true 标志,我得到了一个更简短的错误,但我不能说我是否比以前更好。错误是这样的:
Expected configuration ':android_instant_feature:debugFeatureCompileClasspath' to contain exactly one file, however, it contains no files.
现在我被困在这里,不知道该做什么,也不知道下一步该去哪里,所以我想知道我的方法是否存在根本性的缺陷,因为我是在反复试验之后想出来的,然后我我不确定这是否合适,在这种情况下,我可以使用哪种其他方法来满足我的要求和来自 Google 的要求,无论它们是什么。
根据@TWL 的要求,这些是我的这些模块的 Gradle 文件。我已经用 com.myapp.id 替换了真实的应用程序 ID,其余的正是我所拥有的,包括很多我认为与此事无关的 libGDX 的东西,尽管我更愿意以准确性的名义将它留在那里:
android_common:
apply plugin: "com.android.feature"
configurations { natives }
android {
baseFeature true
compileSdkVersion 28
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
androidTest.setRoot('tests')
}
defaultConfig {
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
sourceSets {
all {
manifest.srcFile "AndroidManifest.xml"
}
}
multiDexEnabled true
}
buildTypes {
release {
setMinifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildToolsVersion '28.0.2'
lintOptions {
abortOnError false
}
dexOptions {
jumboMode true
}
}
dependencies {
application project(':android')
implementation project(':core')
api 'com.android.support:multidex:1.0.3'
implementation "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
implementation "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64"
implementation "com.android.billingclient:billing:$playBillingLibVersion"
implementation "com.google.firebase:firebase-core:16.0.3"
implementation "com.google.firebase:firebase-ads:15.0.1"
implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.guava:guava:24.0-android'
}
task copyAndroidNatives() {
file("libs/armeabi/").mkdirs();
file("libs/armeabi-v7a/").mkdirs();
file("libs/arm64-v8a/").mkdirs();
file("libs/x86_64/").mkdirs();
file("libs/x86/").mkdirs();
configurations.natives.files.each { jar ->
def outputDir = null
if (jar.name.endsWith("natives-arm64-v8a.jar")) outputDir = file("libs/arm64-v8a")
if (jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a")
if (jar.name.endsWith("natives-armeabi.jar")) outputDir = file("libs/armeabi")
if (jar.name.endsWith("natives-x86_64.jar")) outputDir = file("libs/x86_64")
if (jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86")
if (outputDir != null) {
copy {
from zipTree(jar)
into outputDir
include "*.so"
}
}
}
}
android_instant_feature:
apply plugin: "com.android.feature"
android {
// baseFeature true
buildToolsVersion "28.0.2"
compileSdkVersion 28
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ["${project(':android_common').projectDir}/res"]
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
}
defaultConfig {
versionCode 4031
versionName "4.1.2.1i"
minSdkVersion 16
targetSdkVersion 28
multiDexEnabled true
}
dexOptions {
jumboMode true
}
// Proguard configuration
buildTypes {
release {
//minifyEnabled true will turn proguard ON
// minifyEnabled true
//proguardFiles let you add your own proguard rules ('proguard-project.txt') in this case, as its already created by gdx-setup
// proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
}
debug {}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
productFlavors {
}
lintOptions {
abortOnError false
}
}
task run(type: Exec) {
def path
def localProperties = project.file("../local.properties")
if (localProperties.exists()) {
Properties properties = new Properties()
localProperties.withInputStream { instr ->
properties.load(instr)
}
def sdkDir = properties.getProperty('sdk.dir')
if (sdkDir) {
path = sdkDir
} else {
path = "$System.env.ANDROID_HOME"
}
} else {
path = "$System.env.ANDROID_HOME"
}
def adb = path + "/platform-tools/adb"
commandLine "$adb", 'shell', 'am', 'start', '-n', 'com.marzoa.ruletafree/com.marzoa.ruletafree.AndroidLauncher'
}
dependencies {
implementation project(":core")
feature project(":android_common")
api 'com.android.support:multidex:1.0.3'
implementation "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
implementation "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
implementation "com.google.firebase:firebase-core:16.0.3"
implementation 'com.google.android.gms:play-services-instantapps:16.0.0'
implementation fileTree(dir: 'libs', include: ['*.jar'])
}
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'
android_instant:
apply plugin: 'com.android.instantapp'
android {
defaultConfig {
applicationId "com.myapp.id"
minSdkVersion 16
targetSdkVersion 28
multiDexEnabled true
}
}
dependencies {
implementation project(":android_common")
implementation project(":android_instant_feature")
}
安卓:
apply plugin: "com.android.application"
apply plugin: 'io.fabric' // Needed by crashlytics. DO NOT REMOVE.
android {
buildToolsVersion "28.0.2"
compileSdkVersion 28
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ["${project(':android_common').projectDir}/res"]
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
androidTest.setRoot('tests')
}
defaultConfig {
applicationId "com.myapp.id"
versionCode 4032
versionName "4.1.2.1"
minSdkVersion 16
targetSdkVersion 28
multiDexEnabled true
}
dexOptions {
jumboMode true
}
// Proguard configuration
buildTypes {
release {
//minifyEnabled true will turn proguard ON
minifyEnabled true
//proguardFiles let you add your own proguard rules ('proguard-project.txt') in this case, as its already created by gdx-setup
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
productFlavors {
}
lintOptions {
abortOnError false
}
}
task importPuzzles(type: Exec) {
// TODO
}
task run(type: Exec) {
def path
def localProperties = project.file("../local.properties")
if (localProperties.exists()) {
Properties properties = new Properties()
localProperties.withInputStream { instr ->
properties.load(instr)
}
def sdkDir = properties.getProperty('sdk.dir')
if (sdkDir) {
path = sdkDir
} else {
path = "$System.env.ANDROID_HOME"
}
} else {
path = "$System.env.ANDROID_HOME"
}
def adb = path + "/platform-tools/adb"
commandLine "$adb", 'shell', 'am', 'start', '-n', 'com.marzoa.ruletafree/com.myapp.id.AndroidLauncher'
}
dependencies {
implementation project(":core")
implementation project(":android_common")
api 'com.android.support:multidex:1.0.3'
implementation "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
implementation "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
implementation "com.android.billingclient:billing:$playBillingLibVersion"
implementation "com.google.firebase:firebase-core:16.0.3"
implementation "com.google.firebase:firebase-ads:15.0.1"
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.5'
implementation fileTree(include: ['*.jar'], dir: 'libs')
}
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'
提前致谢!
最佳答案
感谢您提供 gradle 文件,看起来您的 gradle 依赖项混淆了。
持有 baseFeature true
的 com.android.feature
模块应该是其依赖项也持有 application project()
和 feature project()
。这是导致错误的主要原因:
Expected configuration ':___:debugFeatureCompileClasspath' to contain exactly one file, however, it contains no files.
因此,从您提供的内容来看,您的application project()
和feature project()
似乎是分开的。
要解决这个问题,您的“base”android_common
应该是:
application project(':android')
feature project(":android_instant_feature")
你的“非基本功能”android_instant_feature
应该是:
implementation project(':android_common)
这不会改变项目的整体结构。
com.android.application
将使用以下库进行编译:core
和 android_common
。com.android.instantapp
将与即时应用程序 apks 一起编译:android_common.apk
和 android_instant_feature.apk
。现在,为什么它之前与 2x baseFeature
一起工作?我不知道,它不应该...
曾经有一个页面@https://g.co/instantapps这解释了即时应用程序的结构,但您可以引用我之前涉及它的一篇文章以获得概述和引用链接:How can i access an activity from another feature module
旁注:我注意到您有一个实现项目(":core")
贯穿您的模块(减去instantapp)。如果那纯粹是一个像 com.android.library
这样的库,那么您不必那样设置它。实际上,您可以将它放在您的 base 中,如下所示:api project(":core")
并删除其他地方的所有其他引用。将其声明为 api
意味着任何同样实现该基础的模块也将暴露于此依赖项。 (尝试一下,根据您的核心
拥有的其他库,在极少数情况下会出现错误,但请尝试看看)。
关于java - Android 即时功能 : Is it something fundamentally flawed with this approach?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53160273/
Under the push parsing approach, a push parser generates synchronous events as a document is parsed,
我刚刚开发了一个 Android 应用程序(minSdkVersion 23/targetSdkVersion 29),可以连接到 BluetoothLE 设备以定期获取数据。 现在,在 MainAc
我现在编程了一段时间(初学者),递归函数对我来说是一个有点抽象的概念。我不会说我卡住了,程序运行良好,我只是想知道是否可以在代码中没有 pow 函数的情况下编写函数本身(但仍然完全按照问题的建议进行操
http://www.codechef.com/OCT14/problems/PRLADDU 这是当前的运行比赛。 我不想要它的答案,只是让我知道我的方法是否正确。 我遵循的方法是按交换方式添加人和恐
我是Python线程的新手,作为我写的第一个任务: from twitterHandler import Twitter_User from text_analyzer import text_ana
我不是 DBA,我不知道什么是最好的解决方案。我有两个表, Custumers Table CustomerId (primary key, identity) ... 和 Suppliers Tab
我对Spring和Apache Tika集成感兴趣。 这种方法是线程安全的吗? 我可以从不同的线程安全地调用detect()方法吗? 是否有任何Spring-Tika集成模式? 提前致谢。 最佳答案
这听起来可能是一个新手问题,但我是 iOS 开发新手。 我在我的项目中跟踪了代码,该项目启用了 ARC,但我在执行时遇到错误(访问错误),并且想了解问题的原因并解决它。 按下某些按钮后,将在 MTCl
自从 AsyncTask 自2009年在Cupcake(API 3,Android 1.5)中引入以来,它一直被Android团队一如既往地推广: “Painless threading” “an e
就目前情况而言,这个问题不太适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、民意调查或扩展讨论。如果您觉得这个问题可以改进并可能重新开放,visit
我一直在为这个 leetcode 问题绞尽脑汁。想知道是否有一种实用的方法可以解决这个问题。我能想到的就是使用可变对象(在 Scala 中)。 给定一个表示为数字链接列表的非负整数,该整数加一。 存储
我一直在为这个 leetcode 问题绞尽脑汁。想知道是否有一种实用的方法可以解决这个问题。我能想到的就是使用可变对象(在 Scala 中)。 给定一个表示为数字链接列表的非负整数,该整数加一。 存储
我正在考虑编写一个函数,该函数使用 calloc 创建一个数组来容纳文件中的数据(目前以字符形式)。据我了解,我的两个最明显的选择是读取所有字符以获得所需的总大小,使用 calloc 分配所需的空间,
很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visit the help center . 关闭 1
我必须准备一个包含很多字段(大约 100 个)的表单。我可以使用一个大的 HTML\PHP 文件,但为了提高可访问性和轻松访问字段,我宁愿使用选项卡菜单。原始表格(称为临床评估)在逻辑上可以分为 3
关闭。这个问题是opinion-based .它目前不接受答案。 想要改进这个问题? 更新问题,以便 editing this post 可以用事实和引用来回答它. 关闭 7 年前。 Improve
我想获取所有带有 编辑:如果您不想显式定义 for 循环和 if 语句,请尝试使用 .filter() 和 .match( ): var arr = ["cat", "apple", "window
我正在寻找一种 dojo 工具包方法来跨 iFrame 进行通信。与此处显示的 Julien Lecomte 的 CrossFrame 技术类似的东西 http://www.julienlecomte
问题 我想实现TransparencyChecker Interface,它将验证网络中的任何交易所是否都可以使用来自其他交易所的所有交易信息。 问:TransparencyChecker Infer
我有一个类 ClassA,它调用另一个类(DAO)来获取查询结果。在特定的业务场景下, ClassA 使用查询参数调用 DAO 大约 20,000 次。其中,ClassA 向 DAO 发送了大约 10
我是一名优秀的程序员,十分优秀!