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
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')
}
}
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.
I have project in eclipse and use android 2.3.3(API 10), but when I need import this project to android studio 0.4.6 thin android show me massage to fixed my project after I click fixed show me error `"Execution failed for task ':preBuild'.> Build Tools Revision 19.0.0+ is required."
please how I can fixed this error.
That my gredle-wrapper .properties:
#Thu Apr 17 01:07:57 PDT 2014
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-all.zip
That my build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.8.+'
}
}
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
android {
compileSdkVersion 8
buildToolsVersion "17.0.0"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['use','src']
resources.srcDirs = ['use','src']
aidl.srcDirs = ['use','src']
renderscript.srcDirs = ['use','src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('tests')
}
}
Please till me, any version eclipse I can export project to import in android studio.
All version eclipse is true to export.
You need to update the Build Tools Revision to version 19.0.0
open your sdk manager and update ( use the sdk directory associated with android studio not eclipse)
You might as well try to migrate your project from eclipse to make it easier when importing it in eclipse.
Let me know if this is not working
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