error using dependencyResolutionManagement in nuild.gradle in Android-Studio - android

I try to add the dependencyResolutionManagement block to my build.gradle file.
I use this code in my build.gradle file:
plugins {
id 'com.android.application'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.findyourtimetable"
minSdkVersion 24
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
}
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
def fragment_version = "1.5.5"
implementation "androidx.fragment:fragment:$fragment_version"
}
I have the following error :
Build file '...\app\build.gradle' line: 5
A problem occurred evaluating project ':app'.
> No signature of method: build_2qy3qm6nv25wc6g469gv6z2jt.android() is applicable for argument types: (build_2qy3qm6nv25wc6g469gv6z2jt$_run_closure1) values: [build_2qy3qm6nv25wc6g469gv6z2jt$_run_closure1#35f3e998]
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
I tried to change the location of the dependencyResolutionManagement block but the function is not recognize.
I don't know what to do to solve this problem
thanks in advance for any help

You should add
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
}
}
into your settings.gradle file. You can take a look an example here from the nowinandroid app github repo.

Related

Running gradle build is failed When try to run on device?

before that i have uninstalled visual studio code , android studio and gradle , my project was running on device fine , but when reinstalled tools and try command :
ionic cap run android --livereload --consolelogs --serverlogs --external
to build and run my project on my device , I m facing this error :
Build file 'E:\Mes Projets\Mobile\iStore\iStore\node_modules\#capacitor-community\fcm\android\build.gradle' line: 29
[capacitor]
[capacitor] * What went wrong:
[capacitor] A problem occurred evaluating project ':capacitor-community-fcm'.
[capacitor] > initialize must be called for meta class of class build_asct3wckhlowifz9k3uacapmo$_run_closure2$_closure6(class org.codehaus.groovy.runtime.metaclass.ClosureMetaClass) to complete initialisation process before any invocation or field/property access can be done
my build.gradle file :
ext {
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.12'
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.1'
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.2.0'
firebaseMessagingVersion = project.hasProperty('firebaseMessagingVersion') ? rootProject.ext.firebaseMessagingVersion : '21.0.1'
}
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.1'
}
}
apply plugin: 'com.android.library'
android {
compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 30
defaultConfig {
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 21
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':capacitor-android')
testImplementation "junit:junit:$junitVersion"
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
androidTestImplementation 'com.android.support:support-annotations:28.0.0'
implementation "com.google.firebase:firebase-messaging:$firebaseMessagingVersion"
implementation 'com.android.support:appcompat-v7:28.0.0'
}
Note : im using Fcm for firebase messaging
how can i solve this error , any help ?
thanks

I'm having an error building my application in android studio

enter image description here
// this is the build.gradle(module:App)
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.authapp"
minSdkVersion 19
targetSdkVersion 30
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildFeatures {
mlModelBinding true
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
implementation 'com.google.firebase:firebase-auth:21.0.1'
implementation 'com.google.firebase:firebase-database:20.0.2'
implementation 'com.android.support:multidex:1.0.3'
implementation platform('com.google.firebase:firebase-bom:29.0.0')
implementation 'com.google.mlkit:image-labeling:17.0.5'
implementation 'org.tensorflow:tensorflow-lite-support:0.1.0'
implementation 'org.tensorflow:tensorflow-lite-metadata:0.1.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
apply plugin: 'com.google.gms.google-services'
// this is the Build.gradle(project: auth_app)
//
Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:4.2.1"
classpath 'com.google.gms:google-services:4.3.10'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenCentral()
// Warning: this repository is going to shut down soon
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I have no idea on how to fix this error can anyone pls assist me
this is the error in our project
Task :app:mergeDebugJavaResource FAILED
Execution failed for task ':app:mergeDebugJavaResource'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.MergeJavaResWorkAction
> 2 files found with path 'androidsupportmultidexversion.txt' from inputs:
- C:\Users\63921\.gradle\caches\transforms-2\files-2.1\480913dfb7b73ce9375e43aa9e1a997f\multidex-2.0.0\jars\classes.jar
- C:\Users\63921\.gradle\caches\transforms-2\files-2.1\4f2dc8a20d0b51cf9b4d1765b971973c\multidex-1.0.3\jars\classes.jar
Adding a packagingOptions block may help, please refer to
https://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.PackagingOptions.html
for more information
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Try adding this in your gradle file :
packagingOptions{
pickFirst “androidsupportmultidexversion.txt”
}
This will solve the conflict by picking up the first androidsupportmultidexversion.txt file.

How to Fix Error: Could not find method deleteAllActions() for arguments [] on task

I have added a new library. But I don't know why I am not able to build the project.
i am getting
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring project ':mavenirmeeting'.
org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method deleteAllActions() for arguments [] on task ':mavenirmeeting:extractDebugAnnotations' of type com.android.build.gradle.tasks.ExtractAnnotations.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Build Gradle
apply plugin: 'com.android.library'
apply plugin: 'me.tatarka.retrolambda'
android {
compileSdkVersion 28
android {
lintOptions {
abortOnError false
}
}
defaultConfig {
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
assets.srcDirs = ['assets']
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
// Google libraries
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
// other libraries
implementation 'se.emilsjolander:stickylistheaders:2.7.0'
implementation 'io.reactivex:rxjava:1.1.1'
}
What is going wrong I don't know. I am using Android studio version 3.4.
gradle weapper
#Tue Jul 02 13:27:58 IST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
If you are using RetroLambda in your project and Java8, then please remove retrolambda in gradle.properties file.
Java8 support lambda experession.
https://developer.android.com/studio/write/java8-support?utm_source=android-studio
Regards

Android common jar file in android

I have an app and two library modules - moduleA, moduleB.
Both of these modules are using a common jar file "xyz.jar" which is being placed in their respective libs folder.
When i am trying to build this project in Android studio i am getting following error -
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task
':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
I have already enabled multi dex by adding following lines in build files-
multiDexEnabled true
api 'com.android.support:multidex:1.0.2'
Could anyone please help? Almost whole day have been gone without any solution.
build.gradle for ModuleA
apply plugin: 'com.android.library'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation files('libs/bbdevice-android-3.4.1.jar')
}
build.gradle for ModuleB
apply plugin: 'com.android.library'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation files('libs/bbdevice-android-3.4.7.jar')
implementation files('libs/bbdeviceotaapi-android-1.5.2.jar')
}
app.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "visa.testapplication"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation project(':moduleA')
implementation project(':moduleB')
}
App Level build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
// 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
}
gradle-wrapper.properties file
#Tue Oct 16 14:44:59 IST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
Build Error Received
:app:mergeDebugAssets
:app:transformClassesWithDexBuilderForDebug
AGPBI: {"kind":"error","text":"Program type already present: com.bbpos.bb03z.c","sources":[{}],"tool":"D8"}
:app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\0.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\1.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\2.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\3.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\4.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\5.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\6.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\7.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\8.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\9.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\10.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\11.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\12.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\13.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\14.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\15.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\16.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\17.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\18.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\19.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\20.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\21.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\22.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\23.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\24.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\25.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\26.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\27.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\28.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\29.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\30.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\31.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\32.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\33.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\34.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\35.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\36.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\37.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\38.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\39.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\40.jar
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 56s
In Android Studio, Change the View from Android to Project and inside your app >> libs paste your .jar files
Then right click on your .jar file and select Add As Library
It will sync your project and added as gradle dependency

Dex Error while building the project

I am getting the following error when I try to build my project. This error occurs when I was trying to add JavaMail api in my project.
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
This is my gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.persi.eatery"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
packagingOptions {
exclude 'META-INF/mailcap.default'
exclude 'META-INF/mimetypes.default'
}
defaultConfig {
multiDexEnabled true
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.android.support:design:26.1.0'
implementation 'com.google.firebase:firebase-database:11.8.0'
implementation 'com.google.firebase:firebase-auth:11.8.0'
implementation 'com.sun.mail:android-mail:1.6.1'
implementation 'com.sun.mail:android-activation:1.6.1'
implementation project(':library')
}
apply plugin: 'com.google.gms.google-services'
My library gradle:
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion '26.0.2'
defaultConfig {
minSdkVersion 8
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
Project gradle file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
maven {
url "https://maven.java.net/content/groups/public/"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:3.1.1'
// 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
}
P.S I have already tried Clean project followed by rebuild project as suggested in other answers but its still not working.Thanks in advance
Unable to merge dex
You have a dependencies conflict. Try to see your dependencies via command ./gradlew app:dependencies (Details here ). And you will see the next situation:
As you can see android-mail depends on android-activation. I think you don't need to use the line implementation 'com.sun.mail:android-activation:1.6.1'
P.S. For debugging builds you can use the next flag "--stacktrace". Then you can see more information about your issue.

Categories

Resources