0

I am trying to use Sweet Alert Dialog(here) in my project but I face a problem. I am following the README.md file but I don't know where to place the following in android studio:

MAVEN

<dependency>
    <groupId>cn.pedant.sweetalert</groupId>
    <artifactId>library</artifactId>
    <version>1.3</version>
    <type>aar</type>
</dependency>

I've succesfully modified the build.gradle project-level but I don't know what to do with this..

My module gradle file is:

apply plugin: 'com.android.application'

android {
compileSdkVersion 27
defaultConfig {
    applicationId "com.vogella.android.service.receiver.myapplication"
    minSdkVersion 19
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"

}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 
'proguard-rules.pro'
    }
}
}

dependencies {
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:27.1.1'
    compile 'com.android.support:support-v4:27.1.1'
    compile 'com.android.support:design:27.1.1'

    //Sweet alert dialog
    compile 'cn.pedant.sweetalert:library:1.3'


}

project-level gradle file:

buildscript {

repositories {
    google()
    jcenter()
    mavenCentral()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.0.1'


    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}

allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

And that's the error I get:

Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : Attribute application@icon value= 
(@mipmap/ic_launcher) from AndroidManifest.xml:7:9-43
is also present at [com.pnikosis:materialish-progress:1.0] 
AndroidManifest.xml:13:9-45 value=(@drawable/ic_launcher).
Suggestion: add 'tools:replace="android:icon"' to <application> element at 
AndroidManifest.xml:5:5-19:19 to override.
Kwnstantinos Nikoloutsos
  • 1,832
  • 4
  • 18
  • 34
  • 1
    Possible duplicate of [How do I add a library project to Android Studio?](https://stackoverflow.com/questions/16588064/how-do-i-add-a-library-project-to-android-studio) –  Jun 28 '18 at 14:26
  • not really on-topic, but that library you want to use is really outdated. Get something newer. I used it as well and only got problems with Gradle. – Zun Jun 28 '18 at 14:34
  • @ZUNJAE is this why although I have add these in my gradle file it doesn't work? – Kwnstantinos Nikoloutsos Jun 28 '18 at 14:36
  • 1
    You're using unmaintained project, try this fork instead: https://github.com/F0RIS/sweet-alert-dialog – ישו אוהב אותך Jun 28 '18 at 14:38

2 Answers2

3

if you look closely this is about maven repository. You should go for gradle. it will work. Go into your module gradle file and in dependency tag write dependency and after that write reporitories and put mavenCentral in it.

  repositories {
    mavenCentral()
}

dependencies {
    implementation 'cn.pedant.sweetalert:library:1.3'
}

By looking at your logs the problem is in your manifest merging:

 xmlns:app="http://schemas.android.com/tools"
 app:replace="android:icon
Umair
  • 6,366
  • 15
  • 42
  • 50
  • I already have done this. I have added mavenCentral() in allprojects{ repositories {} and the compile statement – Kwnstantinos Nikoloutsos Jun 28 '18 at 14:26
  • @KwnstantinosNikoloutsos then what issue you faced while implementing this approach ? – Umair Jun 28 '18 at 14:27
  • @KwnstantinosNikoloutsos you have imported this library and now you use it ? What do want exactly ? – Umair Jun 28 '18 at 14:48
  • check my post. The library isn't imported and I am getting an error message for some reason – Kwnstantinos Nikoloutsos Jun 28 '18 at 14:49
  • @KwnstantinosNikoloutsos and looking at the error message your problem is not that library but merging of manifest files. Open your manifest file and then click merged manifests at bottom it will show you the problem fix it there and you will be good to go. – Umair Jun 28 '18 at 14:50
  • So is there any conflict in manifest files? I still cannot resolve this but thank you for your help – Kwnstantinos Nikoloutsos Jun 28 '18 at 14:57
  • 1
    @KwnstantinosNikoloutsos I am pretty much sure the problem is in your manifest files not in the library. And opening your manifest file and then clicking merger manifest tab below, you will know where the problem is :)/ – Umair Jun 28 '18 at 14:58
  • One more thing you can actually see from logs where the problem is – Umair Jun 28 '18 at 15:01
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/173974/discussion-between-kwnstantinos-nikoloutsos-and-umair). – Kwnstantinos Nikoloutsos Jun 28 '18 at 15:02
0

Add this to your app level gradle and sync again.

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '25.3.0'
            }
        }
    }
}