關於SweetAlertDialog在AS3.0環境下報錯的處理.
阿新 • • 發佈:2019-01-29
SweetAlertDialog Android Studio3.0, Gradle4.1報錯處理
前言
之前常用這個輪子, 近兩年, 原作者不再維護, AS3.0引用報錯, 在此宣告新版使用方式.
方式一
通過我自己封裝SweetAlertDialog新增依賴,直接引用
方式二
通過匯入Library引用
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') }