0

I have migrated an old (2013) Java Android project to use Gradle as per the instructions in https://developer.android.com/studio/intro/migrate.

I have used the "Migrate by creating a new empty project strategy", the other strategy is "Migrate by creating a custom Gradle build file" but I have used the first.

After following the steps, I build my app in Android Studio and get the error "package R does not exist" in the Java files that use R.

I see that no gen directory is generated when building, so no wonder the R class is unknown. Any ideas I might try? Thanks a lot.

Pavitx
  • 81
  • 2
  • 17

1 Answers1

0

Since I was using the method "Migrate by creating a new empty project strategy" I created a directory and application named myprojectgradle and the package generated was com.example.myprojectgradle where my previous package was com.example.myproject. I fixed the package but the -gradle suffix was present in some places and confusing Android Studio. I changed the package in the generated unit test files (not important and are just boilerplate) and also removed the -gradle suffix in the build.gradle file applicationId property. Probably when you are using that strategy you should name your new project with the same name as the old non-Gradle project and keep the same package.

Pavitx
  • 81
  • 2
  • 17