sweet alert dialog 在android studio应用问题说明详解
看到这个sweet-alert-dialog很亲切,因为前端开发本人用的提示就是这个js插件,java牛人很厉害,直接弄成一个java包插件,good!
下面记录如何引用到工程,并使用:
sweet-alert-dialog插件可以直接到github上下载
地址:
或者直接到发布好的页面下载:
我下载的是:sweet-alert-dialog-1.1版本zip包
将下载sweet-alert-dialog-1.1包解压出来,再你的app项目中,打开 file -> new -> import module 选择到刚才解压的文件夹
报错:
error:dependency myalert:sweetalertdialog:unspecified on project app resolves to an apk archive which is not supported as a compilation dependency. file: d:\androidstudioprojects\test\myalert\sweetalertdialog\build\outputs\apk\sweetalertdialog-release-unsigned.apk
可以先build一下sweet-alert-dialog工程。
另外你的工程gradle scripts目录下的bulid.gradle (module:app)下
dependencies { compile filetree(include: [‘*.jar'], dir: ‘libs') testcompile ‘junit:junit:4.12' compile ‘com.android.support:appcompat-v7:24.1.1' compile ‘cn.pedant.sweetalert:library:1.3' }
引入:compile ‘cn.pedant.sweetalert:library:1.3'
build app出现新的错误信息:
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 element at androidmanifest.xml:5:5-18:19 to override.
解决方法:
修改androidmanifest.xml:
在manifest添加 xmlns:tools=”http://schemas.android.com/tools”
在application添加 tools:replace=”android:icon,android:theme,android:allowbackup,android:label,android:supportsrtl”
将在application中所用到的全部android:都在上面tools:replace=添加进去,逗号分隔。
如下:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="cn.cgrs.myalert"> <application tools:replace="android:allowbackup,android:icon,android:label,android:supportsrtl,android:theme" android:allowbackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsrtl="true" android:theme="@style/apptheme"> <activity android:name=".mainactivity"> <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> </application> </manifest>
到此sweet-alert-dialog已完成配置,可以开始随意使用了….
以上所述是小编给大家介绍的sweet alert dialog 在android studio应用问题说明详解,希望对大家有所帮助