Android.mk遇到user tag detected on new module - user tags are only supported on legacy modules

本文记录了一次在编译Android程序时遇到的错误,并详细描述了解决过程。问题出现在未正确设置LOCAL_MODULE_TAGS变量和变量赋值顺序不当。通过调整变量顺序解决了编译问题。

今天阳历生日,明天光棍节。继续光着吧。

前几天,编译Android程序时,出现了类似下面的一个错误。


build/core/base_rules.mk:74: *** Module name: xxxtest
build/core/base_rules.mk:75: *** Makefile location: packages/xxx/xxxtest
build/core/base_rules.mk:76: * 
build/core/base_rules.mk:77: * Each module must use a LOCAL_MODULE_TAGS in its
build/core/base_rules.mk:78: * Android.mk. Possible tags declared by a module:
build/core/base_rules.mk:79: * 
build/core/base_rules.mk:80: *     optional, debug, eng, tests, samples
build/core/base_rules.mk:81: * 
build/core/base_rules.mk:82: * If the module is expected to be in all builds
build/core/base_rules.mk:83: * of a product, then it should use the
build/core/base_rules.mk:84: * "optional" tag: 
build/core/base_rules.mk:85: * 
build/core/base_rules.mk:86: *    Add "LOCAL_MODULE_TAGS := optional" in the
build/core/base_rules.mk:87: *    Android.mk for the affected module, and add
build/core/base_rules.mk:88: *    the LOCAL_MODULE value for that component
build/core/base_rules.mk:89: *    into the PRODUCT_PACKAGES section of product
build/core/base_rules.mk:90: *    makefile(s) where it's necessary, if
build/core/base_rules.mk:91: *    appropriate.
build/core/base_rules.mk:92: * 
build/core/base_rules.mk:93: * If the component should be in EVERY build of ALL
build/core/base_rules.mk:94: * products, then add its LOCAL_MODULE value to the
build/core/base_rules.mk:95: * PRODUCT_PACKAGES section of
build/core/base_rules.mk:96: * build/target/product/core.mk
build/core/base_rules.mk:97: * 
build/core/base_rules.mk:98: *** user tag detected on new module - user tags are only supported on legacy modules.  Stop.

看这段解释,也上网搜答案,都说要把写上LOCAL_MODULE_TAGS := optional这么一行。但是明明我写了啊?看来不是这个问题。

后来才发现,原来是我Android.mk里,变量赋值的顺序的问题。 

本来在LOCAL_MODULE := xxxtest和include $(BUILD_EXECUTABLE)之间,我还给了好几个变量赋了值,有一个还是前面赋了一段,在这两者之间又赋了一段。我试着将LOCAL_MODULE := test_exe和include $(BUILD_EXECUTABLE)放到最后。问题突然就解决了。

因为太忙,也没去看看到底是什么问题。就去忙别的了。

如果谁遇到这问题,看是不是这个问题,咱们再探讨。


> Task :app:checkDebugDuplicateClasses FAILED AGPBI: {"kind":"warning","text":"Your project has set `android.useAndroidX=true`, but configuration `debugRuntimeClasspath` still contains legacy support libraries, which may cause runtime issues.\nThis behavior will not be allowed in Android Gradle plugin 8.0.\nPlease use only AndroidX dependencies or set `android.enableJetifier=true` in the `gradle.properties` file to migrate your project to AndroidX (see https://developer.android.com/jetpack/androidx/migrate for more info).\nThe following legacy support libraries are detected:\ndebugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02\ndebugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-compat:28.0.0-rc02\ndebugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-media-compat:28.0.0-rc02 -> com.android.support:support-annotations:28.0.0-rc02\ndebugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-compat:28.0.0-rc02 -> com.android.support:collections:28.0.0-rc02\ndebugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-compat:28.0.0-rc02 -> android.arch.lifecycle:runtime:1.1.1\ndebugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-compat:28.0.0-rc02 -> android.arch.lifecycle:runtime:1.1.1 -> android.arch.lifecycle:common:1.1.1\ndebugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-compat:28.0.0-rc02 -> android.arch.lifecycle:runtime:1.1.1 -> android.arch.core:common:1.1.1\ndebugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-media-compat:28.0.0-rc02 -> com.android.support:versionedparcelable:28.0.0-rc02\ndebugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-media-compat:28.0.0-rc02\ndebugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-core-utils:28.0.0-rc02\ndebugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-core-utils:28.0.0-rc02 -> com.android.support:documentfile:28.0.0-rc02\ndebugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-fragment:28.0.0-rc02 -> com.android.support:loader:28.0.0-rc02\ndebugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-fragment:28.0.0-rc02 -> com.android.support:loader:28.0.0-rc02 -> android.arch.lifecycle:livedata-core:1.1.1\ndebugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-fragment:28.0.0-rc02 -> com.android.support:loader:28.0.0-rc02 -> android.arch.lifecycle:livedata-core:1.1.1 -> android.arch.core:runtime:1.1.1\ndebugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-fragment:28.0.0-rc02 -> android.arch.lifecycle:viewmodel:1.1.1\ndebugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-core-utils:28.0.0-rc02 -> com.android.support:localbroadcastmanager:28.0.0-rc02\ndebugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-core-utils:28.0.0-rc02 -> com.android.support:print:28.0.0-rc02\ndebugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-core-ui:28.0.0-rc02\ndebugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-core-ui:28.0.0-rc02 -> com.android.support:customview:28.0.0-rc02\ndebugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-core-ui:28.0.0-rc02 -> com.android.support:viewpager:28.0.0-rc02\ndebugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-core-ui:28.0.0-rc02 -> com.android.support:coordinatorlayout:28.0.0-rc02\ndebugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-core-ui:28.0.0-rc02 -> com.android.support:drawerlayout:28.0.0-rc02\ndebugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-core-ui:28.0.0-rc02 -> com.android.support:slidingpanelayout:28.0.0-rc02\ndebugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-core-ui:28.0.0-rc02 -> com.android.support:interpolator:28.0.0-rc02\ndebugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-core-ui:28.0.0-rc02 -> com.android.support:swiperefreshlayout:28.0.0-rc02\ndebugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-core-ui:28.0.0-rc02 -> com.android.support:asynclayoutinflater:28.0.0-rc02\ndebugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-core-ui:28.0.0-rc02 -> com.android.support:cursoradapter:28.0.0-rc02\ndebugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-fragment:28.0.0-rc02","sources":[{}]} Your project has set `android.useAndroidX=true`, but configuration `debugRuntimeClasspath` still contains legacy support libraries, which may cause runtime issues. This behavior will not be allowed in Android Gradle plugin 8.0. Please use only AndroidX dependencies or set `android.enableJetifier=true` in the `gradle.properties` file to migrate your project to AndroidX (see https://developer.android.com/jetpack/androidx/migrate for more info). The following legacy support libraries are detected: debugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 debugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-compat:28.0.0-rc02 debugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-media-compat:28.0.0-rc02 -> com.android.support:support-annotations:28.0.0-rc02 debugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-compat:28.0.0-rc02 -> com.android.support:collections:28.0.0-rc02 debugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-compat:28.0.0-rc02 -> android.arch.lifecycle:runtime:1.1.1 debugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-compat:28.0.0-rc02 -> android.arch.lifecycle:runtime:1.1.1 -> android.arch.lifecycle:common:1.1.1 debugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-compat:28.0.0-rc02 -> android.arch.lifecycle:runtime:1.1.1 -> android.arch.core:common:1.1.1 debugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-media-compat:28.0.0-rc02 -> com.android.support:versionedparcelable:28.0.0-rc02 debugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-media-compat:28.0.0-rc02 debugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-core-utils:28.0.0-rc02 debugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-core-utils:28.0.0-rc02 -> com.android.support:documentfile:28.0.0-rc02 debugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-fragment:28.0.0-rc02 -> com.android.support:loader:28.0.0-rc02 debugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-fragment:28.0.0-rc02 -> com.android.support:loader:28.0.0-rc02 -> android.arch.lifecycle:livedata-core:1.1.1 debugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-fragment:28.0.0-rc02 -> com.android.support:loader:28.0.0-rc02 -> android.arch.lifecycle:livedata-core:1.1.1 -> android.arch.core:runtime:1.1.1 debugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-fragment:28.0.0-rc02 -> android.arch.lifecycle:viewmodel:1.1.1 debugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-core-utils:28.0.0-rc02 -> com.android.support:localbroadcastmanager:28.0.0-rc02 debugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-core-utils:28.0.0-rc02 -> com.android.support:print:28.0.0-rc02 debugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-core-ui:28.0.0-rc02 debugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-core-ui:28.0.0-rc02 -> com.android.support:customview:28.0.0-rc02 debugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-core-ui:28.0.0-rc02 -> com.android.support:viewpager:28.0.0-rc02 debugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-core-ui:28.0.0-rc02 -> com.android.support:coordinatorlayout:28.0.0-rc02 debugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-core-ui:28.0.0-rc02 -> com.android.support:drawerlayout:28.0.0-rc02 debugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-core-ui:28.0.0-rc02 -> com.android.support:slidingpanelayout:28.0.0-rc02 debugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-core-ui:28.0.0-rc02 -> com.android.support:interpolator:28.0.0-rc02 debugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-core-ui:28.0.0-rc02 -> com.android.support:swiperefreshlayout:28.0.0-rc02 debugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-core-ui:28.0.0-rc02 -> com.android.support:asynclayoutinflater:28.0.0-rc02 debugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-core-ui:28.0.0-rc02 -> com.android.support:cursoradapter:28.0.0-rc02 debugRuntimeClasspath -> com.android.support:support-v4:28.0.0-rc02 -> com.android.support:support-fragment:28.0.0-rc02 Execution failed for task ':app:checkDebugDuplicateClasses'. > A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable > Duplicate class android.support.v4.app.INotificationSideChannel found in modules core-1.3.2-runtime (androidx.core:core:1.3.2) and support-compat-28.0.0-rc02-runtime (com.android.support:support-compat:28.0.0-rc02) Duplicate class android.support.v4.app.INotificationSideChannel$Stub found in modules core-1.3.2-runtime (androidx.core:core:1.3.2) and support-compat-28.0.0-rc02-runtime (com.android.support:support-compat:28.0.0-rc02) Duplicate class android.support.v4.app.INotificationSideChannel$Stub$Proxy found in modules core-1.3.2-runtime (androidx.core:core:1.3.2) and support-compat-28.0.0-rc02-runtime (com.android.support:support-compat:28.0.0-rc02) Duplicate class android.support.v4.graphics.drawable.IconCompatParcelizer found in modules core-1.3.2-runtime (androidx.core:core:1.3.2) and support-compat-28.0.0-rc02-runtime (com.android.support:support-compat:28.0.0-rc02) Duplicate class android.support.v4.os.IResultReceiver found in modules core-1.3.2-runtime (androidx.core:core:1.3.2) and support-compat-28.0.0-rc02-runtime (com.android.support:support-compat:28.0.0-rc02) Duplicate class android.support.v4.os.IResultReceiver$Stub found in modules core-1.3.2-runtime (androidx.core:core:1.3.2) and support-compat-28.0.0-rc02-runtime (com.android.support:support-compat:28.0.0-rc02) Duplicate class android.support.v4.os.IResultReceiver$Stub$Proxy found in modules core-1.3.2-runtime (androidx.core:core:1.3.2) and support-compat-28.0.0-rc02-runtime (com.android.support:support-compat:28.0.0-rc02) Duplicate class android.support.v4.os.ResultReceiver found in modules core-1.3.2-runtime (androidx.core:core:1.3.2) and support-compat-28.0.0-rc02-runtime (com.android.support:support-compat:28.0.0-rc02) Duplicate class android.support.v4.os.ResultReceiver$1 found in modules core-1.3.2-runtime (androidx.core:core:1.3.2) and support-compat-28.0.0-rc02-runtime (com.android.support:support-compat:28.0.0-rc02) Duplicate class android.support.v4.os.ResultReceiver$MyResultReceiver found in modules core-1.3.2-runtime (androidx.core:core:1.3.2) and support-compat-28.0.0-rc02-runtime (com.android.support:support-compat:28.0.0-rc02) Duplicate class android.support.v4.os.ResultReceiver$MyRunnable found in modules core-1.3.2-runtime (androidx.core:core:1.3.2) and support-compat-28.0.0-rc02-runtime (com.android.support:support-compat:28.0.0-rc02) Duplicate class androidx.core.graphics.drawable.IconCompatParcelizer found in modules core-1.3.2-runtime (androidx.core:core:1.3.2) and support-compat-28.0.0-rc02-runtime (com.android.support:support-compat:28.0.0-rc02) Duplicate class androidx.core.internal.package-info found in modules core-1.3.2-runtime (androidx.core:core:1.3.2) and support-compat-28.0.0-rc02-runtime (com.android.support:support-compat:28.0.0-rc02) Duplicate class androidx.versionedparcelable.CustomVersionedParcelable found in modules versionedparcelable-1.1.0-runtime (androidx.versionedparcelable:versionedparcelable:1.1.0) and versionedparcelable-28.0.0-rc02-runtime (com.android.support:versionedparcelable:28.0.0-rc02) Duplicate class androidx.versionedparcelable.NonParcelField found in modules versionedparcelable-1.1.0-runtime (androidx.versionedparcelable:versionedparcelable:1.1.0) and versionedparcelable-28.0.0-rc02-runtime (com.android.support:versionedparcelable:28.0.0-rc02) Duplicate class androidx.versionedparcelable.ParcelField found in modules versionedparcelable-1.1.0-runtime (androidx.versionedparcelable:versionedparcelable:1.1.0) and versionedparcelable-28.0.0-rc02-runtime (com.android.support:versionedparcelable:28.0.0-rc02) Duplicate class androidx.versionedparcelable.ParcelImpl found in modules versionedparcelable-1.1.0-runtime (androidx.versionedparcelable:versionedparcelable:1.1.0) and versionedparcelable-28.0.0-rc02-runtime (com.android.support:versionedparcelable:28.0.0-rc02) Duplicate class androidx.versionedparcelable.ParcelImpl$1 found in modules versionedparcelable-1.1.0-runtime (androidx.versionedparcelable:versionedparcelable:1.1.0) and versionedparcelable-28.0.0-rc02-runtime (com.android.support:versionedparcelable:28.0.0-rc02) Duplicate class androidx.versionedparcelable.ParcelUtils found in modules versionedparcelable-1.1.0-runtime (androidx.versionedparcelable:versionedparcelable:1.1.0) and versionedparcelable-28.0.0-rc02-runtime (com.android.support:versionedparcelable:28.0.0-rc02) Duplicate class androidx.versionedparcelable.VersionedParcel found in modules versionedparcelable-1.1.0-runtime (androidx.versionedparcelable:versionedparcelable:1.1.0) and versionedparcelable-28.0.0-rc02-runtime (com.android.support:versionedparcelable:28.0.0-rc02) Duplicate class androidx.versionedparcelable.VersionedParcel$1 found in modules versionedparcelable-1.1.0-runtime (androidx.versionedparcelable:versionedparcelable:1.1.0) and versionedparcelable-28.0.0-rc02-runtime (com.android.support:versionedparcelable:28.0.0-rc02) Duplicate class androidx.versionedparcelable.VersionedParcel$ParcelException found in modules versionedparcelable-1.1.0-runtime (androidx.versionedparcelable:versionedparcelable:1.1.0) and versionedparcelable-28.0.0-rc02-runtime (com.android.support:versionedparcelable:28.0.0-rc02) Duplicate class androidx.versionedparcelable.VersionedParcelParcel found in modules versionedparcelable-1.1.0-runtime (androidx.versionedparcelable:versionedparcelable:1.1.0) and versionedparcelable-28.0.0-rc02-runtime (com.android.support:versionedparcelable:28.0.0-rc02) Duplicate class androidx.versionedparcelable.VersionedParcelStream found in modules versionedparcelable-1.1.0-runtime (androidx.versionedparcelable:versionedparcelable:1.1.0) and versionedparcelable-28.0.0-rc02-runtime (com.android.support:versionedparcelable:28.0.0-rc02) Duplicate class androidx.versionedparcelable.VersionedParcelStream$FieldBuffer found in modules versionedparcelable-1.1.0-runtime (androidx.versionedparcelable:versionedparcelable:1.1.0) and versionedparcelable-28.0.0-rc02-runtime (com.android.support:versionedparcelable:28.0.0-rc02) Duplicate class androidx.versionedparcelable.VersionedParcelable found in modules versionedparcelable-1.1.0-runtime (androidx.versionedparcelable:versionedparcelable:1.1.0) and versionedparcelable-28.0.0-rc02-runtime (com.android.support:versionedparcelable:28.0.0-rc02) Duplicate class androidx.versionedparcelable.VersionedParcelize found in modules versionedparcelable-1.1.0-runtime (androidx.versionedparcelable:versionedparcelable:1.1.0) and versionedparcelable-28.0.0-rc02-runtime (com.android.support:versionedparcelable:28.0.0-rc02) Go to the documentation to learn how to Fix dependency resolution errors. * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. Explain with AI 怎么解决上面的问题
最新发布
12-24
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值