I upgraded android studio to the version 3.0.1. Whenever i try to launch my app the gradle build fails and gives me the following error:
Error:Execution failed for task
':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge
dex
I tried every solution possible mentioned in stack overflow but nothing is helping me out.
-Whenever i clean project no error occurs but when i rebuild the project the error come back again.
-I deleted the .gradle file and build file
-I changed from compile to implementation
-I upgraded from 10.2.1 to 11.4.2 for firebase dependencies but it gives me more error such as UNABLE TO RESOLVE DEPENDENCY
-I enabled dex but again it comes up with more errors.
-I enabled the google play services which has the version 46
I searched everthing possible but i am unable to solve this issue.
Please help me out of it as all my work is stuck.
Any help is appreciated!
build.gradle(Project)
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com'
}}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:3.0.0'
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle(Module)
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "studentapp.notefi"
minSdkVersion 17
targetSdkVersion 24
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(dir: 'libs', include: ['*.jar'])
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:24.1.1'
implementation 'com.android.support:design:24.1.1'
implementation 'com.android.support:support-v4:24.1.1'
implementation 'com.android.support:recyclerview-v7:24.1.1'
implementation 'com.android.support:cardview-v7:24.1.1'
implementation 'com.google.firebase:firebase-messaging:10.2.1'
implementation 'com.google.firebase:firebase-database:10.2.1'
implementation 'com.google.firebase:firebase-storage:10.2.1'
implementation 'com.google.firebase:firebase-auth:10.2.1'
implementation 'com.firebaseui:firebase-ui-database:0.4.0'
implementation 'com.github.barteksc:android-pdf-viewer:2.7.0'
implementation 'org.apache.commons:commons-io:1.3.2'
implementation 'com.google.firebase:firebase-crash:10.2.1'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.4.6'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.android.volley:volley:1.0.0'
implementation 'com.squareup.okhttp3:okhttp:3.2.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
Please remove this line:
task clean(type: Delete) {
delete rootProject.buildDir
}
Rest i checked its working fine, i mean it successfully build.
EDITED:
use this code "com.google.android.gms:play-services:11.4.0" instead of "com.google.gms.google-services". and then clean and rebuild
Related
I an trying to import Ksoap2 library in android studio using .jar file version 3.6.4. I have successfully implemented the jar file to android studio. However, on the module app activity when I try to import e.g. import "org.ksoap2.SoapEnvelope;", it gets and error it shows following results:
Execution failed for task ':app:checkDebugAarMetadata'.
Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
Could not find com.google.code.ksoap2-android:ksoap2-android:3.6.4.
Searched in the following locations:
- https://repo.maven.apache.org/maven2/com/google/code/ksoap2-android/ksoap2-android/3.6.4/ksoap2-android-3.6.4.pom
- https://dl.google.com/dl/android/maven2/com/google/code/ksoap2-android/ksoap2-android/3.6.4/ksoap2-android-3.6.4.pom
- https://jcenter.bintray.com/com/google/code/ksoap2-android/ksoap2-android/3.6.4/ksoap2-android-3.6.4.pom
Required by:
project :app
Possible solution:
Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
Also the imports library have error, please see the pic:
Here is the Build.gradle module code:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.1"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenCentral()
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Here is Build.gradle(app) Module code:
plugins {
id 'com.android.application'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.kowloondairycompanykdl.milk_ic"
minSdkVersion 27
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
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation files('libs\\ksoap2-android-assembly-3.6.4.jar')
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.code.ksoap2-android:ksoap2-android:3.6.4'
}
Please help me, I been stuck here for a long time. How to fix the error and how can I implement the Ksoap2 library properly. Thanks
There doesn't seem to be a 3.4.3 version of that library. There's a 3.4.0. And the newest is 3.6.4. You're going to need to use one of those. I'd move to 3.6.4 as 3.4.0 is over 5 years old, and likely lacks security updates.
Remove the dependencyResolutionManagement block from the setting.gradle file to have your project work the old way.
Related issue: Build was configured to prefer settings repositories over project repositories but repository 'maven' was added by build file 'build.gradle'
I've been going at this for a while now, and it's driving me insane. I've looked through a few existing Stack Overflow questions, but nothing has worked. I keep getting this error whenever I add the last line, which I need for my AdMob ad units. People seem to solve this issue by changing the version number for this line to 15.0.0, but, as you can see, I've already done this. Please help, if you can. Also, this isn't even the first time I've worked with ad units.
Build.gradle (App level)
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.coincalc.anduril.sharetale"
minSdkVersion 17
targetSdkVersion 26
versionCode 2
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
lintOptions {
abortOnError false
}
}
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'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support:support-vector-drawable:26.1.0'
implementation 'com.google.firebase:firebase-database:12.0.1'
implementation 'com.google.firebase:firebase-auth:12.0.1'
implementation 'com.android.support:support-v4:26.1.0'
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'
compile 'com.google.firebase:firebase-core:12.0.1'
implementation 'com.google.android.gms:play-services-ads:15.0.0'
}
apply plugin: 'com.google.gms.google-services'
Build.gradle (Project level)
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.google.gms:google-services:3.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Update the following classpath dependency in your top-level build.gradle:
classpath 'com.google.gms:google-services:4.0.1'
Only newer versions of this plugin understand that the new Firebase dependencies no longer all have to be at the same version.
Read this for more information.
Upgrade your firebase dependencies to latest version, by changing your dependencies to this:
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-auth:16.0.2'
implementation 'com. google.firebase:firebase-core:16.0.1'
And in your project level Gradle file, increment your Google services plugin to 4.0.0
Change this:
implementation 'com.google.firebase:firebase-database:12.0.1'
implementation 'com.google.firebase:firebase-auth:12.0.1'
compile 'com.google.firebase:firebase-core:12.0.1'
into this:
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-auth:16.0.2'
implementation 'com.google.firebase:firebase-core:16.0.1'
Check this for more info:
https://firebase.google.com/support/release-notes/android
I am attempting to generate an apk to install to a device. I was able to do this with the same project prior to Android Studio version 3.0.0. I cannot post any error logs because the apk generates successfully, but when I try to install it on a device I get "App not installed", "File appears to be corrupt". I have been through a number of other threads to try and fix this but nothing has worked so far.
The previous version on the phone has been uninstalled.
Both Signed and unsigned have been tried.
Instant run has been disabled.
The apk has failed to install on at least 3 different devices.
I have tried downgrading my com.android.tools.build:gradle
Any help would be greatly appreciated, I feel like I've tried everything.
build.gradle (app):
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.example.will3596.mobileapplication"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/assets/'] } }
}
dependencies {
implementation 'com.android.support:support-vector-drawable:26.1.0'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
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:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.firebase:firebase-core:11.6.2'
compile 'com.google.firebase:firebase-auth:11.6.2'
compile 'com.google.firebase:firebase-database:11.6.2'
compile 'com.google.android.gms:play-services-maps:11.6.2'
compile 'com.google.android.gms:play-services-location:11.6.2'
compile 'com.google.firebase:firebase-storage:11.6.2'
compile 'com.android.support:palette-v7:26.+'
compile 'com.android.support:customtabs:26.+'
compile 'com.android.support:design:26.+'
compile 'com.android.support:cardview-v7:26.+'
compile 'com.android.support:mediarouter-v7:26.+'
compile 'com.android.support:multidex:1.0.2'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.google.maps.android:android-maps-utils:0.4+'
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:2.7.22'
androidTestCompile 'com.android.support:support-annotations:24.0.0'
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'
}
apply plugin: 'com.google.gms.google-services'
build.gradle (project):
// 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.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 {
jcenter()
maven{
url "https://maven.google.com"
}
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Let me know what else I can post to help get a solution.
Steps to generate debug apk from 3.0.0+
Build->Build APK(s).
I found the answer in another thread somewhere. In my android manifest, I had testOnly="true", set to false and it fixed.
I've looked at Firebase documentation, then searched all github issues and also all stack overflow posts but still I'm getting this error again and again. I've been stuck for hours, please have a look. It says-
java.lang.NoSuchMethodError: No static method zzb(ZLjava/lang/Object;)V in class Lcom/google/android/gms/common/internal/zzaa; or its super classes (declaration of 'com.google.android.gms.common.internal.zzaa' appears in /data/app/com.masquerade.priyanshu.topcoder-2/split_lib_dependencies_apk.apk)
According to other stack overflow posts when i try to change firebase core and database version, i get another bunch of errors saying incompatible version.
This is build.gradle( Module: app)
apply plugin: 'com.android.application'
repositories {
mavenLocal()
flatDir {
dirs 'libs'
}
}
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.masquerade.priyanshu.topcoder"
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 {
implementation fileTree(dir: 'libs', include: ['*.jar'])
// implementation 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:design: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'
//
compile 'com.google.firebase:firebase-core:11.6.0'
compile 'com.android.support:design:26.1.0'
compile 'com.google.firebase:firebase-database:11.6.0'
compile 'com.firebaseui:firebase-ui-storage:1.0.0'
// Displaying images
compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'com.android.support:cardview-v7:21.+'
}
apply plugin: 'com.google.gms.google-services'
This is build.gradle( Project:app ) -
// 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.0.0'
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()
mavenLocal()
maven {
url 'https://maven.fabric.io/public'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
EDIT -
Also I'm getting this warning on compile 'com.google.firebase:firebase-core:11.6.0'
The warning is -
All gms/firebase libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 11.6.0, 11.4.2. Examples include com.google.android.gms:play-services-basement:11.6.0 and com.google.firebase:firebase-storage:11.4.
To solve this, please the change the following line of code from your build.gradle( Project:app ) file:
url 'https://maven.fabric.io/public'
with
url "https://maven.google.com" // Google's Maven repository
Change also this line of code:
compile 'com.firebaseui:firebase-ui-storage:1.0.0'
with
compile 'com.firebaseui:firebase-ui-storage:3.1.0'
Change also this lines of code:
compile 'com.google.firebase:firebase-core:11.6.0'
compile 'com.google.firebase:firebase-database:11.6.0'
with
compile 'com.google.firebase:firebase-core:11.4.2'
compile 'com.google.firebase:firebase-database:11.4.2'
Because Firebase/Play Services Version 11.4.2works with FirebaseUI Version 3.1.0 as seen here.
Also set multiDexEnabled to true in default config.
I am getting the following error when trying to compile the project:
error: package lombok does not exist
And others stating that all the annotations from it can't be found.
I don't see errors in code before compiling and I didn't have this error while I was using Android Studio 3 RC1.
Here are my gradle scripts:
Project level:
// 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.0.0-rc2'
// 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
}
App module level:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.mk.forum"
minSdkVersion 25
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
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'
compile project (':util')
compile project (':forum_core')
compileOnly 'org.projectlombok:lombok:1.16.18'
annotationProcessor 'org.projectlombok:lombok:1.16.18'
compile group: 'com.github.javafaker', name: 'javafaker', version: '0.13'
}
I've got modules too, but I think it isn't important.
I hope it is because of compileOnly annotation. Here is the doc:
blog.gradle.org/introducing-compile-only-dependencies
Dependencies required at compile time but never required at runtime, such as source-only annotations or annotation processors;
Dependencies required at compile time but required at runtime only when using certain features, a.k.a. optional dependencies;
Dependencies whose API is required at compile time but whose implementation is to be provided by a consuming library, application
or runtime environment.
It might be related to jdk9. I know that the combination of IntelliJ, lombok 1.16.18 and jdk9 currently doesn't work. But that does not explain your error message. We expect that we can release 1.16.20 within a few days (maybe tonight) that addresses this problem.
Disclosure: I am a lombok developer.