Dimitri
Dimitri

Reputation: 153

Android - Program type already present com.transition.R while importing ViewPager2 library

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

Upvotes: 8

Views: 3821

Answers (4)

Sujith PS
Sujith PS

Reputation: 4864

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

Through IDE: Android Studio Menu -> Build -> Rebuild Project.

Upvotes: 0

Ahmad Khani
Ahmad Khani

Reputation: 978

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

I hope it helps you.

Upvotes: 3

Positive Navid
Positive Navid

Reputation: 2781

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.

Upvotes: 2

Rahul Patel
Rahul Patel

Reputation: 617

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

Android Studio Menu -> Build -> Rebuild Project.

Upvotes: 23

Related Questions