首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >AAPT错误:<manifest>标记中的属性' package‘不是一个有效的Android包名

AAPT错误:<manifest>标记中的属性' package‘不是一个有效的Android包名
EN

Stack Overflow用户
提问于 2021-03-05 15:23:35
回答 1查看 1.4K关注 0票数 5

我已经看过以前这个问题的答案,但是AAPT错误仍然发生。

代码语言:javascript
运行
复制
error: attribute 'package' in <manifest> tag is not a valid Android package name: 'org.emarti202.gcu.mpd-cw-em'.

尽管我的applicationId在build.gradle中,包名在AndroidManifest.xml匹配中,但它们仍然不能工作。有什么解决办法吗?抱歉,这是一个简单的解决办法,我似乎不能把我的头围绕在它上面。

AndroidManifest.xml

代码语言:javascript
运行
复制
<?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>

build.gradle

代码语言:javascript
运行
复制
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'
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-03-05 15:28:30

不幸的是,连字符“-”在包名中是不可接受的。请参考这份文件。

https://developer.android.com/guide/topics/manifest/manifest-element.html#package

是安卓应用程序的一个完整的Java语言风格的包名。名称可能包含大写或小写字母('A‘到'Z')、数字和下划线('_')。但是,单个包名部分只能以字母开头。在将应用程序构建到应用程序包(APK)中时,build系统将package属性用于两种情况

请将包名更改为“org.emarti202.gcu.mpd_cw_em”。

票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66495188

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档