1

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?

Milad Faridnia
  • 9,113
  • 13
  • 65
  • 78

2 Answers2

0

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

bhgfas
  • 13
  • 2
0

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
Priyanka
  • 1,791
  • 1
  • 7
  • 12