8

Gradle is throwing Program type already present: androidx.transition.R" after importing androidx.viewpager2:viewpager2:1.0.0-beta02

implementation 'androidx.viewpager2:viewpager2:1.0.0-beta02'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.vectordrawable:vectordrawable:1.0.1'
implementation 'androidx.annotation:annotation:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

AGPBI: {"kind":"error","text":"Program type already present: androidx.transition.R","sources":[{}],"tool":"D8"}

Expected outcome: Gradle should compile with no error

Dvyn Resh
  • 980
  • 1
  • 6
  • 14
Dimitri
  • 123
  • 1
  • 7

4 Answers4

23

I was facing similar problem, Rebuilding the project resolved it.

Android Studio Menu -> Build -> Rebuild Project.

Rahul Patel
  • 607
  • 8
  • 10
3

actually in my case run ./gradlew clean inside android directory worked.

I hope it helps you.

Ahmad Khani
  • 850
  • 2
  • 10
  • 15
2

First, try:

Build -> Clean Project.

It's faster than Rebuild and except once, always fixed my problems. If it doesn't work, try to rebuild it as @Rahul mentioned.

Positive Navid
  • 2,481
  • 2
  • 27
  • 41
0

This is possibly due to build issue.

Either

  • remove the old build folder with ./gradlew clean inside the android directory, or
  • simply remove android/app/build folder
Sujith PS
  • 4,776
  • 3
  • 34
  • 61