关于SweetAlertDialog在AS3.0环境下报错的处理.

来源:互联网 发布:windows logo含义 编辑:程序博客网 时间:2024/05/16 13:42

SweetAlertDialog Android Studio3.0, Gradle4.1报错处理

之前常用这个轮子, 近两年, 原作者不再维护, AS3.0引用报错, 在此声明新版使用方式.

方式一

通过我自己封装SweetAlertDialog添加依赖,直接引用

参考项目地址:https://github.com/Cazaea/SweetAlertDialog

方式二

通过导入Library引用

1.下载作者源码https://github.com/pedant/sweet-alert-dialog,将作者源码中library作为module引用;
通过file–>new–>import Module(将作者源码中library直接导入)

参考: 为项目添加Module依赖


2.删除作者library–>build.gradle中给定的VERSION_NAME, GROUP,以及apply from引用, 更改版本信息(所有xxVersion值)与你的主包xxVersion值统一

apply plugin: 'com.android.library'//version = VERSION_NAME//group = GROUP     android {        compileSdkVersion 26        buildToolsVersion '26.0.2'        defaultConfig {            minSdkVersion 19        }        lintOptions {            abortOnError false        }    }    dependencies {        implementation 'com.pnikosis:materialish-progress:1.0'    }//apply from: 'https://raw.github.com/chrisbanes/gradle-mvn-push/master/gradle-mvn-push.gradle'

3.同上, 修改library–>src–>AndroidManifest文件中 xxVersion值与主包下值统一

<?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.pedant.SweetAlert">    <application /></manifest>

4.顺便贴出主包信息, 仅供参考.

apply plugin: 'com.android.application'android {    compileSdkVersion 26    buildToolsVersion '26.0.2'    defaultConfig {        applicationId "cn.pedant.SweetAlert.sample"        minSdkVersion 19        targetSdkVersion 26        versionCode 1        versionName "1.0.0"        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"        multiDexEnabled true        ndk {            abiFilters "armeabi"        }    }    lintOptions {        abortOnError false    }    /*最新打包输出命名方式 com.xx.xx-versionName(versionCode).apk*/    applicationVariants.all { variant ->        variant.outputs.all { output ->            def newApkName = applicationId + "-" + variant.versionName + "(" + variant.versionCode + ")" + ".apk"            outputFileName = new File(newApkName)        }    }}dependencies {    implementation fileTree(include: ['*.jar'], dir: 'libs')    implementation 'com.android.support:appcompat-v7:26.1.0'    implementation 'com.android.support.constraint:constraint-layout:1.0.2'    testImplementation 'junit:junit:4.12'    androidTestImplementation 'com.android.support.test:runner:1.0.1'    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'    //compile 'cn.pedant.sweetalert:library:1.3'    implementation project(':library')}
原创粉丝点击