dev env is below:
androidStudio :4.2.2:
wrap gradle:https://services.gradle.org/distributions/gradle-4.10.1-bin.zip:
android Gradle plugin:'com.android.tools.build:gradle:3.2.0':
and i simplely create test code:
package com.example.myapplication;
import android.app.Activity;
import android.os.Bundle;
import android.os.Looper;
import android.util.Log;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
testAssert();
}
private void testAssert() {
assert Looper.myLooper()!=Looper.getMainLooper();
Log.i("yich","pass!!!!!!!!!");
}
}
android gradle config is below:
plugins {
id 'com.android.application'
}
android {
compileSdkVersion 29
// buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
}
when I run this code by android studio, app work fine, the 'assert' keywrod code not work,so i decompile apk i found no 'assert' code in my apk,pic below:decompile code screenshot ,
i guess it may be AGP's bug when package code into apk,when compile MainActivity.class to dex file ,the assert code is in class file,but i found that assert code lose in dex file,so what i do wrong to make assert code lose when packaging APk? need some help!!!