Android Studio - Error:Program type already presen

2019-01-12 05:18发布

When I try to compile the code, the following error appears on Android Studio 3.0.1

Error:Program type already present: com.squareup.picasso.Action$RequestWeakReference

My gradle code:

  ...
    compile 'com.android.support:appcompat-v7:26.1.0'
    compile 'com.android.support:design:26.1.0'
    compile 'com.android.support:support-v4:26.1.0'
    compile 'com.android.support:support-vector-drawable:26.1.0'
    compile 'com.android.support.constraint:constraint-layout:1.1.0-beta4'
    compile 'com.google.firebase:firebase-messaging:11.8.0'
    compile 'com.google.firebase:firebase-ads:11.8.0'
    compile 'com.google.gms:google-services:3.1.0'
    compile 'com.google.android.gms:play-services:11.8.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    testCompile 'junit:junit:4.12'

}

apply plugin: 'com.google.gms.google-services'

How do I fix my gradle script to fix the error?

10条回答
Juvenile、少年°
2楼-- · 2019-01-12 06:05

Add this to your module build.gradle file

  configurations.all {exclude group: 'com.android.support', module: 'support-v13'}
查看更多
爷的心禁止访问
3楼-- · 2019-01-12 06:08

Check the compile version in your App settings. I changed it to the version compatible with the API level I've built my project with. This fixed the problem for me.

查看更多
干净又极端
4楼-- · 2019-01-12 06:09

I faced nightmare of multiple troubles building APK after I upgraded Android Studio to 3.1.2 and targetSdkVersion to 27. This was one of them.

implementation 'me.leolin:ShortcutBadger:1.1.21@aar' 

This line causing build error Program type already present: me.leolin.shortcutbadger.Badger

For now I just commented it out and it compiled smoothly.

查看更多
叛逆
5楼-- · 2019-01-12 06:14

For me, this error appeared when my build.gradle file contained an invalid line.

I added a .jar file as library, and the Build failed. I checked the build.gradle file, and somehow it contained two lines:

implementation files('libs/bcprov.jar')
implementation files('bcprov.jar')

Of course, I only added the .jar to the libs folder, so the second line is invalid. After I deleted the second line, the error disappeared.

Hope this will help someone.

查看更多
登录 后发表回答