Upgrading to Gradle version 4.0.0 broke R8 code shrinking - android

I have upgraded my gradle version to 4.0.0 from 3.6.3. Android Studio was able to install the app properly when minifyenabled was true and gradle version was 3.6.3 without any issues. On gradle version 4.0.0 and minifyenabled set to true doesn't even install the application. Here is what I see:
Installation did not succeed.
The application could not be installed: INSTALL_FAILED_INVALID_APK
List of apks:
[0] 'C:\Users\user\Desktop\Projects\Application\app\build\outputs\apk\debug\app-debug.apk'
[1] 'C:\Users\user\Desktop\Projects\Application\module1\build\outputs\apk\debug\module1-debug.apk'
[2] 'C:\Users\user\Desktop\Projects\Application\module2\build\outputs\apk\debug\module2-debug.apk'
[3] 'C:\Users\user\Desktop\Projects\Application\module3\build\outputs\apk\debug\module3-debug.apk'
[4] 'C:\Users\user\Desktop\Projects\Application\module4\build\outputs\apk\debug\module4-debug.apk'
[5] 'C:\Users\user\Desktop\Projects\Application\module5\build\outputs\apk\debug\module5-debug.apk'
The APKs are invalid.
build.gradle file:
android {
compileSdkVersion androidDependencies.compile_sdk_version
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.pills.mydemoapplication"
minSdkVersion androidDependencies.min_sdk_version
targetSdkVersion androidDependencies.target_sdk_version
versionCode 7
versionName "5.0.2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
kotlinOptions {
jvmTarget = "1.8"
}
buildTypes {
debug {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
buildFeatures{
dataBinding = true
}
dynamicFeatures = [":module1", ":module2", ":module3", ":module4", ":module5"]
}
Project level build.gradle
buildscript {
ext.kotlin_version = '1.3.72'
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools:r8:1.6.84"
classpath "com.android.tools.build:gradle:4.0.0"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.3.0-beta01"
}
}

Removing the following line from project level build.gradle made it work.
classpath "com.android.tools:r8:1.6.84"
R8 is now bundled with Android Gradle Plugin by default and the version of R8 in AGP is 2.0.74 and I was overriding it with a much older version which broke R8 code shrinking.

Make sure all your libraries and classpaths are up to date. I had a classpath for firebase-plugins that was out of date. This problem occurred when using the new gradle. After updating the classpath, everything looks fine.
In my case. I changed this
classpath 'com.google.firebase:firebase-plugins:1.1.0'
to this
classpath 'com.google.firebase:perf-plugin:1.3.1'

Related

Is there a way you can add repositories to android module (Library)

First of all, I'm working on an android application on android studio, within that app project I'm working also on a module that I want to keep as a library (I'll need it in other
future projects). This module has some dependencies for it own, and some of them require the addition of other repos on the project level gradle build script or on the gradle propertis file for newer version of gradle.
Is there a way that I can add repos the module only, so the next time when I want to reuse it, I'll not have to add the repos beforehand ?
After a lot of search here and there, I found that I can add repositories on module level build.gradle script.
buildscript {
repositories {
google()
mavenCentral()
// Other repos here ....
}
}
plugins {
id 'com.android.library'
}
android {
compileSdk 31
defaultConfig {
minSdk 21
targetSdk 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}
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 {
...
}
and Everything works like a charm.

The project is using an unsupported version of the Android Gradle plug-in (0.13.2). The recommended version is 1.0.0-rc2 [duplicate]

I've just updated my Android Studio and now my project won't build anymore. I get following error:
Error:(16, 0) Gradle DSL method not found: 'runProguard()'
Possible causes:<ul><li>The project 'App' may be using a version of Gradle that does not contain the method.
Gradle settings</li><li>The build file may be missing a Gradle plugin.
Apply Gradle plugin</li>
I didn't change anything, everything worked properly before the update. Here's my build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.ochs.pipette"
minSdkVersion 10
targetSdkVersion 21
versionCode 8
versionName "1.6"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:21.0.0'
compile 'it.sephiroth.android.library.imagezoom:library:1.0.4'
compile 'com.android.support:palette-v7:21.0.+'
}
And here's the other one:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0-rc2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
I don't know how to fix the problem, could anyone help me?
runProguard has been renamed minifyEnabled. See the changelog here for confirmation - version 0.14.0 (2014/10/31) of the Android Gradle plugin made the swap.
As #stkent said, runProguard has been renamed to minifyEnabled in version 0.14.0 (2014/10/31) of Gradle.
To fix this, you need to change runProguard to minifyEnabled in the build.gradle file of your project. For example,
buildTypes {
release {
runProguard false // Does not exist anymore...
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
would be replaced by
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
You can see other issues here but this worked for me.
runProguard has been renamed to minifyEnabled in version 0.14.0 (2014/10/31) of Gradle.
To fix this, you need to change runProguard to minifyEnabled in the build.gradle file of your project.

Upgrading project to Android Studio 1.0 (Gradle problems)

Just to start I'm very new to android development/android studio/gradle so forgive me if I'm asking a stupid question.
My team has been working on a project with the beta version of android studio, I've just installed the new version (1.0) and i've imported our project from the github remote repo.
When trying to sync the project with gradle i get the error: Gradle version 2.1 is required. Current version is 2.2.1. It recommends that I change the distributionUrl in gradle-2.1 but when I do I get the error that the gradle plugin requires 2.2.1.
The question is why is my project requiring 2.1 and where can I change this?
Here is my gradle.build:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
applicationId "com.<teamName>.<projectName>"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
buildscript{
dependencies{
classpath 'com.android.tools.build:gradle:1.0.0'
}
}
in the gradle-wrapper.properties use the following
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
in build.gradle use
dependencies {
classpath 'com.android.tools.build:gradle:1.0.+'
also replace
runProguard false
with
minifyEnabled true
I hope this can help
I was having the same issue that you were and had made the exact same updates as described in the Google docs.
The error I was making was editing my app module's build.gradle, and not the project's build.gradle in the root of the project folder for the com.android.tools.build version.
Here's the updated PROJECT's build.gradle file that I'm using that works.
// Top-level build file where you can add configuration options common to all sub- projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
ext {
compileSdkVersion = 21
buildToolsVersion = "20.0.0"
minSdkVersion = 15
targetSdkVersion = 21
}
allprojects {
repositories {
jcenter()
}
}
To change the gradle distribution used go to this file: {Project folder}/gradle/wrapper/graddle-wrapper.properties.
Then change the distributionUrl to use 2.1:
distributionUrl=https\://services.gradle.org/distributions/gradle-2.1-all.zip

Error:The project is using an unsupported version of the Android Gradle plug-in (0.12.2)

After update Android Studio I cant run my app - I get this Exception:
Error:The project is using an unsupported version of the Android Gradle plug-in (0.12.2). The recommended version is 1.0.0-rc4.
This is my buld.gradle dependencies
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
}
UPDATE I changed in build.gradle and now I get this error:
Error:(42, 0) Gradle DSL method not found: 'runProguard()'
Possible causes: The project 'drivernotes-android' may be using a version of Gradle that does not contain the method.
Gradle settings The build file may be missing a Gradle plugin.
Apply Gradle plugin
UPDATE 2
This is my build.gradle (fragment):
buildscript {
repositories {
maven { url 'http://repo1.maven.org/maven2' }
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0-rc4'
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
}
}
apply plugin: 'android'
apply plugin: 'crashlytics'
repositories {
maven { url 'http://download.crashlytics.com/maven' }
}
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
defaultConfig {
minSdkVersion 9
targetSdkVersion 19
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
release {
minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
signingConfigs {
}
}
Use this version of gradle plugin
classpath 'com.android.tools.build:gradle:1.0.0-rc4'
For more info related to gradle plugin and android studio compatiblity refer this
Edit
As of now both android studio as well as gradle plugin are both stable hence use this
classpath 'com.android.tools.build:gradle:1.0.0'
In App build.gradle in buildTypes{} i think you using runproguard. runProguard is depreceated so use minifyEnabled instead of runproguard
Edited :
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
update answer
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
You have to update your classpath. Currently I've got:
classpath 'com.android.tools.build:gradle:1.0.0-rc4'
Edit:
Replace runProguard with minifyEnabled in your gradle build file
Seems like these answers are very old, here is figured out the way to to fix the problem,
From AndriodStudio,
Step1: Cntrl+Alt+Shift => "S", will open a "Project Structure" window,
-or-
File > Project Structure
Step2: choose "Project" from the left array.
Step3: Change the gradlew version here.

After Android Studio update: Gradle DSL method not found: 'runProguard()'

I've just updated my Android Studio and now my project won't build anymore. I get following error:
Error:(16, 0) Gradle DSL method not found: 'runProguard()'
Possible causes:<ul><li>The project 'App' may be using a version of Gradle that does not contain the method.
Gradle settings</li><li>The build file may be missing a Gradle plugin.
Apply Gradle plugin</li>
I didn't change anything, everything worked properly before the update. Here's my build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.ochs.pipette"
minSdkVersion 10
targetSdkVersion 21
versionCode 8
versionName "1.6"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:21.0.0'
compile 'it.sephiroth.android.library.imagezoom:library:1.0.4'
compile 'com.android.support:palette-v7:21.0.+'
}
And here's the other one:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0-rc2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
I don't know how to fix the problem, could anyone help me?
runProguard has been renamed minifyEnabled. See the changelog here for confirmation - version 0.14.0 (2014/10/31) of the Android Gradle plugin made the swap.
As #stkent said, runProguard has been renamed to minifyEnabled in version 0.14.0 (2014/10/31) of Gradle.
To fix this, you need to change runProguard to minifyEnabled in the build.gradle file of your project. For example,
buildTypes {
release {
runProguard false // Does not exist anymore...
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
would be replaced by
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
You can see other issues here but this worked for me.
runProguard has been renamed to minifyEnabled in version 0.14.0 (2014/10/31) of Gradle.
To fix this, you need to change runProguard to minifyEnabled in the build.gradle file of your project.

Categories

Resources