Egret packaging Apk problems

Build.gradle file modification:

buildscript {
    
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.3'
        

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        flatDir {
            dirs 'libs'
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

app->build.gradle file modification:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    defaultConfig {
        applicationId "com.companyname"
        minSdkVersion 22
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        ndk {
            abiFilters 'armeabi-v7a'
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    sourceSets {
        main {
            assets.srcDirs = ['../assets']
            jniLibs.srcDirs = ['libs']
        }
    }
    buildToolsVersion '29.0.3'
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
}

dependencies {
    compile(name: 'egret', ext: 'aar')
}

After modification, recompile can be successful, then Build->Build Bundle(s)/APK(s)->Build APK can be packaged

The location of the package is "project folder\app\build\outputs\apk\debug\app-debug.apk"

 

Remove debugging information such as fps displayed in the package

Go to the project java->com.companyname->MainActivity.java to modify

nativeAndroid.config.showFPS = false;

 

Formal package method

Official package method: Build->Generate Signed Bundle or APK->APK

Then fill in the information according to the prompts

The location of the official package: "Project folder\app\release\app-release.apk"

* The country code in Mainland China is 86

Choice of jar signature and full apk signature

This is a new signature mechanism introduced from Android 7.0. It adds some features to the APK to make it more secure, so although this option is not mandatory, it is best to choose both . If you choose V2, an error will occur. Can not choose V2

Android Studio compilation error Received close_notify during handshake solution

修改build.gradle
buildscript{
    repositories{
        //jcenter() //把这里注释掉,换成阿里的源
        maven{ url'http://maven.aliyun.com/nexus/content/groups/public/' }
        maven{ url'http://maven.aliyun.com/nexus/content/repositories/jcenter'}
        google()
 }
}
allprojects{
    repositories{
        //jcenter() //把这里注释掉,换成阿里的源
        maven{ url'http://maven.aliyun.com/nexus/content/groups/public/' }
        maven{ url'http://maven.aliyun.com/nexus/content/repositories/jcenter'}
 } 
}

Apk name (name after installation) modification

<application
        android:allowBackup="true"
        android:icon="@drawable/icon"
        //apk名字,用egret打包引用路径是
        //文件主路径\app\src\main\res\values\strings.xml
        android:label="@string/app_name"
        android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >

Remember to modify the package name (not the apk name and apk file name)

File path\app\src\main\AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="你的包名">

Android studio customizes the name of the APK file packaged by the application

Versions above gradle 3.0:

android.applicationVariants.all {
    variant ->
        variant.outputs.all {
            //在这里修改apk文件名,引号内的字符串都可以随便定义
            outputFileName = "${variant.name}-v${variant.versionName}.apk"
        }
}

Versions below gradle 3.0:

The gradle version can be viewed in build.gradle under the project:

Mine is classpath'com.android.tools.build:gradle:3.1.2'

Add in the android{} brackets of the app’s build.gradle file

android.applicationVariants.all { variant ->
        variant.outputs.each { output ->
            def outputFile = output.outputFile
            if (outputFile != null && outputFile.name.endsWith('.apk')) {             
                //在这里修改apk文件名
                def fileName = "想要的文件名.apk"
                output.outputFile = new File(outputFile.parent, fileName)               
            }
        }
}

 

Guess you like

Origin blog.csdn.net/sun124608666/article/details/104527950