Android接入阿里云熱修復(fù)介紹
1.AndroidManinifest.xml中加入權(quán)限
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
2.AndroidManinifest.xml里application
中加入以下,在AS中打開在第五步下載的文件
App ID:"hotfix.idSecret"
App Secret:"emas.appSecret"
RSA密鑰:"hotfix.rsaSecret"
<meta-data android:name="com.taobao.android.hotfix.IDSECRET" android:value="App ID" /> <meta-data android:name="com.taobao.android.hotfix.APPSECRET" android:value="App Secret" /> <meta-data android:name="com.taobao.android.hotfix.RSASECRET" android:value="RSA密鑰" />
3、在app的build.gradle中加入依賴等
plugins { id 'com.android.application'} //加載文件 apply plugin: 'com.aliyun.ams.emas-services' android { compileSdkVersion 30 buildToolsVersion '30.0.3' defaultConfig { applicationId "com.wb.hotfixdemo" minSdkVersion 16 targetSdkVersion 30 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } debug { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } } dependencies { implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'com.google.android.material:material:1.1.0' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' testImplementation 'junit:junit:4.+' androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' //阿里云依賴 api 'com.aliyun.ams:alicloud-android-hotfix:3.3.0' }
4、SophixStubApplication
目前集成已經(jīng)完畢了,下面就是代碼的實(shí)現(xiàn),新建一個(gè)類SophixStubApplication
繼承SophixApplication
public class SophixStubApplication extends SophixApplication { private final String TAG = "SophixStubApplication"; // 此處SophixEntry應(yīng)指定真正的Application,并且保證RealApplicationStub類名不被混淆。 @Keep @SophixEntry(MyRealApplication.class) static class RealApplicationStub {} @Override public void onCreate() { super.onCreate(); SophixManager.getInstance().queryAndLoadNewPatch(); } @Override protected void attachBaseContext(Context base) { super.attachBaseContext(base); // 如果需要使用MultiDex,需要在此處調(diào)用。 // MultiDex.install(this); initSophix(); } private void initSophix() { String appVersion = "0.0.0"; try { appVersion = this.getPackageManager().getPackageInfo(this.getPackageName(), 0).versionName; } catch (Exception e) { } final SophixManager instance = SophixManager.getInstance(); instance.setContext(this) .setAppVersion(appVersion) .setSecretMetaData(null, null, null) .setEnableDebug(true) .setEnableFullLog() .setPatchLoadStatusStub(new PatchLoadStatusListener() { @Override public void onLoad(final int mode, final int code, final String info, final int handlePatchVersion) { if (code == PatchStatus.CODE_LOAD_SUCCESS) { Log.i(TAG, "sophix load patch success!"); } else if (code == PatchStatus.CODE_LOAD_RELAUNCH) { // 如果需要在后臺(tái)重啟,建議此處用SharePreference保存狀態(tài)。 Log.i(TAG, "sophix preload patch success. restart app to make effect."); } } }).initialize(); } }
5、MyRealApplication
public class MyRealApplication extends Application { }
6、AndroidManinifest.xml里加入SophixStubApplication
<application android:name=".SophixStubApplication" //加入此項(xiàng) android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/Theme.HotFixDemo">
到這已經(jīng)完成阿里云熱修復(fù)的百分之八十,后面就是下載工具實(shí)現(xiàn)發(fā)布補(bǔ)丁
到此這篇關(guān)于Android接入阿里云熱修復(fù)介紹的文章就介紹到這了,更多相關(guān)Android阿里云熱修復(fù)內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Kotlin開發(fā)實(shí)戰(zhàn)之hello world
這篇文章主要為大家詳細(xì)介紹了Kotlin開發(fā)實(shí)戰(zhàn)之hello world的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-05-05Android 中menu同時(shí)顯示圖標(biāo)和文字的實(shí)現(xiàn)
這篇文章主要介紹了Android 中menu同時(shí)顯示圖標(biāo)和文字的實(shí)現(xiàn)的相關(guān)資料,希望通過本文能幫助到大家實(shí)現(xiàn)這樣的功能,需要的朋友可以參考下2017-10-10Android Path繪制貝塞爾曲線實(shí)現(xiàn)QQ拖拽泡泡
本文主要介紹Android Path繪制貝塞爾曲線,這里整理相關(guān)資料并運(yùn)用貝塞爾曲線實(shí)現(xiàn)QQ拖拽泡泡的示例,有興趣的小伙伴可以參考下2016-09-09Android語音識(shí)別技術(shù)詳解及實(shí)例代碼
這篇文章主要介紹了Android語音識(shí)別技術(shù)的相關(guān)資料,并附實(shí)例代碼及實(shí)例實(shí)現(xiàn)效果圖,需要的朋友可以參考下2016-09-09RecyclerView實(shí)現(xiàn)常見的列表菜單
這篇文章主要為大家詳細(xì)介紹了用RecyclerView實(shí)現(xiàn)移動(dòng)應(yīng)用中常見的列表菜單,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-12-12Android實(shí)現(xiàn)屏幕各尺寸的獲取的示例
本篇文章主要介紹了Android實(shí)現(xiàn)屏幕各尺寸的獲取的示例,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-09-09Android開發(fā)使用HttpURLConnection進(jìn)行網(wǎng)絡(luò)編程詳解【附源碼下載】
這篇文章主要介紹了Android開發(fā)使用HttpURLConnection進(jìn)行網(wǎng)絡(luò)編程的方法,結(jié)合實(shí)例形式分析了Android基于HttpURLConnection實(shí)現(xiàn)顯示圖片與文本功能,涉及Android布局、文本解析、數(shù)據(jù)傳輸、權(quán)限控制等相關(guān)操作技巧,需要的朋友可以參考下2018-01-01Android 應(yīng)用的歡迎界面實(shí)現(xiàn)代碼
本文主要介紹Android 應(yīng)用歡迎界面的開發(fā),這里提供實(shí)現(xiàn)方法和實(shí)現(xiàn)代碼以供大家參考,有需要的朋友可以參考下2016-07-07