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

标签 android android-studio aapt

我已经查看了此问题的先前答案,但仍然出现 AAPT 错误。

error: attribute 'package' in <manifest> tag is not a valid Android package name: 'org.emarti202.gcu.mpd-cw-em'.
尽管我在 build.gradle 中的 applicationId 和 AndroidManifest.xml 中的包名称匹配,但它们仍然不起作用。有解决方案吗?抱歉,这是一个简单的解决方法,我似乎无法理解它。
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="org.emarti202.gcu.mpd-cw-em">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="MPD-CW-EM"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

        <meta-data android:name="com.google.android.geo.API_KEY"
            android:value="@string/map_key" />

        <activity android:name="org.emarti202.gcu.mpd-cw-em.MainActivity2"></activity>
        <activity android:name="org.emarti202.gcu.mpd-cw-em.MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>
构建.gradle
apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "org.emarti202.gcu.mpd-cw-em"
        minSdkVersion 23
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}


dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    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.android.support:design:28.0.0'
    implementation 'com.google.android.gms:play-services:+'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    // implementation 'com.alespero:expandable-cardview:0.6'
    // implementation 'com.google.android.gms:play-services-maps:16.1.0'
}

最佳答案

不幸的是,连字符“-”在包名中是 Not Acceptable 。
请引用此文档。
https://developer.android.com/guide/topics/manifest/manifest-element.html#package

A full Java-language-style package name for the Android app. The name may contain uppercase or lowercase letters ('A' through 'Z'), numbers, and underscores ('_'). However, individual package name parts may only start with letters. While building your app into the an application package (APK), the build system uses the package attribute for two things


请将您的软件包名称更改为“org.emarti202.gcu.mpd_cw_em”。

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

相关文章:

android - 如何从 fragment 中获取 EditText

android - 即使在 list 中添加权限后仍显示 `Missing permission`

java - Android Studio Kotlin 自动补全重复建议

android - 如何以编程方式查找任何 Android 设备的 CPU 负载

android - "aapt dump badging"希望 minSdkVersion 是一个字符串,但 "adb install"需要它作为一个整数

android - 在android中使用GPG解压缩文件

android - 如何对kotlin中的对象列表进行排序?

linux - 在 shell 脚本中运行 aapt 以转储目录下所有 apk 文件的权限?

android - 为什么 Android aapt 去掉 assets 的 .gz 文件扩展名?

android - 如何使用 jobb 工具创建 .obb 文件作为主 apk 扩展文件?