I'm trying to add this libraries to my project:
com.loopj.android:android-async-http:1.4.6
com.google.apis:google-api-services-analytics:v3-rev115-1.20.0
com.github.castorflex.smoothprogressbar:library:1.1.0
But Android Studio is returning this errors:
Error:(8, 13) Failed to resolve:
com.github.castorflex.smoothprogressbar:library:1.1.0
Error:(6, 13) Failed to resolve:
com.loopj.android:android-async-http:1.4.6
Error:(7, 13) Failed to resolve:
com.google.apis:google-api-services-analytics:v3-rev115-1.20.0
This is my build.grade file:
apply plugin: 'com.android.application'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':librarySmartHotel')
compile 'com.loopj.android:android-async-http:1.4.6'
compile 'com.google.apis:google-api-services-analytics:v3-rev115-1.20.0'
compile 'com.github.castorflex.smoothprogressbar:library:1.1.0'
compile 'com.google.android.gms:play-services:6.5.87'
}
android {
compileSdkVersion 19
buildToolsVersion "22.0.1"
defaultConfig {
multiDexEnabled true
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
Do I have to configure something?? for example com.google.android.gms:play-services:6.5.87 is working perfect and I have not done any configuration.
Any help will be appreciated.
Firstly try to add to your Project build.gradle file following code or just add it to existent repositories
repositories {
mavenCentral()
}
Also you may have "Offline mode" enabled. Check if File -> Build,Execution,Deployment-> Maven/Gradle "Offline work" is enabled, if so just disable it and Sync Gradle
And let me know results.
The Gradle builds which you mentioned perfectly compiled with mine. I suggest you to clean your project and restart android studio and try once again. Please let us know if the problem persists.
Related
I searched and I could not find the answer to my problem. There was a solution that seemed valid, but could not use it in AS 2.1.1 (latest) - Product flavour [Migrating from eclipse to android studio]
My issue is as follows:
A senior dev started a project in Eclipse, the project has grown a lot and now he left. I have to migrate the project in AS to be able to add new stuff and this killed.
I started with going into Eclipse and Exporting the project for Gradle. I went into AS and imported the project.
All seems well so far, but now comes the fun part: the project was building on a separate machine, using different configs for each flavor. In AS I was not able to do so. I will attach here my config maybe someone can help. I need each flavor with a different assets folder that will contain the config file, and a different manifest, as each version can have different names / strings. The rest of the code should be common so it can be easily modified for all version.
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
}
}
apply plugin: 'com.android.application'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
productFlavors {
v1 {
//manifest.srcFile 'src/v1/AndroidManifest.xml'
//assets.srcDirs = ['src/v1/assets']
}
v2 {
//manifest.srcFile 'src/v2/AndroidManifest.xml'
//assets.srcDirs = ['src/v2/assets']
}
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
v1 {
manifest.srcFile 'src/v1/AndroidManifest.xml'
assets.srcDirs = ['src/v1/assets']
}
v2 {
manifest.srcFile 'src/v2/AndroidManifest.xml'
assets.srcDirs = ['src/v2/assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
Hello i get the error while trying to run my app it was an app that used to work(while it was in eclipse ) been trying to make it work in android studio after several errors now this1 hit me and cant figure out anything . Thank You for help.
EDİT
No error when i build the app it comes when i try to run the app.
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/annotation/AnimRes;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
Error:Execution failed for task ':dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_65\bin\java.exe'' finished with non-zero exit value 2
Information:BUILD FAILED
Build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
}
}
apply plugin: 'android'
dependencies {
compile "com.android.support:support-v4:23.1.1"
compile 'com.android.support:appcompat-v7:23.1.1'
compile fileTree(dir: 'libs', include: '*.jar')
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
useLibrary 'org.apache.http.legacy'
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
Delete the android_support_annotations.jar file, as recommended at this answer. Your problem is caused by the annotations jar being included by default in the Android support library so there are now two copies.
You could also try temporarily removing compile "com.android.support:support-v4:18.0.+" from your build.gradle and see if that makes a difference.
(The solution was to remove all but compile 'com.android.support:appcompat-v7:23.1.1' in the dependencies).
so basicly after removing every compile part it worked when only this left
dependencies {
compile 'com.android.support:appcompat-v7:23.1.1'
}
changed dependices to this
I have been fighting with Android Studio for 2 dayys because I cannot import 2 eclipse projects in the IDE.Here what I have done.
The projects are 2 Eclipse projects and I export them by doing FILE > EXPORT > Generate build.gradle files.
When I try to import the projects in Android Studio, I have this error :
Failed to refresh Gradle project 'SourceFiles'
You are using Gradle version 1.11, which is not supported. Please use version 1.9.
Please point to a supported Gradle version in the project's Gradle settings or in the project's Gradle wrapper (if applicable.)
Fix Gradle wrapper and re-import project Gradle settings
As you see I use the latest distribution of gradle (version 1.11) and it still does not work.
Can someone show me the proper way to import those projects in Android Studio?
I am on
Linux OpenSuse version 13.1
Android Studio : 0.4.2
Java : 1.7
[EDIT] My project is comprised of directory Sourcefiles which contains 2 sub-directories Skeletons and Testcase. Skeletons contains the source files and TestCase contains the test case associated with the project in Skeletons.
Here are the build.gradle generated by Eclipse :
In SourceFiles level :
task wrapper(type: Wrapper) {
gradleVersion = '1.9'
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
In the Skeletons level :
android {
compileSdkVersion 18
buildToolsVersion "19.0.2"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
In the testcase level directory :
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':Skeletons:FragmentsLab')
}
android {
compileSdkVersion 18
buildToolsVersion "19.0.2"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
I also have to admit that I am still a noob in gradle.
I also updated the Android Studio the latest version in the canary channel and references the verison 1.9 of gradle in my project.
Any help would be appreciated.
I would want to use the Eclipse IDE but it keeps crashing.
Latest gradle versions have many issues, you should really try to use an older one, 1.9 is fine. Add this to the root build.gradle and run gradle wrapper from console:
task wrapper(type: Wrapper) {
gradleVersion = '1.9'
}
It should create a gradle path in your project. After that, use gradlew instead of gradle in command line or pick a "customizable gradle wrapper" option when creating a project in Android Studio.
If you'll encounter further issues with versions change the value of distributionUrl in gradle\wrapper\gradle-wrapper.properties
I am following the instructions here, however I am running into problems at step 3 "Import the SDK into an Android Studio Project". I imported the Module and set to compile as specified however, when I try to modify the settings.gradle I am running into problems. It keeps giving me Gradle 'MyApplicationProject' project refresh failed: You are using an old, unsupported version of Gradle please use 1.6 or higher. I am build the app with version 4.3 compiler while supporting all the way to 4.0(Android).
This is my settings.gradle
include ':MyPeeps'
include ':libraries:facebook', ':MyApplicationProject'
after is wasn't auto populating I added
dependencies {
compile files('libs/android-support-v4.jar')
compile project(':libraries:facebook')
}
Also put this into the build.gradle
buildscript {
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4'
}
}
apply plugin: 'android-library'
dependencies {
compile files('libs/android-support-v4.jar')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
res.srcDirs = ['res']
}
}
}
When I go to put in the onCreation command for facebook errors with all the commands that use the facebook api. Does anyone know how I can fix my gradle issues?
Change 'com.android.tools.build:gradle:0.4' to 'com.android.tools.build:gradle:0.5.+'
I decided to drop android studio and just go back to adt plugin got it work quickly at that point. Thanks for the help.
I had a gradle error at first where I needed to change the version. I read about this problem on the android studio website, and I followed there directions and changed this line in the gradle file:
classpath 'com.android.tools.build:gradle:0.5.0'
My error didnt go away and my main was full of red underlines. I then restarted Android Studio and everything seemed fixed.
But when I tried to compile and run on my phone from my mac book air I got this error:
Gradle: A problem occurred evaluating root project 'BeerPortfolioPro'.
> The SDK directory '/Users/Mike/Library/Caches/AndroidStudioPreview/compile-server/"/Applications/Android Studio.app/sdk"' does not exist.
my gradle build file:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.0'
}
}
apply plugin: 'android'
dependencies {
}
android {
compileSdkVersion 17
buildToolsVersion "17"
defaultConfig {
minSdkVersion 11
targetSdkVersion 17
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('tests')
}
}
You can change the dependency to 'com.android.tools.build:gradle:0.5.4'.
Also, add a local.properties file in the project root folder with a line pointing to the Android Studio sdk directory. I had to put this line:
sdk.dir=/Applications/Android Studio.app/sdk