Execution failed for task ':app:minifyIsByPassDebugWithR8 - android

I'am using minifyenable = true but error in aapt_rules.txt
my build.gradle
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
debuggable false
}
debug {
debuggable true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
error logcat
Expected field or method name at /Users/ujangwahyu/REINOVASI/ANDROID/DEV/MS2_Android/app/build/intermediates/aapt_proguard_file/isByPassDebug/aapt_rules.txt:148:33
-keepclassmembers class * { *** #{(v) -> vm.onClickEnter(v)}(android.view.View); }

Some days before I also faced the same issue and I fixed it by configuring gradle.properties and build.gradle(project level)
put below two lines in gradle.properties
android.enableR8=false
android.enableR8.libraries=false
put below lines of code inside buildscript{} in build.gradle(project level)
configurations.all {
resolutionStrategy {
force 'net.sf.proguard:proguard-base:6.1.0'
}
}

Related

Android : Proguard is not working in debug mode

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'
}
}

Enable proguard in flavor

I'm using TeamCity to build version of application and upload it to HockeyApp. I want to enable proguard only on specific flavor and when building is on teamcity and uploading on HockeyApp, is it possible? Right now I defined variable in gradle file:
def runProguard = false
and set it in my flavors to false or true and then in build type I have:
if (project.hasProperty('teamcity') && runProguard.toBoolean()) {
minifyEnabled true
} else {
minifyEnabled false
}
but it doesn't work on teamcity and I have version without proguard on HockeyApp. How to fix it? Is it another way to do it for example defining gradle task with enabled proguard?
You should do something like this to achieve what you want:
android {
buildTypes {
debug {
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules-debug.pro'
}
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
mock {
initWith(buildTypes.release)
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
pro {
applicationId = 'com.example.app.pro'
}
free {
applicationId = 'com.example.app.free'
}
}
Also you can set some environment variable in teamcity and check if the build is happening on ci or it's on local machine:
if (!System.getenv("CI")) {
//do something on local machine
} else {
// do something on ci server
}

Gradle Android: Choose SignConfig according to BuildType

I want to add an if or something similar to my gradle build script, that decides wether to sign my App with the Debug-Key or Release Key accodring to what buildType I'm using. I can't do that in the buildTypes section, because if have different release keys for my product flavours. I tried it with something like buildType.name, but gradle does not know this property.
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard.txt'
}
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard.txt'
}
}
signingConfigs {
app1 {
....
}
app2 {
....
}
}
productFlavors {
app1 {
applicationId "com.test.app1"
}
app2 {
applicationId "com.test.app2"
if (buildType.name == 'release'){
signingConfig signingConfigs.app2
}
}
}
Edit: Ok I managed to solve it via gradle.properties: I add a property and set it true or false in buildtypes, and an if in the productFlavour add the signConfig if true.

Android Studio / cannot resolve getDefaultProguardFile

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.

debuggable false in Android Studio 0.5.1

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
}
}

Categories

Resources