日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Android >内容正文

Android

Android 阿里云热修复

發布時間:2023/12/10 Android 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Android 阿里云热修复 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
  • AndroidManinifest.xml中加入權限
  • <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 30buildToolsVersion '30.0.3'defaultConfig {applicationId "com.wb.hotfixdemo"minSdkVersion 16targetSdkVersion 30versionCode 1versionName "1.0"testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"}buildTypes {release {minifyEnabled falseproguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'}debug {minifyEnabled falseproguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'}}compileOptions {sourceCompatibility JavaVersion.VERSION_1_8targetCompatibility 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
    目前集成已經完畢了,下面就是代碼的實現,新建一個類SophixStubApplication繼承SophixApplication

    public class SophixStubApplication extends SophixApplication {private final String TAG = "SophixStubApplication";// 此處SophixEntry應指定真正的Application,并且保證RealApplicationStub類名不被混淆。@Keep@SophixEntry(MyRealApplication.class)static class RealApplicationStub {}@Overridepublic void onCreate() {super.onCreate();SophixManager.getInstance().queryAndLoadNewPatch();}@Overrideprotected void attachBaseContext(Context base) {super.attachBaseContext(base); // 如果需要使用MultiDex,需要在此處調用。 // 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() {@Overridepublic 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) {// 如果需要在后臺重啟,建議此處用SharePreference保存狀態。Log.i(TAG, "sophix preload patch success. restart app to make effect.");}}}).initialize();} }

    5、MyRealApplication

    public class MyRealApplication extends Application {}

    6、AndroidManinifest.xml里加入SophixStubApplication

    <applicationandroid:name=".SophixStubApplication" //加入此項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">

    到這已經完成阿里云熱修復的百分之八十,后面就是下載工具實現發布補丁

    總結

    以上是生活随笔為你收集整理的Android 阿里云热修复的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。