I had an android project running well, but suddenly I encountered some errors which made me update my android studio to 3.2.1 and gradle to 4.6. My code is same as my colleague (all codes and versions) except one line in gradle that I will explain it later, he can build easily but I can't because of following errors:
Failed to resolve: espresso-core
Open File
Failed to resolve: multidex-instrumentation
Open File
app.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.arnick.bazim"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "0.7"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
manifestPlaceholders = [onesignal_app_id : "xxxxxxxxxxxxxx",
onesignal_google_project_number: "REMOTE"]
}
applicationVariants.all { variant ->
variant.resValue "string", "versionName", variant.versionName
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
jcenter()
}
dependencies {
implementation 'com.android.support:recyclerview-v7:27.1.1'
// the above line is showing error to me, error is about some version mismatching
// even by doing what it says the error does not disappear
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.getkeepsafe.taptargetview:taptargetview:1.11.0'
implementation 'com.stephentuso:welcome:1.4.1'
implementation 'co.ronash.android:pushe-base:1.4.0'
implementation 'com.google.android.gms:play-services-gcm:16.0.0'
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:customtabs:27.1.1'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
implementation 'com.google.code.gson:gson:2.8.2'
implementation('io.socket:socket.io-client:1.0.0') {
// excluding org.json which is provided by Android
exclude group: 'org.json', module: 'json'
}
implementation 'com.android.volley:volley:1.1.0'
testImplementation 'junit:junit:4.12'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
}
apply plugin: 'com.google.gms.google-services'
project 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.2.1'
classpath 'com.google.gms:google-services:4.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I have cleaned, rebuiled, invalidated cache an restart and everything I have seen online. I even change maven reposiroty url to 2 or 3 other but error persists. What should I do? tnx
Related
I am getting specified exception after adding .aar file to app gradle:Program type already present: android_serialport_api.SerialPort
When I try to build Debug APK it is working but When I try to build Signed APK it is giving specified exception
Below is my app-gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "XX.XX.XX"
minSdkVersion 22
targetSdkVersion 28
versionCode 27
versionName "6.6"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
useProguard true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
configurations {
all*.exclude group: 'com.squareup.okhttp3';
all*.exclude group: 'com.squareup.okio';
}
}
repositories {
maven { url "jitpack.io" }
maven { name 'glide-snapshot'; url 'oss.sonatype.org/content/repositories/snapshots' }
mavenCentral()
}
dependencies {
implementation files('libs/apache-httpcomponents-httpclient.jar')
implementation files('libs/apache-httpcomponents-httpcore.jar')
implementation files('libs/commons-codec-1.11.jar')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.journeyapps:zxing-android-embedded:3.5.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.google.android.gms:play-services-location:11.0.4'
implementation 'com.google.firebase:firebase-messaging:11.0.4'
implementation 'com.jakewharton.timber:timber:4.5.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.github.bumptech.glide:glide:4.9.0'
implementation 'me.dm7.barcodescanner:zxing:1.8.4'
implementation 'com.loopj.android:android-async-http:1.4.9'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.github.antonKozyriatskyi:CircularProgressIndicator:1.3.0'
implementation 'com.google.code.gson:gson:2.6.2'
implementation 'com.squareup.retrofit2:retrofit:2.0.2'
implementation 'com.squareup.retrofit2:converter-gson:2.0.2'
implementation 'com.android.support:recyclerview-v7:28.0.0'
//implementation group: 'org.bouncycastle', name: 'bcprov-jdk15on', version: '1.54'
implementation 'com.google.android.gms:play-services-maps:11.0.4'
/*implementation(name: 'merchantsdk', ext: 'aar')*/
/*implementation(name: 'merchantsdk', ext: 'aar'){
exclude module: 'SerialPort'
}*/
/*implementation(name: 'ezetapandroidsdk', ext: 'aar')*/
implementation project(':merchantsdk')
implementation project(':ezetapandroidsdk')
testImplementation 'junit:junit:4.12'
implementation files('libs/org.apache.commons.io.jar')
}
apply plugin: 'com.google.gms.google-services'
Below is the Project gradle file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
maven { url "https://jcenter.bintray.com"}
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:4.2.0'
}
}
allprojects {
repositories {
google()
jcenter()
maven {
url 'https://jitpack.io'
}
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Below is the exception
> Task :app:transformClassesAndResourcesWithR8ForRelease FAILED
AGPBI: {"kind":"error","text":"Program type already present: android_serialport_api.a","sources":[{}],"tool":"R8"}
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformClassesAndResourcesWithR8ForRelease'.
> com.android.tools.r8.CompilationFailedException: Compilation failed to complete
Debug apk is working fine but when I try to build signed APK giving above exception.
Please help me on this.Thanks in advance.
The issue is that you have more that one package using android_serialport_api.SerialPort.
There is 2 ways of dealing with this. The first is going through each library and checking if it's using it or you can find duplicates by running:
gradlew -q dependencies yourProject:dependencies --configuration implementation
You can also exclude it from your merchantsdk, like this:
implementation(name: 'merchantsdk', ext: 'aar'){
exclude module: 'SerialPort'
}
It's frustrating when you do all what the Android Studio suggests and still get errors with not enough of what to do. I'm revisiting a project and running on Android Studio 3.3 beta 1. After applying the suggested updates, the app gradle file looks like this:
apply plugin:'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
testOptions {
unitTests.returnDefaultValues = true
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:support-vector-drawable:28.0.0'
implementation 'com.android.support:gridlayout-v7:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:support-annotations:28.0.0'
implementation 'com.github.bumptech.glide:glide:4.4.0'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
implementation "com.google.android.gms:play-services-gcm:16.0.0"
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.google.android.gms:play-services-places:16.0.0'
testImplementation 'junit:junit:4.12'
implementation 'com.google.android.apps.muzei:muzei-api:2.0'
}
apply plugin: 'com.google.gms.google-services'
When I go to SDK Manager, everything is installed:
And in the gradle.build:
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0-alpha01'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.3.0'
}
}
What should I do? any suggestions are appreciated.
You are missing part of your top-level build.gradle file. It should resemble:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
In particular, you are missing the allprojects closure, which sets the repositories for dependency resolution in each of the modules. As a result, your module's build.gradle file does not know where to look for those dependencies.
I'm using Android Studio 2.3.3 and updated my SDK version and now I'm using API 27 but I encountered the following error:
Also I install repository and sync project but This error occurred:
This code is gradle.build (project):
// 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:2.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Also this code is gradle.build (Module:app )
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion '28.0.0'
defaultConfig {
applicationId "comp.packk.ir"
minSdkVersion 14
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:27.0.2'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha7'
testCompile 'junit:junit:4.12'
compile 'com.android.support:design:27.1.1'
}
What is the solution?
implementation or compile 'com.android.support:appcompat-v7:27.1.1'
implementation or compile 'com.android.support:cardview-v7:27.1.1'
implementation or compile 'com.android.support:design:27.1.1'
I have updated my project to latest dependencies, also changed compile to implementations and gradle plugins and i have this error
Failed to resolve: firebase-analytics Open File
Failed to resolve: play-services-tasks Open File
Failed to resolve: play-services-ads-identifier Open File
Failed to resolve: play-services-stats Open File
Failed to resolve: play-services-basement Open File
Module
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "my.id"
minSdkVersion 16
targetSdkVersion 28
versionCode 36
versionName "2.04"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
//multiDexEnabled true
}
buildTypes {
release {
debuggable false
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
debug {
}
}
productFlavors {
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation files('libs/chartboost.jar')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:percent:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.jakewharton:butterknife:8.8.1'
implementation 'com.github.polok:clicknumberpicker:0.1.2'
implementation 'com.android.volley:volley:1.0.0'
implementation 'com.kila.apprater_dialog.lars:apprater-dialog:1.0.5'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.google.firebase:firebase-core:16.0.0'
implementation 'com.google.firebase:firebase-crash:16.0.0'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-ads:15.0.1'
implementation 'com.google.firebase:firebase-messaging:17.0.0'
implementation 'com.android.billingclient:billing:1.0'
testImplementation 'junit:junit:4.12'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
}
apply plugin: 'realm-android'
apply plugin: 'com.google.gms.google-services'
Project
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:4.0.1'
classpath "io.realm:realm-gradle-plugin:3.5.0"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Tried a lot of combinations, can someone help?
I am trying run my app at emulator but I got his error:
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
This is my gradle file:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
multiDexEnabled true
applicationId "com.example.sayres.presencesystem"
minSdkVersion 16
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'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:recyclerview-v7:26.1.0'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.google.firebase:firebase-database:11.6.0'
implementation 'com.google.firebase:firebase-auth:11.6.0'
implementation 'com.firebaseui:firebase-ui-auth:3.1.0'
implementation 'com.firebaseui:firebase-ui-database:3.1.0'
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:multidex:1.0.1'
}
and this:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.google.gms:google-services:3.0.0' // google-services plugin
}
}
allprojects {
repositories {
jcenter()
maven { url 'http://maven.fabric.io/public' }
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
according some siggestion on some post I have added multiDexEnabled true to my gradle but I still got error. some developers at this site had suggested, rebuild project.I did this suggestion but I did work and I still got this error!!
what is your suggestion?
I still did this suggestion
but did not work again.
I do not have too many methods.I have just 2 activity and a few methods.my project is for learning.
I change my build.gradle to :
implementation 'com.google.firebase:firebase-database:10.2.0'
implementation 'com.google.firebase:firebase-auth:10.2.0'
implementation 'com.firebaseui:firebase-ui-auth:1.2.0'
implementation 'com.firebaseui:firebase-ui-database:1.2.0'
and
classpath 'com.google.gms:google-services:3.0.0' // google-services plugin
my problem fixed.now I can compile my project.