I was recently updating my App dependencies and when trying to update the safeargs navigation component gradle plugin to 2.2.1 (actually happens with 2.2.0 too) like this:
dependencies {
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.2.1"
...
}
I'm getting the following error when trying to compile the project:
Unable to find method 'com.squareup.kotlinpoet.ClassName.<init>(Ljava/lang/String;[Ljava/lang/String;)V'.
Possible causes for this unexpected error include:
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)
The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)
Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
I tried all those solutions, none worked.
Gradle Files
build.gradle(project)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.71'
ext.navControllerVersion = '2.1.0'
ext.apolloVersion = '1.4.3'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.apollographql.apollo:apollo-gradle-plugin:$apolloVersion"
classpath 'com.google.gms:google-services:4.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
//Plugin added to check if the project has the last dependencies. You can run a gradle task via terminal with:
// ./gradlew dependencyUpdates
plugins {
id 'com.github.ben-manes.versions' version '0.28.0'
}
//This configuration is added for the ben-manes' plugin to ignore alpha, beta, rc, and so on updates
dependencyUpdates.resolutionStrategy {
componentSelection { rules ->
rules.all { ComponentSelection selection ->
boolean rejected = ['alpha', 'beta', 'rc', 'cr', 'm', 'preview'].any { qualifier ->
selection.candidate.version ==~ /(?i).*[.-]${qualifier}[.\d-]*/
}
if (rejected) {
selection.reject('Release candidate')
}
}
}
}
apply from: 'dependencies.gradle'
apply plugin: 'com.github.ben-manes.versions'
def versionMajor = 0
def versionMinor = 0
def versionPatch = 0
def versionBuild = 7 // bump for dogfood builds, public betas, etc.
allprojects {
repositories {
google()
jcenter()
}
ext {
androidApplicationId = 'es.client.mobile.android.appname'
androidVersionCode = versionMajor * 1000000 + versionMinor * 10000 + versionPatch * 100 + versionBuild
androidVersionName = "${versionMajor}.${versionMinor}.${versionPatch}.${versionBuild}"
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle(:app)
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: "androidx.navigation.safeargs.kotlin"
buildscript {
repositories {
google()
jcenter()
maven { url "https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/repository" }
}
dependencies {
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$navControllerVersion"
}
}
android {
def globalConfiguration = rootProject.extensions.getByName("ext")
compileSdkVersion globalConfiguration["androidCompileSdkVersion"]
testOptions.unitTests.includeAndroidResources = true
defaultConfig {
minSdkVersion globalConfiguration["androidMinSdkVersion"]
targetSdkVersion globalConfiguration["androidTargetSdkVersion"]
applicationId globalConfiguration["androidApplicationId"]
versionCode globalConfiguration["androidVersionCode"]
versionName globalConfiguration["androidVersionName"]
testInstrumentationRunner "es.client.mobile.android.appname.app.test.TestRunner"
buildConfigField "String", "MC_APP_ID", MC_APP_ID
buildConfigField "String", "MC_ACCESS_TOKEN", MC_ACCESS_TOKEN
buildConfigField "String", "MC_SENDER_ID", MC_SENDER_ID
buildConfigField "String", "MC_MID", MC_MID
buildConfigField "String", "MC_SERVER_URL", MC_SERVER_URL
}
dexOptions {
javaMaxHeapSize "4g"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
packagingOptions {
exclude 'LICENSE.txt'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/ASL2.0'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
}
lintOptions {
quiet true
abortOnError false
ignoreWarnings true
disable 'GoogleAppIndexingWarning' //For removing warning about deep linking in Manifest, because this app do not use deep links
}
signingConfigs {
release {
keyAlias '###'
keyPassword '####'
storeFile file('../extras/release/bundle/###.jks')
storePassword '###'
}
}
buildTypes {
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
signingConfig signingConfigs.release
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
flavorDimensions 'version'
productFlavors {
dev {
applicationIdSuffix ".dev"
versionNameSuffix "-dev"
dimension = 'version'
}
integDev {
applicationIdSuffix ".ind"
versionNameSuffix "-ind"
dimension = 'version'
}
integPre {
applicationIdSuffix ".inp"
versionNameSuffix "-inp"
dimension = 'version'
}
pro {
applicationIdSuffix ".pro"
versionNameSuffix "-pro"
dimension = 'version'
}
}
dataBinding {
enabled = true
}
}
androidExtensions {
experimental = true
}
dependencies {
def appDependencies = rootProject.ext.appDependencies
def appTestDependencies = rootProject.ext.appTestDependencies
def developmentDependencies = rootProject.ext.developmentDependencies
implementation project(':model')
implementation project(':domain')
implementation project(':data')
implementation project(':datasources')
implementation appDependencies.kotlin
implementation appDependencies.koin
implementation appDependencies.koinCompile
implementation appDependencies.koinArch
implementation appDependencies.ktxCore
implementation appDependencies.androidAnnotation
implementation appDependencies.appcompat
implementation appDependencies.recyclerView
implementation appDependencies.constraintLayout
implementation appDependencies.materialDesign
implementation appDependencies.lifecycleExtensions
implementation appDependencies.lifecycleCommonJava8
implementation appDependencies.navigationFragment
implementation appDependencies.navigationUi
implementation appDependencies.roomRuntime
implementation appDependencies.rxJava
implementation appDependencies.rxAndroid
implementation appDependencies.rxKotlin
implementation appDependencies.glide
implementation appDependencies.timber
implementation appDependencies.googleMaps
implementation appDependencies.googleMapsUtils
implementation appDependencies.googleLocation
implementation appDependencies.viewpager2
implementation appDependencies.playServicesAuth
implementation appDependencies.facebookSdk
implementation appDependencies.firebaseAnalytics
implementation appDependencies.firebaseCore
implementation appDependencies.firebaseMessaging
implementation appDependencies.marketingCloud
implementation appDependencies.googleServices
implementation appDependencies.zXing
implementation appDependencies.zXingEmbedded
// Unit test dependencies
implementation 'androidx.appcompat:appcompat:1.1.0'
testImplementation appTestDependencies.kotlinJUnit
testImplementation appTestDependencies.mockitoKotlin
testImplementation appTestDependencies.mockitoInline
// Instrumentation test dependencies
androidTestImplementation appTestDependencies.junit
androidTestImplementation appTestDependencies.lifecycleTest
androidTestImplementation(appTestDependencies.koinTest, {
exclude group: 'org.jetbrains.kotlin'
exclude group: 'org.mockito'
})
androidTestImplementation(appTestDependencies.mockitoKotlin, {
exclude group: 'org.jetbrains.kotlin'
exclude group: 'org.mockito'
})
androidTestImplementation appTestDependencies.mockitoAndroid
androidTestImplementation appTestDependencies.androidJUnit
androidTestImplementation(appTestDependencies.espressoCore) {
exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestImplementation(appTestDependencies.androidRunner) {
exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestImplementation(appTestDependencies.androidRules) {
exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestImplementation(appTestDependencies.espressoIntents) {
exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestImplementation(appTestDependencies.espressoContrib) {
exclude module: 'appcompat'
exclude module: 'appcompat-v7'
exclude module: 'support-v4'
exclude module: 'support-v13'
exclude module: 'support-annotations'
exclude module: 'recyclerview-v7'
exclude module: 'design'
}
//Development
debugImplementation developmentDependencies.leakCanary
debugImplementation developmentDependencies.flipper
debugImplementation developmentDependencies.soloader
debugImplementation developmentDependencies.flipperLeakcanary
}
apply plugin: 'com.google.gms.google-services' // Google Play services Gradle plugin
Edit:
More debug lead me to the conclusion that this is being caused by a dependency conflict on the kotlinpoet library, because if I change the safe-args plugin to use the java version:
apply plugin: "androidx.navigation.safeargs"
it works as expected. My problem is that when I invoke ./gradlew app:dependencies I'm not getting any dependency on kotlinpoet, so I don't know how to debug the conflict.
Thanks and best regards,
Ignacio
You've got the code below in your gradle module app instead of having it in gradle project.
Try this:
gradle project:
repositories {
google()
jcenter()
maven { url "https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/repository" }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.apollographql.apollo:apollo-gradle-plugin:$apolloVersion"
classpath 'com.google.gms:google-services:4.3.3'
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$navControllerVersion"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
And remove this:
gradle module:
buildscript {
repositories {
google()
jcenter()
maven { url "https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/repository" }
}
dependencies {
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$navControllerVersion"
}
}
In some cases the issue might be related to an old version of kotlinpoet conflicting with kotlinpoet version included in the SafeArgs lib.
Updating kotlinpoet to 1.4.4 solves the issue.
Related
I am working on native android project, I am migrating project code from support library to AndroidX.After that I have also fixed code related issue manually which are not fixed automatically by studio using Migate To AndroidX option.
After upgrading project code to AndroidX getting build errors for drawable.xml files.
here is screenshot of build error:
build error image
[1]: https://i.stack.imgur.com/OtHE5.png
**Project level build gradle :**
buildscript {
repositories {
mavenCentral()
google()
jcenter()
maven {
url 'https://maven.google.com/'
// name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.2' //4.1.2 //3.0.0
classpath 'com.google.gms:google-services:4.0.1'
classpath "io.realm:realm-gradle-plugin:2.2.1"
classpath 'com.google.firebase:firebase-plugins:1.1.5'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
}
}
allprojects {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
// maven {
maven {
url 'https://github.com/QuickBlox/quickblox-android-sdk-releases/raw/master/'
}
// }
maven { url 'https://maven.google.com/' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
ext{
// Sdk and tools
minSdkVersion = 21
targetSdkVersion = 29
compileSdkVersion = 29
gmsVersion = "16.1.0"
}
**App level build.gradle file :**
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
buildscript {
repositories {
// maven { url 'https://maven.fabric.io/public' }
}
dependencies {
// These docs use an open ended version so that our plugin
// can be updated quickly in response to Android tooling updates
// We recommend changing it to the latest version from our changelog:
// https://docs.fabric.io/android/changelog.html#fabric-gradle-plugin
// classpath 'io.fabric.tools:gradle:1.+'
}
}
//apply plugin: 'io.fabric'
repositories {
//maven { url 'https://maven.fabric.io/public' }
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
android {
useLibrary 'org.apache.http.legacy'
signingConfigs {
}
lintOptions {
abortOnError false
checkReleaseBuilds false
disable 'InvalidPackage'
}
buildTypes {
release {
debuggable false
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguardrules.pro'
signingConfig signingConfigs.config
}
debug {
debuggable true
signingConfig signingConfigs.config
}
}
compileSdkVersion rootProject.ext.compileSdkVersion
defaultConfig {
applicationId "com.app.homemade"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
// versionCode 21
// versionName "2.0"
versionCode 21
versionName "2.1"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
multiDexEnabled true
signingConfig signingConfigs.config
}
dexOptions {
javaMaxHeapSize "4g"
}
productFlavors {
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
exclude 'META-INF/proguard/androidx-annotations.pro' //added
}
compileOptions {
// sourceCompatibility JavaVersion.VERSION_1_7
// targetCompatibility JavaVersion.VERSION_1_7
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
sourceSets {
main {
assets.srcDirs = ['src/main/assets', 'src/main/assets/fonts']
resources.srcDirs = ['src/main/resources', 'src/main/java/org.jivesoftware.smack']
}
}
}
repositories {
jcenter()
mavenCentral()
maven { url "https://jitpack.io" }
flatDir {
dirs 'libs'
}
}
configurations.all {
resolutionStrategy.eachDependency { details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion '28.0.0'
}
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'com.google.android.gms:play-services-auth:16.0.1' //16.0.1
implementation "com.google.android.gms:play-services-maps:$rootProject.ext.gmsVersion"
implementation 'com.google.android.gms:play-services-location:16.0.0' //16.0.0
implementation 'com.google.android.gms:play-services-places:16.0.0' //16.0.0
// implementation 'com.google.android.gms:play-services-vision:16.2.0'
implementation 'com.google.firebase:firebase-core:17.5.1'
implementation 'com.google.firebase:firebase-iid:17.1.0' //17.1.0
implementation 'com.google.firebase:firebase-auth:16.0.4' //16.0.4
implementation 'com.google.firebase:firebase-messaging:17.4.0' //17.4.0
implementation 'com.google.firebase:firebase-crash:16.2.1'
implementation 'com.braintreepayments.api:drop-in:3.7.1' //5.1.0
implementation project(':chatinterface')
implementation project(':library')
implementation project(':jiaozivideoplayer')
implementation project(':cropper')
implementation 'io.pristine:libjingle:9690#aar'
implementation 'androidx.multidex:multidex:2.0.1' //1.0.1
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'com.github.CiaoIM:emojicon:v1.0.1'
implementation 'com.romainpiel.shimmer:library:1.4.0#aar'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.1.+' //1.1.+
implementation 'com.github.danielnilsson9:color-picker-view:1.4.0#aar'
implementation 'com.nineoldandroids:library:2.4.0+' //2.4.0+
implementation 'com.github.chrisbanes:PhotoView:1.2.6'
implementation 'com.squareup.picasso:picasso:2.5.2' //2.5.2
implementation 'com.github.bumptech.glide:glide:3.7.0'
implementation 'io.realm:android-adapters:1.3.0#aar'
implementation 'com.googlecode.libphonenumber:libphonenumber:7.4.3'
implementation 'org.apache.httpcomponents:httpmime:4.2.1' //4.2.1
implementation 'com.mcxiaoke.volley:library:1.0.19'
implementation 'com.squareup.retrofit:retrofit:1.6.1'
implementation 'com.google.code.gson:gson:2.3' //2.3
implementation 'com.squareup.okhttp:okhttp-urlconnection:2.0.0'
implementation 'com.squareup.okhttp:okhttp:2.0.0'
implementation 'log4j:log4j:1.2.17'
// compile 'com.facebook.android:facebook-android-sdk:4.22.0'
implementation 'fr.avianey.com.viewpagerindicator:library:2.4.1.1#aar'
implementation 'com.loopj.android:android-async-http:1.4.9'
implementation 'com.googlecode.mp4parser:isoparser:1.1.20'
implementation 'com.anjlab.android.iab.v3:library:1.0.44'
implementation "com.andkulikov:transitionseverywhere:1.8.0"
implementation 'de.hdodenhof:circleimageview:2.1.0' //2.1.0
implementation 'io.branch.sdk.android:library:5.+' //5.+
implementation 'com.nabinbhandari.android:permissions:3.8'
implementation 'fr.avianey.com.viewpagerindicator:library:2.4.1.1#aar'
// compile('com.crashlytics.sdk.android:crashlytics:2.10.1#aar') {
// transitive = true;
// }
}
apply plugin: 'com.google.gms.google-services'
**Gradle wrapper properties :**
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
**gradle properties:**
org.gradle.jvmargs=-Xmx4608m -Duser.country=US -Duser.language=en
android.useAndroidX=true
android.enableJetifier=true
**tried below solutions but not worked for me:**
1. https://stackoverflow.com/questions/58084850/how-to-fix-this-error-a-failure-occurred-while-executing-com-android-build-grad
2. Created drawable-v24 folder and pasted drawables.xml resources as mentioned below
https://stackoverflow.com/questions/50079312/resource-drawable-not-found
Please let me know any solutions.
After updating Android Studio to 3.5 version, which also updates Gradle version to 5.4.1. My instrumentation tests crash with a very strange error:
java.lang.NoClassDefFoundError: Failed resolution of: Lkotlin/LazyThreadSafetyMode
I have double-checked that all the Standard libraries along with Android libraries are up to date. Not sure what is causing the issue but both the app and unit tests run fine.
Here's my app/build.gradle file (omitting some unnecessary details since the file is too long):
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 28
buildToolsVersion '29.0.1'
defaultConfig {
minSdkVersion 23
targetSdkVersion 28
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArguments clearPackageData: 'true'
vectorDrawables.useSupportLibrary = true
buildTypes {
debug {
testCoverageEnabled = true
manifestPlaceholders = [analytics_deactivated: "true", crashlytics_activated: "false"]
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), "$project.rootDir/tools/rules-proguard-debug.pro"
ext.alwaysUpdateBuildId = false
}
}
dexOptions {
preDexLibraries = true
}
packagingOptions {
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/rxjava.properties'
exclude 'LICENSE.txt'
exclude 'META-INF/main.kotlin_module'
}
aaptOptions {
cruncherEnabled = false
}
lintOptions {
abortOnError false
fatal 'StopShip'
checkReleaseBuilds false
}
testOptions {
// execution 'ANDROIDX_TEST_ORCHESTRATOR'
animationsDisabled true
unitTests {
all {
// configure the test JVM arguments
jvmArgs '-noverify'
includeAndroidResources = true
returnDefaultValues = true
}
}
}
testOptions.unitTests.all {
testLogging {
events 'passed', 'skipped', 'failed', 'standardOut', 'standardError'
outputs.upToDateWhen { false }
showStandardStreams = true
}
}
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
kapt {
useBuildCache = true
}
androidExtensions {
experimental = true
}
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
flatDir { dirs 'libs-aar' }
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
// Google Support Library.
implementation "androidx.core:core-ktx:1.0.2"
implementation "androidx.appcompat:appcompat:1.0.2"
implementation "androidx.constraintlayout:constraintlayout:1.1.3"
// AAC
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.0.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
// MDC
implementation 'com.google.android.material:material:1.1.0-alpha09'
// Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$KOTLIN_VER"
/** Testing **/
// Android Testing Support Library
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.arch.core:core-testing:2.0.0'
androidTestUtil 'androidx.test:orchestrator:1.1.1'
androidTestImplementation 'androidx.test:rules:1.3.0-alpha02'
// Espresso
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.2.0'
}
apply plugin: 'com.google.gms.google-services'
and here's my project's build.gradle file:
buildscript {
ext.kotlin_version = '1.3.50'
ext.detekt_version = '1.0.0-RC14'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$KOTLIN_VER"
classpath 'io.fabric.tools:gradle:1.30.0'
classpath 'com.bugsnag:bugsnag-android-gradle-plugin:4.5.2'
classpath 'org.jlleitschuh.gradle:ktlint-gradle:6.3.1'
classpath "org.jetbrains.kotlin:kotlin-allopen:$kotlin_version"
}
}
allprojects {
repositories {
google()
jcenter()
}
apply plugin: "org.jlleitschuh.gradle.ktlint"
}
task clean(type: Delete) {
delete rootProject.buildDir
}
After i upgrade gradle, also gms, i'm having a error
Program type already present: net.jcip.annotations.GuardedBy
Message{kind=ERROR, text=Program type already present: net.jcip.annotations.GuardedBy, sources=[Unknown source file], tool name=Optional.of(D8)}
apply plugin: 'com.android.application'
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
}
buildscript {
repositories {
jcenter()
mavenCentral()
}
}
def AAVersion = '4.6.0' // change this to your desired version, for
example the latest stable: 4.1.0
android {
signingConfigs {
config {
keyAlias 'toefl2017'
keyPassword 'sangohan1987'
storePassword 'sangohan1987'
}
}
compileSdkVersion 28
buildToolsVersion "28.0.0"
defaultConfig {
applicationId "com.ouamassi.widaf"
minSdkVersion 14
targetSdkVersion 28
versionCode 5
versionName "1.03"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
javaCompileOptions{
annotationProcessorOptions{
includeCompileClasspath = true
}
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled false
debuggable false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
debug {
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/license.txt'
exclude 'META-INF/LGPL2.1'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation ('com.android.billingclient:billing:1.2.2')
implementation ("org.androidannotations:androidannotations:$AAVersion")
implementation ("org.androidannotations:androidannotations-api:$AAVersion")
implementation ('com.google.android.gms:play-services:12.0.0')
implementation project(path: ':fivestarslibrary', configuration: 'default')
}
Where is this GuardedBy thing ? i search for it but i don't found nothing
Generic gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
classpath 'com.google.gms:google-services:3.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
any help would be appreciated
With this :
./gradlew app:dependencies
I get detail of dependencies so i detect that the problem come from androidannotations
so instead of :
implementation ("org.androidannotations:androidannotations:$AAVersion")
implementation ("org.androidannotations:androidannotations-api:$AAVersion")
i had to put :
annotationProcessor ("org.androidannotations:androidannotations:$AAVersion")
implementation ("org.androidannotations:androidannotations-api:$AAVersion")
and also add :
multiDexEnabled true
implementation 'com.android.support:multidex:1.0.3'
I have an app already published on the store, after upgrading to Android Studio 3 (now 3.1) and the forced update of gradle I am unable to import my external projects as modules.
I have tried removing all my modules and adding them one by one, deleting the cache, changing gradle version, and compileSdkVersion but it doesn't work.
When I try to sync gradle I receive some messages like this:
Unable to resolve dependency for ':app#produzioneDebug/compileClasspath': Failed to transform file 'ShareLib-release.aar' to match attributes {artifactType=android-exploded-aar} using transform ExtractAarTransform
This is in my settings.gradle to make external project available:
include ':app'
include ':ShareLib'
project(':ShareLib').projectDir = new File('..//ShareLib//')
This is my build.gradle
buildscript {
repositories {
jcenter()
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'io.fabric.tools:gradle:1.+'
}
}
repositories {
jcenter()
mavenCentral()
mavenLocal()
maven {
url 'https://repo.spring.io/libs-milestone'
}
maven { url 'https://maven.fabric.io/public' }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
def AAVersion = '4.4.0'
android {
compileSdkVersion 26
buildToolsVersion "27.0.3"
defaultConfig {
minSdkVersion 15
targetSdkVersion 26
versionCode 3
versionName "1.0.0.0"
applicationId "com.xxx.app"
// Enabling multidex support.
multiDexEnabled true
javaCompileOptions {
annotationProcessorOptions {
arguments = ["resourcePackageName": android.defaultConfig.applicationId]
}
}
}
signingConfigs {
releaseSigning {
///
}
}
buildTypes {
debug {
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
zipAlignEnabled true
}
release {
// proguard
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
shrinkResources false
zipAlignEnabled true
signingConfig signingConfigs.releaseSigning
}
}
flavorDimensions "tier"
productFlavors {
dev {
buildConfigField "String", "SERVICE_URL_BASE", "\"dev.xxx.com/xxx-rest\""
applicationId "development.xxx.app"
}
coll {
buildConfigField "String", "SERVICE_URL_BASE", "\"dev.xxx.com/xxx-rest\""
applicationId "test.xxx.app"
}
prod {
buildConfigField "String", "SERVICE_URL_BASE", "\"www.xxx.com/xxx-rest\""
applicationId "com.xxx.app"
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
dexOptions {
javaMaxHeapSize "4g"
}
lintOptions {
checkReleaseBuilds false
abortOnError false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation project(path: ':shareLib', configuration: 'default')
// implementation project(path: ':shareLib', configuration: 'default') {
// exclude module: 'jsr305'
// }
// compile fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
implementation 'com.squareup:otto:1.3.8'
implementation 'org.springframework.android:spring-android-rest-template:2.0.0.M3'
annotationProcessor "org.androidannotations:androidannotations:$AAVersion"
implementation "org.androidannotations:androidannotations-api:$AAVersion"
annotationProcessor "org.androidannotations:rest-spring:$AAVersion"
implementation "org.androidannotations:rest-spring-api:$AAVersion"
annotationProcessor "org.androidannotations:otto:$AAVersion"
implementation "org.androidannotations:otto:$AAVersion"
implementation 'com.github.bumptech.glide:glide:3.7.0'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:recyclerview-v7:26.1.0'
// support AA on Android < 5
// compile 'com.android.support:multidex:1.0.1'
implementation 'com.github.markomilos:paginate:0.5.1'
// mpandroid
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.0-beta1'
// crashlytics fabric
implementation('com.crashlytics.sdk.android:crashlytics:2.6.1#aar') {
transitive = true
}
// recaptcha
implementation ('android.lib.recaptcha:reCAPTCHA:2.0.0') {
exclude group: 'com.android.support'
}
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.9.0'
}
I have solved opening modules project one by one and doing this for each one:
Project Structure -> Project -> Gradle Version = 4.7
Settings -> Build, Execution, Deployment -> Compiler -> Uncheck "Configure on demand"
Rebuild project once you can see your .aar file into build/outputs/aar
Then repeat these steps for main project module
When I am trying to build project in Android Studio I get the following error:
Error:Execution failed for task ':hunter:packageDebug'.
> Unsupported manifest version: 1.
When I clean project then I can run it normally, but then I need to clean it again before next build. It is really disturbing. I thought that Gradle and Adnroid version bump will help, but it changed nothing.
app build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'io.fabric'
android {
compileSdkVersion 27
buildToolsVersion "27.0.1"
defaultConfig {
applicationId "com.gamekit.gkquiz"
minSdkVersion 17
targetSdkVersion 27
versionCode 15
versionName "1.2.4"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
signingConfigs {
config {
keyAlias 'gamekit-key'
keyPassword kspass
storePassword kspass
storeFile file('../gamekit-release-key.jks')
}
}
buildTypes {
release {
ext.betaDistributionReleaseNotesFilePath = "crashlytics_release_notes.txt"
ext.betaDistributionGroupAliases = "android-testers"
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
}
sourceSets {
String sharedTestDir = 'src/sharedTest/java'
test {
java.srcDir sharedTestDir
}
androidTest {
java.srcDir sharedTestDir
}
}
packagingOptions {
pickFirst 'META-INF/*'
}
dexOptions {
javaMaxHeapSize "4g"
}
}
dependencies {
implementation project(':common')
kapt libs.activitystarter_kapt
implementation libs.paper_parcel
kapt libs.paper_parcel_kapt
compile ('com.github.kwizzad:kwizzad-android:2.0.2') {
exclude group:"com.android.support"
exclude group:"com.google.android.gms"
}
androidTestImplementation(libs.espresso_core, {
exclude group: 'com.android.support', module: 'support-annotations'
})
androidTestImplementation 'com.android.support.test.espresso:espresso-contrib:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
exclude group: 'com.android.support', module: 'support-v4'
exclude group: 'com.android.support', module: 'design'
exclude group: 'com.android.support', module: 'recyclerview-v7'
}
testImplementation libs.junit
}
common build.gradle
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.23.0'
}
}
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 27
buildToolsVersion '27.0.1'
defaultConfig {
minSdkVersion 17
targetSdkVersion 27
versionCode 1
versionName "1.0"
multiDexEnabled true
}
lintOptions {
abortOnError false
}
}
kapt {
generateStubs = true
}
dependencies {
implementation fileTree(dir: 'lib', include: '*.jar')
api libs.kotlin
api libs.android_support
api libs.retrofit
api libs.rx
api libs.glide
implementation libs.facebook_ads
api('com.crashlytics.sdk.android:crashlytics:2.6.8#aar') {
transitive = true
}
api 'com.github.MarcinMoskala:KotlinAndroidViewBindings:0.10'
api libs.preference_holder
api libs.activitystarter
api group: 'joda-time', name: 'joda-time', version: '2.9.9'
api group: 'com.google.code.gson', name: 'gson', version: '2.8.2'
implementation 'com.facebook.android:facebook-android-sdk:4.25.0'
implementation 'com.vk:androidsdk:1.6.8'
implementation 'com.google.firebase:firebase-ads:11.2.0'
implementation 'com.google.firebase:firebase-auth:11.2.0'
implementation 'com.google.android.gms:play-services-auth:11.2.0'
api 'com.github.marcinmoskala:ArcSeekBar:0.34'
implementation libs.multidex
androidTestImplementation(libs.espresso_core, {
exclude group: 'com.android.support', module: 'support-annotations'
})
testImplementation libs.junit
}
Project build.gradle
buildscript {
ext.kotlin_version = '1.2.0-rc-39'
ext.retrofit_version = '2.3.0'
ext.okhttp_version = '3.6.0'
ext.android_version = '27.0.1'
ext.activity_starter_version = '1.00'
ext.preference_holder_version = '1.51'
repositories {
google()
jcenter()
maven { url 'https://maven.fabric.io/public' }
maven { url 'http://dl.bintray.com/kotlin/kotlin-eap-1.2' }
maven { url "https://kotlin.bintray.com/kotlinx" }
maven { url 'https://maven.google.com' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0-alpha04'
classpath 'com.google.gms:google-services:3.0.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'io.fabric.tools:gradle:1.23.0'
}
}
allprojects {
repositories {
jcenter()
maven { url 'https://jitpack.io' }
maven { url 'https://maven.google.com' }
maven { url 'https://maven.fabric.io/public' }
maven { url "http://dl.bintray.com/kotlin/kotlin-eap-1.2" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
ext.libs = [
minions : 'com.github.marcinmoskala:minions:0.082',
preference_holder : ["com.marcinmoskala.PreferenceHolder:preferenceholder:$preference_holder_version",
"com.marcinmoskala.PreferenceHolder:preferenceholder-gson-serializer:$preference_holder_version",],
kotlin : "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version",
android_support : ["com.android.support:support-v4:$android_version",
"com.android.support:appcompat-v7:$android_version",
"com.android.support:cardview-v7:$android_version",
"com.android.support:recyclerview-v7:$android_version",
"com.android.support:design:$android_version"],
retrofit : ["com.squareup.retrofit2:retrofit:$retrofit_version",
"com.squareup.retrofit2:adapter-rxjava2:$retrofit_version",
"com.squareup.retrofit2:converter-gson:$retrofit_version",
"com.squareup.retrofit2:converter-scalars:$retrofit_version",
"com.squareup.okhttp3:okhttp:$okhttp_version",
"com.squareup.okhttp3:logging-interceptor:$okhttp_version"],
facebook_ads : 'com.facebook.android:audience-network-sdk:4.22.1',
rx : ['io.reactivex.rxjava2:rxjava:2.0.9',
'io.reactivex.rxjava2:rxandroid:2.0.1'],
activitystarter : ["com.marcinmoskala.activitystarter:activitystarter:$activity_starter_version",
"com.marcinmoskala.activitystarter:activitystarter-kotlin:$activity_starter_version"],
activitystarter_kapt: "com.marcinmoskala.activitystarter:activitystarter-compiler:$activity_starter_version",
joda_time : ['joda-time:joda-time:2.9.3',
'com.fatboyindustrial.gson-jodatime-serialisers:gson-jodatime-serialisers:1.2.0'],
event_bus : 'de.greenrobot:eventbus:2.4.0',
crashlytics : 'com.crashlytics.sdk.android:crashlytics:2.5.0#aar',
material_dialog : 'com.afollestad.material-dialogs:core:0.9.0.1',
glide : 'com.github.bumptech.glide:glide:3.7.0',
paper_parcel : ['com.github.grandstaish.paperparcel:paperparcel:1.0.0',
'com.github.grandstaish.paperparcel:paperparcel-kotlin:1.0.0'],
paper_parcel_kapt : 'com.github.grandstaish.paperparcel:compiler:1.0.0',
multidex : 'com.android.support:multidex:1.0.2',
junit : 'junit:junit:4.12',
espresso_core : 'com.android.support.test.espresso:espresso-core:2.2.2',
mockito : 'org.mockito:mockito-core:1.10.19'
]
Have you tried downgrading gradle i.e changing
'com.android.tools.build:gradle:3.1.0-alpha04'
to
'com.android.tools.build:gradle:3.0.0'