Migrating to Android Studio - java

I want to migrate from Eclipse to Android Studio, but unfortunately Eclipse was crashed so I couldn't build gradle-build files, so I reinstalled Eclipse, and luckily I still had those, I copied my old files which where in my old workspace (the workspace from before the crash) to a new workspace.
But, when I build the gradle-build files now and I import them in Android Studio it says my gridlayout_v7 is missing.
Does anyone of you know how I can solve this?

Run SDK Manager and check that you have installed:
Android Support Repository
Android Support Library
Google Repository
Then check if your build.gradle has next lines:
dependencies {
compile 'com.android.support:gridlayout-v7:18.0.0'
}
You dont need separate gridlayout library subproject anymore with new build system.

Related

Gradle project sync failed. Basic functionality will not work properly. (Android studio)

I have gone through similar question on the internet. But I am still unable to find a solution for it.
To begin with I am trying to understand gradle and how android studio builds gradle files.
I have read about gradle and how it is structured. I have understood that it is similar to make in linux, so it builds all of the necessary files to create apk. But i could not understand how android studio generates all the gradle files. Is there a main file which is executed and which generates all of the other gradle files.
My project was working properly until i had to sync the gradle files and now it is giving me "Gradle project sync failed" error. I have tried out existing solutions on the internet, like
1.Invalidating caches and Restarting
2.Settings -> Build, Execution, Deployment -> Gradle turning on Online mode here, which i could not find on the android studio version 4.0.1
3.Opening up Gradle build console from View -> Tool Windows -> Gradle which i could not find.
I can't see the module level and project level gradle files amongst others, should I manually add them?
Should i download a new gradle file and point it separately? Is there any way to fix it by executing the right gradle file and generating the rest of it.
Where can I read more about it and have a better understanding of gradle.
Better install a new version of android studio. i think you have updated your gradle plugin.
I had that problem and I just updated my Android studio. It worked!
go to: Help->Check for updates

Linking eclipse project as library to Android studio

Eclipse has this neat feature where you can set one project to build path of another project so that you can separate the two projects as library and the application while maintaining the independence of editing these projects as desired.
This also helps as change in library project is immediately reflected onto application project
Now I want to do something similar for android studio , but the library that my android project is being built on is a java project in eclipse IDE.
Currently what I do is make some changes in library project eclipse then export it as jar file and then import it on android studio.
This is tedious as I want to develop the library project in eclipse alongside the android project and exporting and copying over the jar files manually is slow
Is it possible to do any of the following:
Setup eclipse project such that its build outputs/updates a jar in the libs folder of android project each time project is built in eclipse?
Link the Android studio project's build path to include the eclipse project
Edit the java project on android studio along side the Android project and link them both
Android Studio is the official integrated development environment (IDE) for Google's Android operating system, built based on JetBrains' IntelliJ IDEA software. Android Studio uses Gradle
In answer to your question
You have to understand Build Process with gradle in Android Studio.
You can import your Android project.
And Add your library as a dependency
Create an Android Library
Add as a dependency for your Andriod app modules or other Java projects.
I recommend reading this site.following Site
Projects Overview

How can I bring Google play services into my libGDX Gradle project?

After adding Google Play Services to integrate Google ads into my libGDX project in Eclipse, I can no longer use Gradle to build my Android project.
I know that's because I need to tell Gradle about the new Google Play project dependency so I added compile com.google.android.gms:play-services:5.0.89 to the dependencies section of the :android project however it complains that it could not find com.android.support:support-v4:19.1.0.
I guess that means I need to somehow tell Gradle this new dependency depends on another dependency?
Everything works fine in Eclipse so the dependency of my Google Play project in Eclipse is for sure golden, I just need to make Gradle the same way. Do I need to declare the Google play project as another Gradle project and make a build.gradle file for it? I don't think I should be touching the Google Play project contents at all.
If you have downloaded the tools and google reprositories using the Android SDK Manager (1st thing to check), check if your build.gradle files do not need to be updated (what libGDX version are you currently using?).
I had the same problem and solved it by replacing my Android's module build.gradle file by a brand new.
To do so, use the last ligdx setup ui (https://github.com/libgdx/libgdx/wiki/Project-Setup-Gradle) to create a fresh project then compare/replace gradle files.
Under your android module there's a build.gradle file. Add the following:
dependencies {
compile 'com.google.android.gms:play-services:6.1.11'
}
Check for the latest version of Google Play Services and update your version number accordingly.

Can't run imported gradle android project in Eclipse

First, im new in gradle so please bear with me.
I successfully build and imported this project with gradle & eclipse on ubuntu 13.10. This is what i did :
run gradle build in terminal (success)
add apply plugin: 'eclipse' in the build.gradle
run gradle eclipse in terminal (success)
import it as existing project on eclipse
The problem is, when i tried to run the project, eclipse read it as "normal" java program, not the android one. This is the SS :
The main project in my workspace is not in eclipse format.
And this is its properties :
Notice there's no android tab in it's properties. And i cant run it as android application.
Am i missing something? Please kindly help me.
Thanks for your help.
Usually to develop Android in Eclipse you need to install ADT into Eclipse or start with ADT-Bundle (Android IDE) from Google. (You have not as Preferences missing Android group)
However ADT does not have gradle support. And Android Studio is still not even yet beta (preview or alpha, bleeding edge, need to update with almost every build).
There is Nodeclipse/Enide Gradle for Eclipse
(marketplace), that lets launch gradle build even on general project.
For the latest build.gradle template for classic Android project check
gh.c/N/n-1/b/m/o.n.e.e.g/docs/android/build.gradle.
This lets create new Android project in Eclipse with ADT and use ADT tools for most of things,
but additionally have newer build with gradle
and execute defined gradle tasks
But for Android project with several modules (as in this case) you would need to DIY do it yourself:
try to configure Eclipse .classpath to correct values, as gradle eclipse task won't yet do it all for you.
Eclipse plugin in Gradle that you have used does not support Android projects - they are significantly different from regular Java projects. Some things can work but there will be a lot of things missing including Android nature for generated projects.
And the ADT plugin provided by Google does not support Gradle projects yet as the team focuses on Android Studio first. http://tools.android.com/tech-docs/new-build-system can give you some ideas about the current state.

JAR libraries not being detected

I created a fresh project in Android Studio which uses external library (JAR). I put this in modules's build.gradle:
dependencies {
compile files('libs/android-support-v4.jar')
compile files('libs/mylib.jar')
}
But, when using Android Studio editor, it says there are some errors in my code and marks imports and variables (which use this library). It doesn't build properly saying that it cannot find one or another class. However, when I go to project's directory in terminal and execute gradlew manually, it builds APK and it (the APK) install and works just fine.
What am I missing? Is there any another setting in my project which is used for library detection?
Android Studio currently does not automatically sync your Gradle build files with your Android Studio (.iml) files. However, version 0.1.3 added a new sync button to the toolbar that will do this manually.
It's mentioned in the second bullet point of this blog post.
There were a lot of fixes in the Gradle project import and build
areas. There is now a "sync" button in the toolbar which will reimport
the Gradle project state into your Android Studio project. Use this
after editing your Gradle files, for example to add a library. In the
future we will more automatically handle state syncing, but for now
this is the simplest way to keep the IDE up to date with project
structure changes made to the Gradle files.

Categories

Resources