skip to Main Content

I Updated my Android studio to ChipMunk 2021.2.1 and then Android Studio recommend me to move package name from Android Manifest to build.gradle :

from:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="myPackageName">
    ...

to:

android {
    namespace 'myPackageName'
    ...
}

And after this change I get this kind of error in all generated Directions classes:

error: package R does not exist
@Override
public int getActionId() {
      return R.id.action_navigateToSomewhere;

I’ve read this post but it doesn’t help me.

Workaround: The only way I found to solve the problem is to revert Android Studio recommended changes which seems ridiculous.

I guess it’s a bug in navigation. Is there any other way to solve this problem?

2

Answers


  1. Connect your VPN then
    Build/Rebuild project or Invalidate cache and restart

    Login or Signup to reply.
  2. It is working fine in Android Studio Electric Eel | 2022.1.1

    You need to move package name from build.gradle app level to manifest as below –

    Remove package name from build gradle

    android  { 
        namespace 'com.appname' //remove this line
    }
    

    Add below line to manifest

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="com.example.app"> //add package name to manifest
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search