I went through the documentation looking for the way how to disable dexguard when running gradle but keeping plugin: 'dexguard'.
I tried to modify proguardFile getDefaultDexGuardFile('dexguard-debug.pro') to do nothing but unfortunately no luck. I need to set no dexguard functionality for my functional testing suit MonkeyTalk which cannot instrument the apk now.
How to turn the dexguard functionality off?
Update from zatziky's answer for current Android Gradle Plugin (v1.0+) and Dexguard Plugin (6.1.+)
To create a dexguard plugin switch you may do the following
In your root build.gradle add a property to your ext (or create it if not done yet, see here why you would do that)
ext {
enableDexGuardPlugin = false
....
}
In your app build.gradle add the plugin like this:
apply plugin: 'com.android.application'
if(rootProject.ext.enableDexGuardPlugin) {
apply plugin: 'dexguard'
}
and if you have library projects do it like this
apply plugin: 'com.android.library'
if(rootProject.ext.enableDexGuardPlugin) {
apply plugin: 'dexguard'
}
remove all proguard configs from your debug build-types (especially getDefaultDexGuardFile('dexguard-release.pro')) if you dont need them. Unfortunatly at least with lib projects, all buil-types are build even in assembleDebug, so you have to provide a stub for getDefaultDexGuardFile like zatziky said:
private File getDefaultDexGuardFile(String name) { new File(name) }
you may add this to your root build.gradle so every script has it.
Now if you expected huge performance benefits from that you may be disapointed. The key is to disable ALL minifyEnabled on debug builds, since as said before currently gradle android is dumb and builds all build-types (at least with libs). You may use the property above for it: enableDexGuardPlugin
release {
...
minifyEnabled rootProject.ext.enableDexGuardPlugin
...
}
It is not possible to keep the dexguard plugin on.
This is a workaround that Eric La Fortune send me and it works (Dexguard 6.x):
For disabling DexGuard, you would need to revert to the Android plugin. You could create a separate Gradle builld file. Alternatively, you could pick the preferred plugin with Groovy. E.g. in
build.gradle:
boolean dexguard = ......
apply plugin: dexguard ? 'dexguard' : 'android'
You can also call the utility method getDefaultDexGuardFile in the same way:
runProguard true
proguardFile dexguard ?
getDefaultDexGuardFile('dexguard-release.pro') :
getDefaultProguardFile('proguard-android.txt')
You do need to define a dummy version of this method in the build file, in case the standard Android plugin is chosen. It is not called in either case, but it solves the missing method definition for the standard plugin:
private File getDefaultDexGuardFile(String name) { new File(name) }
In the recent versions of DexGuard you can disable processing for specific build variants simply by not listing the 'proguardFile' lines.
So for example, to disable it for the debug build:
buildTypes {
debug {
}
release {
proguardFile getDefaultDexGuardFile('dexguard-release.pro')
proguardFile 'dexguard-project.txt'
proguardFile 'proguard-project.txt'
}
}
Edit - all proguardFiles must be gone for it to work
Related
I've created a KMM project, and also an Xcode project with a build phase that calls ./gradlew embedAndSignAppleFrameworkForXcode. It runs successfully, but generates a .framework, not an .xcframework; and we really need the latter for modern Xcode.
Am i missing something? I read that modern versions of kotlin can generate the xcframework directly, but i'm not sure how. Is there a gradle task for this?
Thanks so much :)
According to Kdoctor, I have:
Xcode 14.1
Android studio 2021.3
Kotlin Plugin: 213-1.7.20
Kotlin MM plugin: 0.5.1(213)-60
You should declare your XCFrameworks, then it'll register three tasks for you.
assembleXCFramework, assembleDebugXCFramework, and assembleReleaseXCFramework.
Here is an example of build.gradle:
import org.jetbrains.kotlin.gradle.plugin.mpp.apple.XCFramework
plugins {
kotlin("multiplatform")
}
kotlin {
val xcf = XCFramework()
val iosTargets = listOf(iosX64(), iosArm64(), iosSimulatorArm64())
iosTargets.forEach {
it.binaries.framework {
baseName = "shared"
xcf.add(this)
}
}
}
For more information, visit kotlin docs.
I have a live react native app, which was working fine. But now I need to made some changes to it but I am unable to do so after new updates and new gradle version. I have tried on multiple PCs and workspaces but all are of no use same error on every system pops up. giving some errors which are as under and attached screenshot.
FAILURE: Build failed with an exception.
The Kotlin Gradle plugin was loaded multiple times in different subprojects, which is not supported and may break the build.
This might happen in subprojects that apply the Kotlin plugins with the Gradle 'plugins { ... }' DSL if they specify explicit versions, even if the versions are equal.
Please add the Kotlin plugin to the common parent project or the root project, then remove the versions in the subprojects.
If the parent project does not need the plugin, add 'apply false' to the plugin line.
See: https://docs.gradle.org/current/userguide/plugins.html#sec:subprojects_plugins_dsl
The Kotlin plugin was loaded in the following projects: ':react-native-alarm-clock', ':react-native-webview'
What went wrong:
Execution failed for task ':invertase_react-native-apple-authentication:compileDebugKotlin'.
Screenshot of the error
another Screenshot of the error
I have a live react native app, which was working fine. But now I need to made some changes to it but I am unable to do so. I have tried on multiple PCs and workspaces but all are of no use same error on every system pops up.
add kotlin version in you android/build.gradle
buildscript {
ext {
...
kotlin_version='1.6.0' //add This change version with your installed kotlin version
...
}
repositories {
google()
mavenCentral()
}
dependencies {
...
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" //add This
...
}
}
Just go to build.gradle(Project:yourProjectName)
change
Plugin {
...
id 'org.jetbrains.kotlin.android' version '1.4.x' apply false
...
}
To
Plugin {
...
id 'org.jetbrains.kotlin.android' version '1.6.0' apply false
...
}
Ive got a error like this while building my project:
e: This version (1.1.1) of the Compose Compiler requires Kotlin version 1.6.10 but you appear to be using Kotlin version 1.6.20 which is not known to be compatible. Please fix your configuration (or suppressKotlinVersionCompatibilityCheck but don't say I didn't warn you!).
I'm using the newest IntellIJ Pro, and the newest kotlin
How i can make the compose compile with the project?
for kotlin version 1.6.20 you need to add this line in your build.gradle
composeOptions {
kotlinCompilerExtensionVersion '1.2.0-alpha08'
}
Refer to this documentation by google to find out more about kotlin compatibility to different compose versions
You need to use kotlin version 1.6.10 to compile project with this version of compose. In next releases may be thay add new version of kotlin support.
Change your gradle/maven properties to solve this problem.
In Gradle change:
kotlin("jvm") version "1.6.20"
to:
kotlin("jvm") version "1.6.10"
Or you can add compiler args (But there may be problems):
"-P", "plugin:androidx.compose.compiler.plugins.kotlin:suppressKotlinVersionCompatibilityCheck=true"
Here you can see compose and kotlin version mapping
https://developer.android.com/jetpack/androidx/releases/compose-kotlin
1.2.0-alpha08 ->1.6.20
1.1.0-rc02 -1.2.0-alpha07 ->1.6.10
Following the compatibility table posted by user2851150 above,https://developer.android.com/jetpack/androidx/releases/compose-kotlin, it works for me setting in build.gradle (module) :
android{
...
composeOptions {
kotlinCompilerExtensionVersion '1.1.1'
kotlinCompilerVersion '1.6.10'
}
...
}
You need to follow 2 steps for this,
go to your build.gradle(project) and there change your kotlin version for kotlin-gradle-plugin
ext.kotlin_version = '1.6.10'
//....
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
change your kotlin version for plugins -
plugins {
...
...
id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
}
Another update to this answer, since they still have not fixed this for Chipmunk. I left in comments what was causing the issue, so you may have to update again with new versions.
buildscript {
ext {
//compose_version = '1.1.0-beta01' -> causes problems
compose_version = '1.2.0-alpha08'
}
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.2.2' apply false
id 'com.android.library' version '7.2.2' apply false
//id 'org.jetbrains.kotlin.android' version '1.5.31' apply false -> causes problems
id 'org.jetbrains.kotlin.android' version '1.6.20' apply false
}
Go to the build.gradle in project level and change the kotlin version to mapped the required and compatible version
I'm working with IntelliJ 15.0.6, SpringBoot 1.4.3.RELEASE, Gradle 2.14 and Groovy 2.3.11.
I get the following message from IntelliJ:
I tried following from StackOverFlow, the official documentation and JavaCodeGeeks with no success.
This is my configuration file:
#Configuration
#ConfigurationProperties(prefix = "configuracoes")
class GeralConfiguration {
def proxyEndereco
def proxyPorta
}
And the relevant part of my application.yaml file:
configuracoes:
proxyEndereco: http://fake.com
proxyPorta: 8080
If I remove #ConfigurationProperties from my configuration file, the message disappears.
This is my build.gradle file:
buildscript {
repositories {
mavenLocal()
maven {url('http://repo.spring.io/plugins-release')}
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.3.RELEASE")
classpath('org.springframework.build.gradle:propdeps-plugin:0.0.7')
}
}
apply plugin: 'groovy'
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'propdeps'
apply plugin: 'propdeps-idea'
sourceCompatibility = 1.7
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
compile("org.springframework.boot:spring-boot-starter")
compile("org.springframework.boot:spring-boot-devtools")
optional("org.springframework.boot:spring-boot-configuration-processor")
compile('org.codehaus.groovy:groovy-all:2.3.11')
compile('com.machinepublishers:jbrowserdriver:0.17.3')
compile("org.im4java:im4java:1.4.0")
testCompile("org.springframework.boot:spring-boot-starter-test")
testCompile("org.spockframework:spock-core:1.1-groovy-2.4-rc-3")
}
compileJava.dependsOn(processResources)
compileGroovy.dependsOn(processResources)
Any ideas on what is going on and how I can fix this?
Unfortunately, the annotation processor is not supported with Groovy. You may want to report that IJ shouldn't show this warning with Groovy code.
#Stephane helped me find the answer.
Indeed annotation processor is not supported with Groovy but I didn't manage to get it to work inside src/main/java as well.
I found out that the classes subfolder inside build was marked as excluded by IntelliJ (I don't know why).
As I tried fixing issues one by one I was never getting success. When I performed all fixes at once and marked the classes subfolder as NOT excluded everything worked fine (although IntelliJ keeps showing me the error message).
Thanks to #Stephane for helping me.
From the Android Tools Project Site's Android Gradle Plugin User Guide I'm aware that it's possible to prevent Android's lint from aborting a build using:
lintOptions {
abortOnError false
}
I'm also aware that lint can be disabled for release builds:
lintOptions {
checkReleaseBuilds false
}
However, is it possible to completely disable lint when running e.g. gradle assembleDebug?
I'm aware of the risks and for this particular project it is wasting a fair amount of time given all the build flavors we have.
Surely you can do this by adding this line in your gradle.properties file:
gradle=build -x lint -x lintVitalRelease
Warning: The above line will prevent running lint for both debug and release builds!
If you want to find out more gradle hacks, speedy builds, performance improvements, this will be the best slides you'll be looking at: Mastering Gradle 3.0
I prepared this from a lot of different resources including Android Developer & Gradle documentation, Android Developer videos, etc - hope it helps! It really makes a huge difference in build times (incremental as well as project load time)
Add following lines of code inside build.gradle(app).
android {
lintOptions {
checkReleaseBuilds false
//If you want to continue even if errors found use following line
abortOnError false
}
}
I had similar problem and used all below options
quiet true
abortOnError false
checkReleaseBuilds false
but at the end I found that clearing and invalidating cache would be a good option to settle the matter.