How to fix dependency issues in AndroidStudio? - android

I just clones an android project from my local repo and I have trouble to 'build' it. Maybe it missed some external library, but I do not know.
Upon starting a grade build I get the following message:
Error:A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugApk'.
> Configuration with name 'default' not found.
I tried to check the 'Manifest' file, but I can't find it. I am completely lost...
I am pretty sure this is a configuration error, therefore all the config files I can find here:
build.gradle (project)
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle (app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.impyiablue.myapp"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
preDexLibraries = false
}
}
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.1.0'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.google.firebase:firebase-ads:9.0.0'
compile 'in.srain.cube:grid-view-with-header-footer:1.0.12'
compile 'com.github.paolorotolo:appintro:4.1.0'
compile project(path: ':LibraryModule')
}
apply plugin: 'com.google.gms.google-services'
cradle-wrapper.properties
#Wed Sep 07 20:03:05 CEST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
settings.gradle:
include ':app'
include ':libraries:volley'
include ':LibraryModule'
project(':LibraryModule').projectDir = new File('/Users/adietz/AndroidStudioProjects/LIBS')
local.properties:
## This file is automatically generated by Android Studio.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Sun Oct 15 11:07:25 CEST 2017
sdk.dir=/Users/adietz/Library/Android/sdk
The output of ./gradlew build (from inside the project folder) is the following:
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.gradle.internal.reflect.JavaMethod (file:/Users/adietz/.gradle/wrapper/dists/gradle-2.14.1-all/4cj8p00t3e5ni9e8iofg8ghvk7/gradle-2.14.1/lib/gradle-base-services-2.14.1.jar) to method java.lang.ClassLoader.getPackages()
WARNING: Please consider reporting this to the maintainers of org.gradle.internal.reflect.JavaMethod
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Failed to notify project evaluation listener.
> javax/xml/bind/annotation/XmlSchema
* 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: 7.217 secs

Part of the solution seems to be a change in the file build.gradle (for Module:app). If you replace this line
compile project(path: ':LibraryModule')
with this line:
compile project(':libraries:volley')
and do 'Clean Project again', different things might happen:
AndroidStudio start to download stuff
Other gradle files appear mysteriously in your Gradle Scripts folder
Other errors appear (which you can google and actually find some helpful answers)
But it might fix the actual problem...

Related

I implemented VirtualAPK library and getting Execution failed for task ':app:compileDebugJavaWithJavac'

I am implemented VirtualAPK library and failed to build project
My Project gradle file:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'com.didi.virtualapk:gradle:0.9.8.6'
// 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
}
Also I implemented library and applied as per library guide in Module gradle:
apply plugin: 'com.android.application'
apply plugin: 'com.didi.virtualapk.host'
android {
compileSdkVersion 28
dataBinding {
enabled = true
}
defaultConfig {
applicationId "com.example.vspace"
minSdkVersion 19
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'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.didi.virtualapk:core:0.9.8'
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'
}
And after that I am trying to build project and getting Error like():
Compiling with JDK Java compiler API.
Created classpath snapshot for incremental compilation in 0.024 secs.
[INFO][VAHostPlugin] Used compileClasspath: debug
> Task :app:compileDebugJavaWithJavac FAILED
:app:compileDebugJavaWithJavac (Thread[Daemon worker,5,main]) completed. Took 2.586 secs.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> java.lang.NoSuchMethodException: No similar method computeBuildMapping with params [class org.gradle.invocation.DefaultGradle_Decorated] could be found on type class com.android.build.gradle.internal.ide.ModelBuilder.
* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
I was also tried to downgrade and upgrade gradle version and also tried with old Android Studio 3.0.1 and with 3.4.1. But nothing is working here. So, if any one can help then its surely acceptable.
I also refers This question but its can't helped me.
VirtualApk is doing this.....and computeBuildMapping is not supported(based on error in your post) in gradle 3.4.1.
if (project.extensions.extraProperties.get(Constants.GRADLE_3_1_0)) {
ImmutableMap<String, String> buildMapping = Reflect.on('com.android.build.gradle.internal.ide.ModelBuilder')
.call('computeBuildMapping', project.gradle)
.get()
compileArtifacts = ArtifactDependencyGraph.getAllArtifacts(
applicationVariant.variantData.scope, AndroidArtifacts.ConsumedConfigType.COMPILE_CLASSPATH, null, buildMapping)
} else {
compileArtifacts = ArtifactDependencyGraph.getAllArtifacts(
applicationVariant.variantData.scope, AndroidArtifacts.ConsumedConfigType.COMPILE_CLASSPATH, null)
}
so, try building your project with gradle plugin 3.1.0 and gradle version 4.4
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

Could not resolve com.android.tools.build:gradle:3.3.2

I was trying to add firebase auth to my android project but getting this error.
I have tried adding 'com.google.firebase:firebase-core:16.0.3' too but its taking more than 40 mins and still not syncing the gradle.
This is build.gradle file:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 28
defaultConfig {
applicationId "myaid.startup"
minSdkVersion 21
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'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.firebase:firebase-auth:16.0.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'
}
This is app.gradle file:
// 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.3.2'
classpath 'com.google.gms:google-services:4.1.0'
// 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
}
This is the error:
FAILURE: Build failed with an exception.
What went wrong: A problem occurred configuring root project 'MyAid'.
Could not resolve all artifacts for configuration ':classpath'.
Could not resolve com.android.tools.build:gradle:3.3.2.
Required by:
project :
Could not resolve com.android.tools.build:gradle:3.3.2.
Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.3.2/gradle-3.3.2.pom'.
Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.3.2/gradle-3.3.2.pom'.
Connection reset
Could not resolve com.android.tools.build:gradle:3.3.2.
Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.3.2/gradle-3.3.2.pom'.
Could not GET 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.3.2/gradle-3.3.2.pom'.
Connection reset
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
CONFIGURE FAILED in 2m 13s ERROR: Connection reset
I have resolved this problem by removing all my .gradle files, SDK files, .m2 files, .androidstudio files and then re-installing it.
Followed this answer: How to completely uninstall Android Studio
Please check your gradle's proxy settings. Enable it or disable it in the following file:
~/.gradle/gradle.properties
Like:
systemProp.https.proxyPort=1080
systemProp.http.proxyHost=127.0.0.1
systemProp.https.proxyHost=127.0.0.1
systemProp.http.proxyPort=1080
Advices:
If your connection to repositories is not stable, use a proxy
instead of direct connection.
If you used to use a proxy for
gradle, check if it is still working.

Android: how to Fix Gradle execution error?

I have Android Studio installed on my PC and it has been working fine. I just opened up Android Studio (v2.3.2) and now my projects won't build/sync.
Error message says Gradle project sync failed. Failed to complete
Gradle execution. Cause: CreateProcess error=2, The system cannot
find the file specified.
Not sure if this has anything to do with it, but the error occurred after I loaded a Samsung USB Driver onto my computer so that I can connect my Samsung device to Android Studio for testing my projects. Any ideas how to get back up and running again?
Here is additional error message:
Error: Unable to start the daemon process.
This problem might be caused by incorrect configuration of the daemon.
For example, an unrecognized jvm option is used.
Please refer to the user guide chapter on the daemon at https://docs.gradle.org/3.3/userguide/gradle_daemon.html
Please read the following process output to find out more:
Error: could not open `C:\Program Files\Java\jre1.8.0_131\lib\amd64\jvm.cfg'
And the setting in Android Studio for File \ Other Settings \ Default Project Structure \ JDK location: is set to "Use embedded JDK" which is at: C:\Program Files\Android\Android Studio\jre".
Gradle info.:
build.gradle (Project)
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle (Module: app)
defaultConfig {
applicationId "com.example.jdw.v060B"
minSdkVersion 14
targetSdkVersion 25
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:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
}
Have you check your gradle-wrapper.properties, check there distribution url must be greater than 3.0 or you use this
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip

Gradle exists with non-zero value

I'm working on an Adnroid app that was imported. The imported app used an old version of Gradle so I'm trying to sync it to the new ones (it used Gradle 19 I think). I'm unable to use Gradle 24 b/c there are symbol class finders that can't be found, so I'm just trying to get this working with 21, but it still won't work. Can anyone help?
Here is my outer .build file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.3'
}
}
allprojects {
repositories {
mavenCentral()
// maven { url 'http://clinker.47deg.com/nexus/content/groups/public' }
// maven { url 'http://repo1.maven.org/maven2' }
}
}
Here is my inner .build file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.0.0"
defaultConfig {
minSdkVersion 16
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:21.0.0'
compile 'com.android.support:appcompat-v7:21.0.0'
// compile "com.android.support:support-core-utils:21.0.0"
compile 'com.j256.ormlite:ormlite-core:4.48'
compile 'com.j256.ormlite:ormlite-android:4.48'
compile 'se.emilsjolander:stickylistheaders:2.5.2'
compile 'com.github.chrisbanes.photoview:library:1.2.2'
compile 'com.loopj.android:android-async-http:1.4.6'
compile 'com.google.android.gms:play-services:6.1.71'
}
When I run this on an physical android I get this error:
Executing tasks: [:leafsnap:clean, :leafsnap:generateDebugSources, :leafsnap:generateDebugAndroidTestSources, :leafsnap:mockableAndroidJar, :leafsnap:prepareDebugUnitTestDependencies, :leafsnap:assembleDebug]
Configuration on demand is an incubating feature.
Observed package id 'add-ons;addon-google_apis-google-24' in inconsistent location 'C:\Users\Butters Stotch\AppData\Local\Android\Sdk\add-ons\addon-google_apis-google-24-1' (Expected 'C:\Users\Butters Stotch\AppData\Local\Android\Sdk\add-ons\addon-google_apis-google-24')
Already observed package id 'add-ons;addon-google_apis-google-24' in 'C:\Users\Butters Stotch\AppData\Local\Android\Sdk\add-ons\addon-google_apis-google-24'. Skipping duplicate at 'C:\Users\Butters Stotch\AppData\Local\Android\Sdk\add-ons\addon-google_apis-google-24-1'
Incremental java compilation is an incubating feature.
:leafsnap:clean
:leafsnap:preBuild UP-TO-DATE
:leafsnap:preDebugBuild UP-TO-DATE
:leafsnap:checkDebugManifest
:leafsnap:preReleaseBuild UP-TO-DATE
:leafsnap:prepareComAndroidSupportAppcompatV72100Library
:leafsnap:prepareComAndroidSupportSupportV42100Library
:leafsnap:prepareComGoogleAndroidGmsPlayServices6171Library
:leafsnap:prepareSeEmilsjolanderStickylistheaders252Library
:leafsnap:prepareDebugDependencies
:leafsnap:compileDebugAidl
:leafsnap:compileDebugRenderscript
:leafsnap:generateDebugBuildConfig
:leafsnap:mergeDebugShaders
:leafsnap:compileDebugShaders
:leafsnap:generateDebugAssets
:leafsnap:mergeDebugAssets
:leafsnap:generateDebugResValues UP-TO-DATE
:leafsnap:generateDebugResources
:leafsnap:mergeDebugResources
:leafsnap:processDebugManifest
:leafsnap:processDebugResources FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':leafsnap:processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\Butters Stotch\AppData\Local\Android\Sdk\build-tools\21.0.0\aapt.exe'' finished with non-zero exit value -1073741819
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
I can't figure out what's wrong with it. Can anyone help?
dependencies {
classpath 'com.android.tools.build:gradle:2.1.3'
}
You're using gradle plugin 2.1.3 which according to documentation needs the following as must have dependencies.
Android Plugin for Gradle, Revision 2.1.3 (August 2016)
Dependencies:
Gradle 2.14.1 or higher.
Build Tools 23.0.2 or higher.
This update adds compatibility with Gradle 2.14.1, which includes performance improvements, new features, and an important security fix.
For more details, see the Gradle release notes.
whereas your build tool version currently set as buildToolsVersion "21.0.0".
Change the build tool version to 23.0.2, update the support and appcompat dependencies accordingly and sync again.

"Task 'compile' is ambiguous in root project" - Android Studio

Every time I try to run my project, clean it or build it I get a gradle error:
Error:FAILURE: Build failed with an exception.
* What went wrong:
Task 'compile' is ambiguous in root project 'FifiFun2'. Candidates are: 'compileDebugAidl', 'compileDebugAndroidTestAidl', 'compileDebugAndroidTestJavaWithJavac', 'compileDebugAndroidTestNdk', 'compileDebugAndroidTestRenderscript', 'compileDebugAndroidTestSources', 'compileDebugJavaWithJavac', 'compileDebugNdk', 'compileDebugRenderscript', 'compileDebugSources', 'compileDebugUnitTestJavaWithJavac', 'compileDebugUnitTestSources', 'compileLint', 'compileReleaseAidl', 'compileReleaseJavaWithJavac', 'compileReleaseNdk', 'compileReleaseRenderscript', 'compileReleaseSources', 'compileReleaseUnitTestJavaWithJavac', 'compileReleaseUnitTestSources'.
* Try:
Run gradle tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
I have tried running gradle tasks with the options above (stacktrace,info,debug) but nothing helpful came up.
gradle:
// 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:1.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
main gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.example.user_pc.myapplication"
minSdkVersion 19
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.0.1'
}
settings.gradle file:
include ':app'
Screenshot of the problem:
The problem is, your gradlew file is in the root of your project and you are trying to run an ambiguous task compile from the root of the project, in which the compiler does not know the actual task to run, this will lead to TaskSelectionException. You can run a single task, this stackoverflow question will help you
Check the following :
Can you build and run another project? (New one for instance).
Try defining a debug buildType and resync gradle then build.
Check if you have a good proyect structure or set it in gradle.build if you don't.
If non of thoses work am out of ideas, sorry.
Remove the code
task clean(type: Delete) {
delete rootProject.buildDir
}
from your gradle file, then clean and rebuild your project.
None of the above worked for me. The solution I found was
Install latest version of Cordova.
Install latest version of gradle. You can do this Manually. Remember to updated GRADLE_HOME and PATH in System variables
Remove and reinstall android in your project. Remember to back up items such as Icons etc
Run cordova build android --prod --release. This will generate an App bundle instead of an APK file. This command will also hopefully download the latest version of gradle for your project.
Hope that helps some poor soul somewhere who is at their wits end.
You need to clean the project(Top level menu Build --> Clean Project) first and then run the command again.

Categories

Resources