[英]Error: attribute 'package' in <manifest> tag is not a valid Android package name
我正在尝试编写一个曾经构建过的android应用程序。现在,每次构建时,都会出现以下错误:
Caused by: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
C:\Users\Jay\AndroidStudioProjects\DndTools-App\app\build\intermediates\merged_manifests\debug\AndroidManifest.xml:2: AAPT:
error: attribute 'package' in <manifest> tag is not a valid Android package name: 'dndtools'.
Change applicationId "dndtools"
to applicationId "com.dndtools.android.dndtools"
.将applicationId "dndtools"
更改为applicationId "com.dndtools.android.dndtools"
。
applicationId
in your build.gradle file is what is used as the real package, that's why you can see it in the merged manfiest as well. applicationId
在你的build.gradle文件是干什么用的真正的包,这就是为什么你可以看到它在合并manfiest为好。 Update it to match the one you have in your Android Manfiest and it should work fine.更新它以匹配您在 Android Manfiest 中的那个,它应该可以正常工作。
As for why it's an invalid package - it needs to have at least one dot in it to be installable on Android.至于为什么它是一个无效的包 - 它需要至少有一个点才能在 Android 上安装。
In my Case, I have updated the Android studio to version 3.5.3 , and while project setup, by mistake I have added applicationIdSuffix = kotlin_version , so this is what causing the problem.在我的案例中,我已将 Android studio更新到版本 3.5.3 ,并且在项目设置时,我错误地添加了applicationIdSuffix = kotlin_version ,所以这就是导致问题的原因。
So simply removing this line helped me to fix this issue.因此,只需删除此行即可帮助我解决此问题。
in my case, i build app use default config就我而言,我构建应用程序使用默认配置
compileSdkVersion 30
defaultConfig {
applicationId "com.webview.app"
minSdkVersion 23
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
applicationIdSuffix kotlin_version
}
when i add productFlavors当我添加 productFlavors
flavorDimensions "default"
productFlavors {
test01{
dimension "default"
applicationIdSuffix ".test"
versionNameSuffix "-test00"
}
test01{
dimension "default"
applicationIdSuffix ".test"
versionNameSuffix "-test01"
}
test01{
dimension "default"
applicationIdSuffix ".test"
versionNameSuffix "-test02"
}
}
then i'm runing my app, i got this message然后我正在运行我的应用程序,我收到了这条消息
tag is not a valid Android package name: 'com.webview.app.1.4.21.jb'
i think the problem shoud be number and point(.) can not be package name, so i delete code我认为问题应该是数字和点(。)不能是包名,所以我删除了代码
applicationIdSuffix kotlin_version
it's work for me, because kotlin_version value it's ext.kotlin_version = "1.4.21"
, when my appid contain number and point(.) it cannot working.它对我有用,因为 kotlin_version 值是ext.kotlin_version = "1.4.21"
,当我的 appid 包含 number 和 point(.) 时,它无法工作。 in android the appid(pacakege name) should be like this 'come.domain.project' it is reverse domain name.在android中,appid(pacakege name)应该是这样的'come.domain.project',它是反向域名。
My problem was with uncorrect naming of the package id.我的问题是包 ID 的命名不正确。 I put something like com.example.3d
.我放了类似com.example.3d
东西。 You can't start with the number like 3d
.你不能从像3d
这样的数字开始。
A full Java-language-style package name for the Android app. Android 应用程序的完整 Java 语言样式的包名称。 The name may contain uppercase or lowercase letters ('A' through 'Z'), numbers, and underscores ('_').名称可以包含大写或小写字母(“A”到“Z”)、数字和下划线(“_”)。 However, individual package name parts may only start with letters但是,个别包名部分只能以字母开头
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.