Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

打包之后apk安装失败,报代码缺失 #688

Closed
Andyload opened this issue Dec 7, 2021 · 1 comment · Fixed by #709
Closed

打包之后apk安装失败,报代码缺失 #688

Andyload opened this issue Dec 7, 2021 · 1 comment · Fixed by #709
Assignees
Labels
bug Something isn't working

Comments

@Andyload
Copy link

Andyload commented Dec 7, 2021

异常类型:打包之后apk安装失败

安装命令

adb install -t E:\matrixdemo\app\build\outputs\apk\debug\app-debug.apk

输出日志:

adb: failed to install E:\matrixdemo\app\build\outputs\apk\debug\app-debug.apk: Failure [INSTALL_FAILED_INVALID_APK: Package couldn't be installed in /data/app/com.example.matrixdemo-1: Package /data/app/com.example.matrixdemo-1/base.apk code is missing

反编译apk,发现里面缺少classes.dex文件

手机型号:无

手机系统版本:无

matrix版本:2.0.2

gradle版本:6.1.1,gradle插件版本:4.0.0

问题描述:
在自己创建的Demo工程中,配置了Debug混淆配置:

    debug {
        debuggable true
        minifyEnabled true
        zipAlignEnabled true
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }

然后在gradle.properties配置了android.enableR8=false之后,就会出现这个问题,通过自己重复测试,发现同时配置了以上混淆参数和enableR8=false就会出现这个问题

项目只用函数耗时统计的功能,所以依赖的matrix库只有3个(MATRIX_VERSION=“2.0.2”):

implementation group: "com.tencent.matrix", name: "matrix-android-lib", version: MATRIX_VERSION, changing: true
implementation group: "com.tencent.matrix", name: "matrix-android-commons", version: MATRIX_VERSION, changing: true
implementation group: "com.tencent.matrix", name: "matrix-trace-canary", version: MATRIX_VERSION, changing: true

matrix的配置代码:
class MyApplication : Application() {

override fun onCreate() {
    super.onCreate()

    val builder = Matrix.Builder(this)
    builder.pluginListener(object : PluginListener {
        override fun onInit(plugin: Plugin) {
        }

        override fun onStart(plugin: Plugin) {
        }

        override fun onStop(plugin: Plugin) {
        }

        override fun onDestroy(plugin: Plugin) {
        }

        override fun onReportIssue(issue: Issue) {
            Log.e("MatrxApplication", "TracePlugin onReportIssue:$issue")
        }
    })
    val traceConfig = TraceConfig.Builder()
        .enableFPS(true)
        .enableEvilMethodTrace(true)
        .enableAnrTrace(true)
        .enableStartup(true)
        .isDebug(true)
        .isDevEnv(false)
        .build()

    val tracePlugin = TracePlugin(traceConfig)
    builder.plugin(tracePlugin)

    Matrix.init(builder.build())
    tracePlugin.start()
}

}

@scuzoutao
Copy link

+1,debug能打出来,打release就缺了dex文件

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants