Proguard is working well for release version but it is not work for debug version.
Here is my build.gradle file
buildTypes {
debug {
lintOptions {
disable 'MissingTranslation'
}
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
lintOptions {
disable 'MissingTranslation'
}
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
Related
We have enabled R8 in Gradle properties and when we set minify enable to true the app gets crashed stating the below exception code.
In gradle.properties,
android.enableR8 = true
android.enableR8.fullMode=true
useProguard = true
In build.gradle,
buildTypes {
release {
minifyEnabled false
debuggable false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug{
debuggable false
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
Exception : java.lang.SecurityException: Specified package com.oplus.internal.telephony under uid 1001 but it is not
at com.android.server.appop.AppOpsService.verifyAndGetBypass(AppOpsService.java:4791)
at com.android.server.appop.AppOpsService.noteOperationUnchecked(AppOpsService.java:3575)
at com.android.server.appop.AppOpsService.noteOperationImpl(AppOpsService.java:3563)
at com.android.server.appop.AppOpsService.access$4000(AppOpsService.java:223)
at com.android.server.appop.AppOpsService$CheckOpsDelegateDispatcher.lambda$noteOperation$4(AppOpsService.java:7769)
at com.android.server.appop.AppOpsService$CheckOpsDelegateDispatcher$$ExternalSyntheticLambda5.apply(Unknown Source:33)
at com.android.server.policy.AppOpsPolicy.noteOperation(AppOpsPolicy.java:221)
at com.android.server.appop.AppOpsService$CheckOpsDelegateDispatcher.noteOperation(AppOpsService.java:7767)
at com.android.server.appop.AppOpsService.noteOperation(AppOpsService.java:3547)
at com.android.internal.app.IAppOpsService$Stub.onTransact(IAppOpsService.java:476)
at com.android.server.appop.OplusAppOpsService.onTransact(OplusAppOpsService.java:38)
at android.os.Binder.execTransactInternal(Binder.java:1226)
at android.os.Binder.execTransact(Binder.java:1163)
I have two different flavor's, RQT & PRD.
And for one of them, I want to disable proguard configuration (for RQT, disable proguard for both buildTypes).
Like add conditioning ? Is something like that is possible ?
android {
...
flavorDimensions("server")
productFlavors {
rqt {
dimension "server"
applicationIdSuffix ".rqt"
}
prd {
dimension "server"
applicationIdSuffix ".prd"
}
}
...
buildTypes {
debug {
(__if (flavor != RQT) then do proguard config...__)
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
proguardFile 'proguard-debug-project.txt'
}
release {
(__if (flavor != RQT) then do proguard config...__)
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
proguardFile 'proguard-release-project.txt'
}
}
...
}
You could create additional Build Types, e.g. debugNoProguard, releaseNoProguard, etc.
android {
variantFilter { variant ->
def needed = variant.name in [
'rqtDebugNoProguard',
'rqtReleaseNoProguard',
'prdDebug',
'prdRelease'
]
variant.setIgnore(!needed)
}
buildTypes {
debug {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
proguardFile 'proguard-debug-project.txt'
}
debugNoProguard {
debuggable true
minifyEnabled false
signingConfig signingConfigs.debug
}
....
}
}
Then instead of building rqtDebug you would build the variant rqtDebugNoProguard or prdDebugNoProguard when you wanted to run a debug build without ProGuard.
flavorDimensions 'publish', 'develop'
productFlavors {
live {
dimension 'publish'
}
dev {
dimension 'develop'
applicationIdSuffix ".dev"
}
}
buildTypes {
debug {
minifyEnabled false
shrinkResources false
zipAlignEnabled true
debuggable true
productFlavors.live.signingConfig buildSignConfig.debug
productFlavors.dev.signingConfig buildSignConfig.debug
}
release {
minifyEnabled true
shrinkResources true
zipAlignEnabled true
debuggable false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
productFlavors.live.signingConfig buildSignConfig.release
productFlavors.dev.signingConfig buildSignConfig.release
}
}
I have 2 library modules and in application gradle file, I have above flavorDomensions, productFlavors and buildTypes. This produces build variant incorrectly like liveDevDedug and liveDevRelease. What could be the possible errors? Using AS 3.0
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
Just update your buildTypes instead your .
buildTypes {
release {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
Then Clean - Rebuild And
File -> Invalidate Cache / Restart . I hope it will helps you .
FYI : I think your gradle file under " apply plugin: 'com.android.application'"
buildTypes {
release {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
OR
You can try File -> Invalidate Caches/Restart, and select this option to fix this.
in the version 0.4.2 i write in the AndroidManifest
android:debuggable="false" to upload to play.store
but in the 0.5.1, i do not what to do.
Please, help me.
y resolved my problem with
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
foo{
debuggable false //add this
}
}
in the androidmanifest
i resolved the problem with
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
foo{
debuggable false //add this
}
}