Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: attribute 'package' in <manifest> tag is not a valid Android package name

I am trying to write an android app, which used to build once upon a time. Now, everytime I build, I get the following error:

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'.

I originally started off with an android-kotlin tutorial as the base, since I wanted to familiarize myself with kotlin and android, if that might be relevant. Also, "Merged Manifest" has package = dndtools instead of com.dndtools.android.dndtools listed, also not sure if relevant.

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
...

build.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
...

I have searched the internet, and others who had this error usually had an underscore at the start or end of their applicationId (which is not the case here), so I am really at a loss

like image 819
jay p Avatar asked Apr 09 '19 19:04

jay p


3 Answers

Change applicationId "dndtools" to 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. Update it to match the one you have in your Android Manfiest and it should work fine.

As for why it's an invalid package - it needs to have at least one dot in it to be installable on Android.

like image 90
Izabela Orlowska Avatar answered Nov 07 '22 17:11

Izabela Orlowska


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.

So simply removing this line helped me to fix this issue.

like image 35
B.shruti Avatar answered Nov 07 '22 17:11

B.shruti


My problem was with uncorrect naming of the package id. I put something like com.example.3d. You can't start with the number like 3d.

like image 6
Dyno Cris Avatar answered Nov 07 '22 17:11

Dyno Cris