I downloaded Android Studio for the first time and encountered a problem:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
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.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.1'
testCompile 'junit:junit:4.12'
On a another dock appeared:
ERROR: Failed to resolve: com.android.support.constraint:constraint-layout:1.0.1
Show in Project Structure dialog
Affected Modules: app
Where and how can I resolved the issue?
I believe the error is with constraint-layout:1.0.1 but I can't seem to find solution else where.
You should connect to internet and sync project with gradle and gradle will download neccessary files.if you have problem to connect to the internet to download gradle, you can set http proxy this way :
File->Settings->search for Proxy->select Manual proxy configuration->HTTP
Host name:[yourHost] Port number:[yourPort]
you need to change the Host name to the proxy you use
ERROR: Failed to resolve: com.android.support.constraint:constraint-layout:1.0.1 Show in Project Structure dialog Affected Modules: app
It's probably because incompatibility with the recent Android Studio. You can try using version 1.0.2 with:
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
don't forget to add the google() maven to your build.gradle.
See the artifacts at https://mvnrepository.com/artifact/com.android.support.constraint/constraint-layout
But, you should consider upgrading your project to AndroidX. See Migrating to AndroidX.
Related
I have installed play services in sdk tools and added following libs though it shows the problem
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.firebase:geofire-android:2.1.1'
compile 'com.google.gms.google-services:15.0.1'
compile 'com.google.android.gms:play-services-maps:15.0.1'
compile 'com.google.android.gms:play-services-drive:15.0.1'
compile 'com.github.bumptech.glide:glide:4.0.0'
compile 'com.android.support:design:26.1.0'
compile 'com.android.support:cardview-v7:26.1.0'
compile 'com.github.jd-alexander:library:1.1.0'
compile 'com.paypal.sdk:paypal-android-sdk:2.15.3'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
Remove com.google.gms.google-services:15.0.1 from dependencies, that is a gradle file plugin not an dependency.
def mySupportVersion = "26.1.0"
dependencies {
compile "com.android.support:appcompat-v7:$mySupportVersion"
compile "com.android.support:design:$mySupportVersion"
compile "com.android.support:cardview-v7:$mySupportVersion"
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.firebase:geofire-android:2.1.1'
compile "com.google.android.gms:play-services-maps:15.0.1"
compile "com.google.android.gms:play-services-drive:15.0.1"
compile 'com.github.bumptech.glide:glide:4.0.0'
compile 'com.github.jd-alexander:library:1.1.0'
compile 'com.paypal.sdk:paypal-android-sdk:2.15.3'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
You should use def for flexibility when changing version.
The options can be
change versions of play services
remove unused services
if using maps, check permission of google place api
[https://firebase.google.com][1] should be proper configured
google-play.json file should be updated with project.
I think unchecking Offline work option may solve the problem. Check My Answer Here.
A lot of problems can cause this issue:
1) Check if you have Maven/Google repository on your top level main build.grade (can be found on your project root folder):
allprojects {
repositories {
jcenter()
google()
}
}
2) Check if you have the correct library number on your module App build.grade (can be found on \app) :
https://developer.android.com/topic/libraries/support-library/packages
3) Check buildToolsVersion and targetSdkVersion on your module App build.grade (can be found on \app):
Sometimes it's not possible to download anything if buildToolsVersion is not set to the new version. Check this site: https://developer.android.com/studio/releases/build-tools
4) Check internet connection and firewall issues
This is so simple, but nobody checks...
5) Check if Android Studio is set to Offline Work:
File ->
Other Settings ->
Default Settings ->
Build, Execution, Deployment ->
Build Tools ->
Gradle -> Uncheck Offline Work
6) If nothing works, click on Android Studio "clean project" and then "invalidade cache/restart":
Build->Clean Project
File->Invalidade Cache/Restart
Good Luck!
just change the play service version to 15.0.0 and sync the gradle
I have an Android project in which I have been using ACRA 4.6.0 with a static jar file, all working fine. I have tried to change this to use the latest ACRA by the maven dependency in build.gradle:
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
testCompile 'junit:junit:4.12'
compile 'ch.acra:acra:4.8.5'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
}
in my build.gradle. However this causes the build to fail with errors like:
CJApp.java:13: error: cannot find symbol
import org.acra.ACRAConfiguration;
^
symbol: class ACRAConfiguration
location: package org.acra
So far as I can tell gradle is not downloading anything for acra. I have tried adding mavenCentral() to the repositories list with no effect.
What else do I need to do, and is there any way of determining just what gradle has downloaded?
Are you sure that the class org.acra.ACRAConfiguration is included in the new version: acra:4.8.5 which you're suddenly linking to? If not, this is a simple matter of incompatibility. In that case, it should be resolved if you step the version back to 4.6.0.
Have you checked that the build downloads the file from Maven Central? This should be clearly visible when giving gradle the -i flag - it will print every URL as it downloads them.
ACRAConfiguration has moved to org.acra.config. Just adjust your import.
I recently migrated from Eclipse to Android Studio and I'm using Android Studio 1.5.1. Before when I started Android Studio, I got this error:
Failed to resolve: junit:junit:4.12
After searching in Google and trying some proposed options, only commenting junit test in app/build.gradle solved the problem:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support:design:23.0.0'
}
But I want to know is this a good and safe option to resolve that problem? For example does it cause any problem in future?
You will need to add the following to your build.gradle file and it should work fine.
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
So, I managed to create an Android library component and publish it on Maven Central. But when I'm trying to use it as a dependency in a new project, Android Studio can't seem to find the classes.
build.gradle for the app module:
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'no.hyper:libdateintervalpicker:1.0.0' //this is the one I want to use
}
This part seems to work, at least I get no sync errors. However, when trying to access to package and classes from my MainActivity, Android Studio can't find them and gives me "cannot resolve symbol" message.
I have tried downloading the classes.jar from the archive directly from Maven Central, and they are indeed in the package.
Other dependencies seem to appear in the /build/intermediates/exploded-aar folder after syncing, but that does not happen to my library.
I use Android Studio 1.0.2 on OSX 10.9.5 (Mavericks)
Any suggestions?
Looking in your pom, it states <packaging>aar.asc</packaging>. It should be aar instead.
Oh, and the answer to actually being able to use the library, was to add #aar to the dependency so that it now reads
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'no.hyper:libdateintervalpicker:1.0.0#aar' //note the magic #aar
}
Edit:
Removing the block
configurations {
archives {
extendsFrom configurations.default
}
}
makes Gradle generate the pom with the correct packaging entry, and thus makes it possible to reference the dependency without the #aar suffix
I have a basic Android app that I created with Android Studio, and I'm having problems adding butterknife to my build. I get this error:
Error:: duplicate files during packaging of APK C:\apps\orion\app\build\apk\app-debug-unaligned.apk
Error:Execution failed for task ':app:packageDebug'.
> Duplicate files copied in APK META-INF/services/javax.annotation.processing.Processor
File 1: C:\Users\andres\.gradle\caches\modules-2\files-2.1\com.jakewharton\butterknife\4.0.1\f43b36925363701633d01adb8e54df7150397a78\butterknife-4.0.1.jar
File 2: C:\Users\andres\.gradle\caches\modules-2\files-2.1\com.jakewharton\butterknife\4.0.1\f43b36925363701633d01adb8e54df7150397a78\butterknife-4.0.1.jar
My dependencies look like this:
dependencies {
compile 'com.android.support:support-v4:+'
compile 'com.squareup.dagger:dagger-compiler:1.2.1'
compile 'com.squareup.dagger:dagger:1.2.1'
compile 'com.jakewharton:butterknife:4.0.1'
compile 'com.google.android.gms:play-services:4.0.30'
compile 'com.android.support:appcompat-v7:+'
compile project(':lib')
compile fileTree(dir: 'libs', include: ['*.jar'])
}
Later versions of the plugin will tell you how to fix this. I think we introduced the fix in 0.8 so you should probably upgrade. Then the fix is to put this in your build.gradle
android {
packagingOptions {
exclude 'META-INF/services/javax.annotation.processing.Processor'
}
}
This will exclude this file from the packaging which is fine since it's not actually needed in the APK.
That's because you wrote compile for dagger-compiler, replace it with provided and the issue will be fixed.
compile 'com.squareup.dagger:dagger:1.2.1'
provided 'com.squareup.dagger:dagger-compiler:1.2.1'
The best option in version >= 0.9.1 of Gradle build tools is probably:
android {
packagingOptions {
pickFirst 'META-INF/services/javax.annotation.processing.Processor'
}
}
For more, see the Android Tools Project page: New Build System.
Edit:
One last note here if you start having problems with generated code, make sure to structure your dependencies properly. I ended up removing any exclusion of the Processor line and structuring my annotation processed dependencies like:
compile "org.parceler:parceler-api:0.2.15"
apt "org.parceler:parceler:0.2.15"
and
provided 'com.squareup.dagger:dagger-compiler:1.2.2'
apt 'com.squareup.dagger:dagger-compiler:1.2.2'
If after applying above given solutions you still face the same issue as I was, then if you are using glide library then change the version of the glide to it's max.
eg.
implementation 'com.github.bumptech.glide:glide:4.10.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.10.0'