gpt4 book ai didi

android - 错误 : attribute 'package' in tag is not a valid Android package name

转载 作者:行者123 更新时间:2023-12-04 23:36:00 35 4
gpt4 key购买 nike

我正在尝试编写一个曾经构建过的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'.

我最初以 android-kotlin 教程作为基础,因为我想熟悉 kotlin 和 android,如果这可能相关的话。此外,“合并 list ”有 package = dndtools而不是 com.dndtools.android.dndtools列出,也不确定是否相关。

AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.dndtools.android.dndtools">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" //dndtools
...

构建.gradle
apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'
def androidSupportVersion = '28.0.0'

android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
applicationId "dndtools"
minSdkVersion 21
targetSdkVersion 28
...

我已经搜索了互联网,其他出现此错误的人通常在他们的 applicationId 的开头或结尾都有一个下划线(这里不是这种情况),所以我真的很茫然

最佳答案

更改applicationId "dndtools"applicationId "com.dndtools.android.dndtools" .
applicationId在您的 build.gradle 文件中是用作真正包的内容,这就是为什么您也可以在合并的 manfiest 中看到它的原因。更新它以匹配您在 Android Manfiest 中的那个,它应该可以正常工作。

至于为什么它是一个无效的包 - 它需要至少有一个点才能安装在 Android 上。

关于android - 错误 : attribute 'package' in <manifest> tag is not a valid Android package name,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55599876/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com