Fixing A Run Time Error for An Android Program - android

when I was trying to run a simple program , I got an error related to Gradle :
Error:A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration':app:_debugUnitTestCompile'.
> Could not resolve junit:junit:4.12.
Required by:
MyApplication:app:unspecified
> Could not resolve junit:junit:4.12.
> Could not get resource 'https://jcenter.bintray.com/junit/junit/4.12/junit-4.12.pom'.
> Could not GET 'htps://jcenter.bintray.com/junit/junit/4.12/junit-4.12.pom'.
> Connection to htps://jcenter.bintray.com refused .
I don't know how can I fix it , please help .( I am currently using the android studio version 2.1.2 )
my module build-gradle includes these codes:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.example.n5110.myapplication"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:design:23.3.0'
}

The problematic part with your gralde.build is this line:
testCompile 'junit:junit:4.12'
This is a unit testing library. If you are just starting and are probably not gonna write testcases for your project then, you can resolve the issue by simply deleting the line. If however you essentially need that library then refer here.

Related

Issue in making APK file in Android studio

I'm working on my very first android application which is almost complete now and ready to post on play store. But I'm unable to make the APK file :(
I'm using Android Studio 3.0.1
gradle-4.1
When I tried to make the APK file I got the error:
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
which was quickly resolved by adding multiDexEnabled true to
app/build.gradle
file. But after adding this I'm now getting another error:
Error:Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
> java.io.IOException: Can't write [D:\My Data\Android\1stApplicationTest\app\build\intermediates\multi-dex\debug\componentClasses.jar] (Can't read [C:\Users\USER_NAME\.gradle\caches\transforms-1\files-1.1\support-media-compat-26.0.2.aar\d7c069de85684fc017734fd1ac5ba973\jars\classes.jar(;;;;;;**.class)] (Duplicate zip entry [classes.jar:android/support/v4/media/VolumeProviderCompat.class]))
I'm unable to resolve this issue I tried number of solutions
updated all the jars version as per build/sdk version of the application
Removed duplicate/extra dependencies, if any
Removed Build folders from root and inside of app folder
In Android Studio File -> Invalidate Caches/Restart
Restarted Android studio with the clean build, also removed extra jars in .idea folder
Please advise if i need to remvoe something from the SDK: C:\Users\USER_NAME\AppData\Local\Android\sdk
Here is app/build.gradle file of my application
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId 'Shah.Jee'
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:26.0.2'
/*
compile files('libs/android-support-v4.jar')
compile 'com.android.support:support-v4:26.0.2'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:26.0.2'*/
compile 'commons-lang:commons-lang:2.6'
compile 'com.github.bumptech.glide:glide:4.2.0'
compile 'com.google.android.exoplayer:exoplayer:r2.4.0'
compile 'com.google.android.exoplayer:exoplayer-core:r2.4.0'
compile 'com.google.android.exoplayer:exoplayer-dash:r2.4.0'
compile 'com.google.android.exoplayer:exoplayer-hls:r2.4.0'
compile 'com.google.android.exoplayer:exoplayer-smoothstreaming:r2.4.0'
compile 'com.google.android.exoplayer:exoplayer-ui:r2.4.0'
testCompile 'junit:junit:4.12'
compile project(':picasso-2.5.2')
}
Need a quick advise if I'm missing something. Thanks in advance.

DexArchiveBuilderException

I know that this question is already asked but the solutions provided there are not working for me and i can't risk the build with d8 compiler. Here is the error:
Error:Execution failed for task ':app:transformClassesWithDexBuilderForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.dexing.DexArchiveBuilderException: com.android.builder.dexing.DexArchiveBuilderException: Failed to process E:\suv\Projects\SoundRecorder\ImageFetcher\app\build\intermediates\classes\debug
Error:com.android.builder.dexing.DexArchiveBuilderException: Failed to process E:\suv\Projects\SoundRecorder\ImageFetcher\app\build\intermediates\classes\debug
Error:com.android.builder.dexing.DexArchiveBuilderException: Error while dexing Services/MyFirebaseInstanceIDService.class
Error:com.android.dx.cf.iface.ParseException: class name (services/MyFirebaseInstanceIDService) does not match path (Services/MyFirebaseInstanceIDService.class)
Gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "ops.com.imagefetcher"
minSdkVersion 15
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'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-messaging:11.0.4'
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'
}
apply plugin: 'com.google.gms.google-services'
Please help me to fix this issue.
Edit: While trying to fix it I did "clean project" and one more error came out:
Error:Execution failed for task ':app:clean'.
> Unable to delete directory: E:\suv\Projects\SoundRecorder\ImageFetcher\app\build\intermediates\classes\debug
After doing clean build i got error:
execution failed for task ':app:clean'.
> Unable to delete directory: E:\suv\Projects\SoundRecorder\ImageFetcher\app\build\intermediates\classes\debug
Then I tried to delete the package manually from android studio but it showed some IOException error. Then what i did is: I closed the android studio and manually deleted the debug folder from "MyComputer/ThisPC" by following the path from error. After this fix, android studio successfully created the build.
The casing in your path doesn't match:
services/MyFirebaseInstanceIDService
Services/MyFirebaseInstanceIDService.class
in gradle
android {
compileSdkVersion 26
defaultConfig {
multiDexEnabled true
}
}

error: cannot find symbol class Android Studio

This error hapens after update mac osx or system (I don't know).
It was after I open project that I closed one weak ago.
My settings.gradles is:
include ':app' , ':api', ':daogenerator'
project(':mobilneapi').projectDir = new File("/Users/AndroidstudioProjects/Modules/api")
project(':daogenerator').projectDir = new File("/Users/AndroidstudioProjects/Modules/daogenerator")
And my app gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "pl.wm.myapplication"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':api')
compile project(':daogenerator')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.1'
}
When I add import into MainActivity in Main Project.
I have got error after compile:
Error:(6, 24) error: cannot find symbol class Cache
What was wrong?
The same error on gradle build tools 1.3.0 and 1.2.4
try the usual stuff:
rebuild/clean project.
sync project with gradle files.
force close studio64.exe and restart it
restart the computer!
I hate these kind of errors, when nothing works, I usually end up creating a new project and start copying everything to it.

build.gradle file error in android studio

I've tried to add a library to android studio
https://github.com/nostra13/Android-Universal-Image-Loader/wiki/Quick-Setup
and after compiling I get the
Error:A problem occurred configuring project ':app'.
Could not resolve all dependencies for configuration ':app:_debugCompile'.
Could not find com.android.support:appcombat-v7:22.2.0.
Searched in the following locations:
https://jcenter.bintray.com/com/android/support/appcombat-v7/22.2.0/appcombat-v7-22.2.0.pom
https://jcenter.bintray.com/com/android/support/appcombat-v7/22.2.0/appcombat-v7-22.2.0.jar
file:/Users/sergiumereuta/Library/Android/sdk/extras/android/m2repository/com/android/support/appcombat-v7/22.2.0/appcombat-v7-22.2.0.pom
file:/Users/sergiumereuta/Library/Android/sdk/extras/android/m2repository/com/android/support/appcombat-v7/22.2.0/appcombat-v7-22.2.0.jar
file:/Users/sergiumereuta/Library/Android/sdk/extras/google/m2repository/com/android/support/appcombat-v7/22.2.0/appcombat-v7-22.2.0.pom
file:/Users/sergiumereuta/Library/Android/sdk/extras/google/m2repository/com/android/support/appcombat-v7/22.2.0/appcombat-v7-22.2.0.jar
Required by:
XMLParsingTest:app:unspecified
can anybody help me to solve the problem? thanks!
here is my build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.0.1"
defaultConfig {
applicationId "com.example.sergiumereuta.xmlparsingtest"
minSdkVersion 8
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcombat-v7:22.2.0'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.4'
}
You have a Typo. Replace your app compact dependency for:
compile 'com.android.support:appcompat-v7:22.2.0'
Should be appcompat and not appcombat
Try Cleaning the project and Rebuilding it again.
In Build => Clean Project then
Rebuilt Project.
Then sync again.
It should work, reply if problem continue
Ya Sandro Machado is correct .
You should replace appcombat to appcompat

Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'

I am getting an ':app:packageAllDebugClassesForMultiDex' Error when I try to build an application using the YouTubeData API. I have researched several other threads that cover this error and the conclusion that I have come to is that I have libraries in my build file that are creating a duplicated reference to build files. I know that the file triggering the error is:
'com/google/api/client/googleapis/json/GoogleJsonErrorContainer.class'
but how do I exclude the reference from the build file with out removing the entire library?
This is my build file
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "co.hannalupi.fitnessblenderapp"
minSdkVersion 16
targetSdkVersion 21
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:multidex:1.0.0'
compile 'com.android.support:appcompat-v7:22.0.0'
compile files('libs/YouTubeAndroidPlayerApi.jar')
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.google.apis:google-api-services-youtube:v3-rev136-1.20.0'
}
This is the error I get:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: com/google/api/client/googleapis/json/GoogleJsonErrorContainer.class
I am new to Android, any direction you can point me in would be greatly appreciated. Thanks in advance.
An update for folks having a similar error - As a last resort I deleted the project file that I was working in from my desktop and cloned a fresh copy from GitHub. Importing and running the fresh copy gave me no errors!!

Categories

Resources