How import eclipse project to android studio 0.4.6 ? - java

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

Related

Unable to integrate OpenCV in android studio

I am trying to integrate openCV in Android studio for my latest project. I followed the following steps:
Imported new module ..\OpenCV-android-sdk\java\
Added dependancy OpenCVLibrary320
Changed compilesdk and targetsdk versions to 23 and buildToolsVersion to 25.0.0 in the build.gradle of OpenCVLibrary320
Copied the contents of ..\OpenCV-android-sdk\sdk\native to app\main\src\jniLibs (After creating a jni folder)
Wrote a snippet of code to test if it was working
But I got the error:
Error:Execution failed for task ':app:compileDebugNdk'.
Error: Your project contains C++ files but it is not using a supported native build system.
Consider using CMake or ndk-build integration with the stable Android Gradle plugin:
https://developer.android.com/studio/projects/add-native-code.html
or use the experimental plugin:
https://developer.android.com/studio/build/experimental-plugin.html.
How can I fix this problem?
Note: In step 4, I created the jniLibs folder but it did not show up in the 'Android' view so I had to copy the contents to the jniLibs folder in the 'Project' view.
In gradle add module dependency:
include ':libraries:opencv'
add in build.gradle with this content
apply plugin: 'android-library'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
}
}
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0.0"
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
res.srcDirs = ['res']
aidl.srcDirs = ['src']
}
}
}
Manualy add the jar file in the lib folder,
app -> libs -> xyz.jar
This will also create duplicate jar issue, remove from the previous folder, because it gets compiled twice if you do not remove

Unable to sync Android Studio with Maven repository

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.

How to properly import Android projects in Android studio?

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

Using Android Studio Facebook SDK

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.

transferred computers with Android Studio and now have Gradle error

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

Categories

Resources