亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Android接入阿里云熱修復(fù)介紹

 更新時(shí)間:2022年01月27日 09:13:03   作者:白色單肩包  
大家好,本篇文章主要講的是Android接入阿里云熱修復(fù)介紹,感興趣的同學(xué)趕快來看一看吧,對(duì)你有幫助的話記得收藏一下

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)文章

最新評(píng)論