Weird error I have no idea how to fix - java

Does anyone know how to fix this?
I tried building my app, but I got an error that it was out of sync or something along those lines, so I searched for the error.
Found a solution that said I had to delete one of the .gradle files, so I did and then this error occurred when trying to build the app again.
I am new to android and java development and have no idea how to fix this.
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugAndroidTestApkCopy'.
> Could not find com.squareup:javawriter:2.1.1.
Required by:
JustJava:app:unspecified > com.android.support.test.espresso:espresso-core:2.2.2
> Could not find javax.inject:javax.inject:1.
Required by:
JustJava:app:unspecified > com.android.support.test.espresso:espresso-core:2.2.2
> Could not find org.hamcrest:hamcrest-library:1.3.
Required by:
JustJava:app:unspecified > com.android.support.test.espresso:espresso-core:2.2.2
> Could not find org.hamcrest:hamcrest-integration:1.3.
Required by:
JustJava:app:unspecified > com.android.support.test.espresso:espresso-core:2.2.2
> Could not find com.google.code.findbugs:jsr305:2.0.1.
Required by:
JustJava:app:unspecified > com.android.support.test.espresso:espresso-core:2.2.2
> Could not find javax.annotation:javax.annotation-api:1.2.
Required by:
JustJava:app:unspecified > com.android.support.test.espresso:espresso-core:2.2.2
> Could not find junit:junit:4.12.
Required by:
JustJava:app:unspecified > com.android.support.test.espresso:espresso-core:2.2.2 > com.android.support.test:runner:0.5
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
This is the build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.android.justjava"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
}
}
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:25.1.0'
}

Related

MongoDB "Task :app:mergeExtDexDebug FAILED"

When I try add mongodb-driver implementation to dependencies block at build.gradle I get this build error. I try downgrade and enable to enableDexEnable for solve this problem but problem is continue. I search almost internet but can not have a solution
> Task :app:mergeExtDexDebug
AGPBI: {"kind":"error","text":"Invalid build configuration. Attempt to create a global synthetic for 'Record desugaring' without a global-synthetics consumer.","sources":[{}],"tool":"D8"}
Invalid build configuration. Attempt to create a global synthetic for 'Record desugaring' without a global-synthetics consumer.
> Task :app:mergeExtDexDebug FAILED
Execution failed for task ':app:mergeExtDexDebug'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Failed to transform bson-record-codec-4.8.1.jar (org.mongodb:bson-record-codec:4.8.1) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=24, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.
> Execution failed for DexingNoClasspathTransform: C:\Users\user\.gradle\caches\modules-2\files-2.1\org.mongodb\bson-record-codec\4.8.1\339c92291f24acf896334ba9a2a5bf52fd462115\bson-record-codec-4.8.1.jar.
> Error while dexing.
* Try:
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
build.gradle page;
plugins {
id 'com.android.application'
}
android {
namespace 'com.example.appname'
compileSdk 33
defaultConfig {
applicationId "com.example.appname"
minSdk 21
multiDexEnabled true
targetSdk 33
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_11
targetCompatibility JavaVersion.VERSION_11
}
buildToolsVersion '33.0.1'
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.6.0'
implementation 'com.google.android.material:material:1.7.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'org.mongodb:mongodb-driver-sync:4.8.2' //<-mongodb here
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}

DataBinding not working when i Upgrade Android Studio 2.3

When I update android studio I have an error about dataBinding:
Error:(1, 0) android/databinding/tool/DataBindingBuilder
this is my build gradle app:
apply plugin: 'com.android.application'
dependencies {
'com.android.databinding:compiler:2.3.0'
}
android {
compileSdkVersion 25
buildToolsVersion "25.0.1"
defaultConfig {
applicationId "com.example.theodhor.retrofit2"
minSdkVersion 17
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
}
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:25.1.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.4.0'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.squareup:otto:1.3.8'
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.android.support:design:25.0.1'
testCompile 'junit:junit:4.12'
compile 'org.apache.httpcomponents:httpclient:4.5.3'
exclude module: "httpclient"
classpath 'com.android.tools.build:gradle:1.5.0-beta2'
}
I get this error:
Error:(1, 0) android/databinding/tool/DataBindingBuilder Open File
FAILURE: Build failed with an exception. * Where: Build file '/Users/marco/Downloads/Retrofit-master/app/build.gradle' line: 1 * What went wrong: A problem occurred evaluating project ':app'. > android/databinding/tool/DataBindingBuilder * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. BUILD FAILED Total time: 0.686 secs
I don't know why I have this problem.
Who can help me?
Thanks everybody!!!

Dealing with duplicate entries in AndroidStudio: java.util.zip.ZipException

EDIT: Solution from Error: java.util.zip.ZipException: duplicate entry doesn't work here, because I don't have problem with support-v4 module
I'm trying to build an Android project which uses SpongyCastle, but unfortunately it requires javax.naming package from jndi library.
I added jndi and even javaEE to make it work, but gradle still has problem with running a project (build is successful)
My gradle.build file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "grylls.cryptotexting"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'javax:javaee-api:7.0'
compile files('lib/jndi-1.2.1.jar')
}
Gradle throws this error:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.>
com.android.build.api.transform.TransformException:java.util.zip.ZipException:
duplicate entry:javax/mail/AuthenticationFailedException.class
When I tried to exclude javax.mail from javax:javaee-api:7.0 I got:
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException:
com.android.ide.common.process.ProcessException:
org.gradle.process.internal.ExecException:
Process 'command 'C:\Program Files\Java\jdk1.8.0_40\bin\java.exe'' finished with non-zero exit value 1
Where can I find this duplication of javax.mail which by the way I don't even need?
To properly include SpongyCastle I had to make a change in dependencies :
dependencies {
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.madgag.spongycastle:core:1.51.0.0'
compile 'com.madgag.spongycastle:prov:1.51.0.0'
compile 'com.madgag.spongycastle:pkix:1.51.0.0'
compile 'com.madgag.spongycastle:pg:1.51.0.0'
}
Create a class that inserts BouncyCastle Provider
import android.app.Application;
import java.security.Security;
public class Dynks extends Application {
static { Security.insertProviderAt(new org.spongycastle.jce.provider.BouncyCastleProvider(), 1); }
}
and include it in AndroidManifest.xml under "application" tag:
...
<application
android:name="Dynks"
...

Execution failed for task ':hVFhirApp:dexDebug'. > com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException:

I know that this is an error that it has been asked in a question before but I havent found any answer that suits me.
This is my gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "com.example.hvfhirapp"
minSdkVersion 16
targetSdkVersion 21
multiDexEnabled = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
configurations{
compile.exclude module: 'commons-codec'
compile.exclude module: 'javax.json'
}
dependencies {
compile project(':androidsdksimplexml')
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'ca.uhn.hapi.fhir:hapi-fhir-base:1.1'
compile 'ca.uhn.hapi.fhir:hapi-fhir-structures-dstu2:1.1'
compile 'com.android.support:multidex:1.0.1'
}
android {
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
As you can see I have entered the multiDexEnabled = true and I have also added the dependcy of MultiDex + the line in my manifest's application.
Also my exact error in the stack trace in gradle console is:
* What went wrong:
Execution failed for task ':hVFhirApp:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 1
Also what I would like to add is the fact that when I remove the excludes in my dependencies bracket the error that shows up is
* What went wrong:
Execution failed for task ':hVFhirApp:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: org/apache/commons/codec/binary/Base64.class
and that's why I exclude them
Any help would be of much appreciation.
Thank you in advance
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
Add this to your gradle and clean the entire the project and build.Still if it is not working then uninstall JAVA from your machine and reinstall again

Could not resolve org.roboguice:roboguice:3.+

this is my build.gradle file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.14.2'
}
}
apply plugin: 'com.android.application'
repositories {
jcenter()
}
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
applicationId "com.example.stopcall.app"
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:21.0.3'
compile 'org.roboguice:roboguice:3.+'
provided 'org.roboguice:roboblender:3.+'
}
I don't know why but sometimes I get this error while building:
Error:Gradle: A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
> Could not resolve org.roboguice:roboguice:3.+.
Required by:
StopCall:app:unspecified
> Failed to list versions for org.roboguice:roboguice.
> Unable to load Maven meta-data from https://jcenter.bintray.com/org/roboguice/roboguice/maven-metadata.xml.
> Could not GET 'https://jcenter.bintray.com/org/roboguice/roboguice/maven-metadata.xml'.
> cache.corp.google.com: nodename nor servname provided, or not known
> Failed to list versions for org.roboguice:roboguice.
> Unable to load Maven meta-data from https://jcenter.bintray.com/org/roboguice/roboguice/maven-metadata.xml.
> Could not GET 'https://jcenter.bintray.com/org/roboguice/roboguice/maven-metadata.xml'.
> cache.corp.google.com
> Could not resolve org.roboguice:roboblender:3.+.
Required by:
StopCall:app:unspecified
> Failed to list versions for org.roboguice:roboblender.
> Unable to load Maven meta-data from https://jcenter.bintray.com/org/roboguice/roboblender/maven-metadata.xml.
> Could not GET 'https://jcenter.bintray.com/org/roboguice/roboblender/maven-metadata.xml'.
> cache.corp.google.com
> Failed to list versions for org.roboguice:roboblender.
> Unable to load Maven meta-data from https://jcenter.bintray.com/org/roboguice/roboblender/maven-metadata.xml.
> Could not GET 'https://jcenter.bintray.com/org/roboguice/roboblender/maven-metadata.xml'.
> cache.corp.google.com
what can it be? as it can happen in a specific hour and few hours later (maybe another network) it might be fixed.
any idea?
Are you behind a proxy?
if so check your gradle properties file
Under C:\Users\.gradle\ create a gradle.properties file with the proxy details:
systemProp.http.proxyHost=hostname
systemProp.http.proxyPort=8080
systemProp.http.proxyUser=username
systemProp.http.proxyPassword=xxx
systemProp.https.proxyHost=hostname
systemProp.https.proxyPort=8080
systemProp.https.proxyUser=username
systemProp.https.proxyPassword=password
systemProp.https.nonProxyHosts=localhost

Categories

Resources