Changes to Android library project are not applied until restarting Eclipse - android

I have a main Android application that is using an Android library project. When I change my library project and Build Project or Build All the changes are not detected in main project until I clean the main project or close and reopen Eclipse.
How con I solve this problem? Is there any rapid solution?
Update
I am using:
Eclipse 3.7.1
Android SDK API 15 Rev 3
Android SDK Tools Rev 19
Android SDK Platform-tools Rev 11

Solution 1) I clicked on Android Dependencies in Package Explorer and pressed F5 (refresh) and built the main project and problem solved.
Solution 2) this answer also works for this problem. It says you can add the project to the build path. ( Right click on project -> properties -> java build path -> Projects -> Add).
Under the Order and Export section, make sure the library is above the Android Dependencies.

Related

How do I "select Android SDK" in Android Studio?

After a successful import of an Eclipse-Android-Project into "Android Studio 1.4", I get the error
"Please select Android SDK"
when I click on the button to run the application in the simulator, I can't find any way of doing that.
This dialog opens when I click on "run":
This is the "project structure" dialog:
What should I do now?
I go to build.gradle and click sync now. Then it worked.
Update :
File -> Sync Project with Gradle Files (Android Studio 3.1.1)
Tools -> Android -> Sync Project with Gradle Files (Android Studio 3.0.1)
Or You can click on the icon from the toolbar.
This answer may not help works for later version as Android studio Team work on making the tool more better, the way to sync may be different in the next version of Android Studio.
COMMON WAY that may helps is try to sync project and then Invalidate Caches and Restart Android Studio.
Solution for Android Studio 3.1.2 [See below answer]
See Latest Android Studio version
FIX FOR 3.1.2 OR NEWER VERSIONS
Some of my colleagues and I have faced the same issue on AS 3.1.2, but a simple Sync didn't help us. For us, the solution was a bit different:
File -> Invalidate Caches -> Invalidate
File -> Close Project.
Remove the project from the AS project selector window.
Quit from Android Studio
Start AS and open project again
EXTRA ADVICE IF YOU ARE FACING THIS ISSUE CONSTANTLY
Some of you are constantly facing this issue, and this "solution" fixes it only temporarily. At the time we started getting this error, we used gradle wrapper 4.6 and Android gradle plugin 3.1.0, but since then we went back to gradle 4.4 and we use it with the latest Android gradle plugin, and we haven't seen this issue since then.
In Android Studio 3 and above, for Windows, Mac and Linux:
File -> Sync Project with Gradle Files
Solved!
Or you can do this by shortcut key:
Press ⌘ + Shift + A (Mac) or Ctrl + Shift + A (Windows, Linux). Then pop-up a Edit-Text and write "Sync Project with Gradle Files". Then press double click on the option.
Your problem is solved! It'll sync your gradle file with your project file.
Screenshot:
Click this icon to sync gradle
or edit any of your module gradle and then sync
Press "Ctrl+shift+A" and in the pop-up EditText, write "Sync Project with Gradle Files". After that double click on the appeared option. It will then sync your Gradle file SDK with the project file.
Just go to the (app level) build.gradle file, give an empty space somewhere and click on sync, once gradle shows sync complete then the Error will be gone
This is the easiest way to fix this issue:
Add a comment line to the gradle file
It will then ask you to Sync.
Click 'Sync Now'
Viola! You're done.
Now on Android Studio 3 and above, you can try to sync project with gradle like:
File -> Sync Project with Gradle Files
The menu structure and options have changed slightly as of Android 3.2.0. I fixed this error by changing the Module SDK in the following menu:
File > Project Structure > Modules > App File > Dependencies Tab > Module SDK
Make sure to hit Apply to save your changes.
The comment from #Nisarg helped: "set latest version in Compile Sdk Version"
I changed from API 8 to API 23 and the error message disappeared.
Press the first refresh button on the gradle vertical tab in Android Studio on the right
Press " ⌘ + Shift + A" on Mac (or "Ctrl+Shift+A" on Windows) and in the pop-up EditText, write "Sync Project with Gradle Files". After that double click on the appeared option. It will then sync your Gradle file SDK with the project file.
Follow these steps:
Goto Android Studio Settings
Search for "Android SDK" using search bar
Ensure the path to your android sdk folder is correct.
After that also ensure the path is automatically updated after a prompt in your project (local.properties) file. If not, do it manually.
Hope this helps.
There are multiple hit & trial solutions for this error. One of them will surely work for you.
Below are the solutions:
1.
Tools -> Android -> Sync Project with Gradle Files (Android Studio
3.0.1)
Go to build.gradle and click sync now
Click hammer(Build) icon to sync Gradle
or edit any of your module Gradle and then sync
File -> Settings -> Android SDK -> Android SDK Location Edit ->
Android SDK
Open build.gradle file, just add a space or press enter. Then sync
project.
File -> Invalidate Caches / Restart
Go to File >> ProjectStructure(⌘;). This would open this window then select the app module. Then choose the Compile SDK version . Choose the latest one and click apply.
I was having this problem on all versions of AS 3.0+. Syncing with gradle did not solve the problem for me. The solution from András Klöczl was the only thing that would allow me to get some coding done. The problem was, anytime I had to do a gradle sync, the problem came back. So I had to go through that process any time I wanted to make a change in my build.gradle. What ended up working for me was to downgrade my kotlin version from 1.2.40 to 1.2.30
My problem was that if I changed the project (for example opened new window of Android Studio with different project) this error happened.
So I read every answer in this question and the "clear caches and open the project again" solution wasn't so useful in my case.
Instead I discovered that if the Kotlin's plugin's version in Android Studio was lower than in gradle file, the problem appeared.
My setup was:
Android Studio 3.1.3
Kotlin plugin (in Android Studio) 1.2.30
Kotlin version in gradle file 1.2.51
What fixed the problem?
I updated the Kotlin plugin:
File -> Settings -> Plugins -> Install JetBrains plugin...
Then search for Kotlin and click Update. After update just restart the Android Studio and sync Gradle.
Just change build tools version to 25.0.3.. and sync now
I hope it will help..
This worked for me.
File -> Settings -> Android SDK -> Android SDK Location Edit -> Android SDK
Go to : File > Project Structure > Modules -> app > Properties
please choose : Compile 'SDK' version = API26 Build Tools
Version = 27.0.0 Source Compatibility = 1.8 Target Compatibility =
1.8
open build.gradle file. just add a space or press enter. then sync project. it works...
Sometimes android studio just acts stupid and needs some kind of reset..
Go to settings.gradle file it should contain include ':app'
change it to include ':ap' and sync.
after sync, change it to include ':app' again.
It should be working OK now.
The simplest solution for this problem:
First make sure your sdk path is currect.
Then
Please close current project and in android startup menu click on import project and choose your project from explorer.
This will always solve my problem
In my case there there is no selected java sdk version in project structure-
I had to select the -
1.Source Compatibility (1.7)
2.Target Compatibility (1.7)
as shown in image.
If you are using 'Profile or Debug APK...', then you might come across this error.
My solution is to first check SDK for updates in SDK manager: click on "Edit" at the right side of SDK location and go through to install any updates:
Then I clicked on "Logcat" at bottom of Android Studio and find out I also need to configure Android SDK, so choose latest Android API Platform:
After that, I'm able to run the APK in Emulator.
In latest android studio 3.3.2 the icon of sync project with Gradle Files is changed
Now try this
File -> Sync Project with Gradle Files (Android Studio 3.3.2)
For Android Studio 3.5, "File -> Sync project with gradle files" is enough.
Go to gradle.build file and click sync now
OR
click icon on Sync project with Gradle file
OR
Go to Tools-> Android -> Sync project with Gradle file
If your android SDK path is given and still you facing this issue then it might because your android studio not synced well, even you have clicked on "Sync now" link.
So for re sync it go to app gradle file and make any change or just give a space and now sync again. It will work perfectly.
In my case I downloaded a git repository for an android project. The project required minimum sdk version 21 and target sdk version 27. When I tried to run the project it gave me "Please select Android SDK error". I checked that I had already downloaded the required sdk files.
For me the solution was to "sync project with Gradle Files"

Facebook SDK v.4 for Android: errors on Eclipse

I am trying to import the latest version (4.0.1) of the Facebook Android SDK into eclipse but I am facing issues in having the project being properly built and imported as a Library.
I followed the steps (for android studio, ported to Eclipse) provided in the official guide and looked through Google for other developers having the same problems as I am having but I am still not able to have it properly working.
Here are the steps I do:
Download the Facebook SDK for android from here: https://developers.facebook.com/resources/facebook-android-sdk-current.zip
Extract the projects
In Eclipse, import existing Android code into workspace
Select the folder "facebook" and choose the only project that is shown (the project is properly imported)
Right click on "facebook" project, properties, android and check "isLibrary"
clean project
At this point I still have issues for annotations and classes not found from "android.support" package.
Project's setting for Java compiler is "1.6", minSDK is 9 and target is 17.
I tried also to add the facebook library to my main project but it is still not working.
I tried to put java 1.7 in the compiler but it is not resolving the missing classes plus it is saying that to compile with java 1.7 I need to have min API set to kitkat (which I don't want because I will not be able to compile for 4.2 and 4.3).
I added manually the androd support jar from the SDK Manager folder of android and this resolved partially the missing classes but some did remain.
I am using Eclipse Version: Luna Service Release 1 (4.4.1) with JDK 1.7.0_51 and the latest ADT Plugin (all android components updated with SDK Manager).
Any help is appreciated.
I did some more tests and find out that by downloading the two libraries:
android-support-v4.jar
bolts-android-1.1.2.jar
from the github project (https://github.com/facebook/facebook-android-sdk) did the trick.
So the steps are the following:
Download, unpack and import as android existing code into workspace the latest v.4 version of the Facebook SDK for Android.
Download the two jars from GitHub
Set the Facebook Project as "isLibrary"
Add the two jars as "external jars" in the classpath
Set the java compiler to 1.7
clean and rebuild the project
Now errors are gone.
Download the facebook sdk from here.
Extract the zip file.
Import only facebook sdk project into eclipse as "Existing Android code into
workspace".
Now, this project will show many errors, do not open any java file or
resource file and do not try to do any imports or clean project until I
mention it to do so.
First add the v7 library to this project by doing right click on facebook
sdk project >> properties>>android>>Add Library.(If you don't have latest
v7 support library download it from sdk manager), also set the project build
target to the maximum android version available and select "is library".
Now, right click on facebook project and select >Build path>Configure build
path>Libraries tab>Add external jars> browse to place where you extracted
facebook sdk in step 2 and find two jar files in libs folder(android-
support-v4.jar and bolts-android-1.1.2.jar) and add both files. Switch to
"order and export" tab and select both the jar files and click on ok.
Now right click on facebook sdk >>properties>>Java Complier>>set the
"compiler compliance level to 1.7 or more and use default compliance settings.
Now select the project and click on Project > Clean.
This should remove all errors now. This is how it worked for me.
Android Facebook SDK import occurs with errors - Eclipse
Check this out. May be this will help you.
I faced same problem while working in Android Studio.
But you are facing in Eclipse.

android studio new project missing folders

I have created a new project using the latest version of Android Studio (0.2.2), this is a fresh install of studio. When I am in the project explorer view, it fails to show me any folders for my project. I should see a root project folder, and within it the .idea, gradle, and module folders, but they are not showing.
Here is what I expect to see (taken from the sample project created on first boot):
But here is what I see immediately after the project's creation:
I cannot figure out how to expose my project's folders! I do not want to develop without the project explorer, it's simply too much of a hassle. Did I create the project incorrectly, or am I missing some not-so-obvious setting somewhere?
Thanks.
The problem here is that I assumed android studio would create a module for the application. I assumed this because it asked me at the beginning for app name, module name, package, sdk info etc.
This assumption turned out to be false. You must create your first module manually through File > Project Structure. After that is done, the project explorer shows the files.
File -> Project Structure -> Modules
Add Button (Green plus button) click -> New Module Select
New Module window -> "Content root" change path button click to select "Project root file path"
Apply to change save and "OK" button exit.
In the project Explorer there is a drop down menu where you have selected project, now change it to project files.
I hope this will solve your problem. reply if it didn't.
You have created a new gradle project not a new android project.
Update your android studio tools to 0.2.3 - Go to Help menu - select check for update.
then Update your android sdk tools, android support repository, android support library and android build tools using android sdk manager.
And update some configuration in project structure. Go to File menu->project structure -> in projects tab select Android SDK as default sdk and in SDKs tab set correct path to updated android sdk.
Now restart android studio and try to create a new project and it should work fine.
(Noted for posterity) I had a similar issue come up recently, when importing an Eclipse android project. The issue was that the source folder wasn't added as such. I had to manually go into Project Structure -> Modules -> Sources and make sure that the "src" folder wasn't excluded and was marked a source folder.
Although this question is asked years ago. But now following simple solution worked for me.
Clicking 'Sync Project With Gradle files' makes all directories visible.
I had this exact same issue, there are some problem if you upgrade from 0.1.9 version to 0.2.0 in Windows.
Android Studio 0.2.0 Release
The solution (which worked for me) was to completely uninstall Android Studio and reinstall the 0.2.0 version.
I had the same problem today. Additionally, the IDE posted an "Assertion Error" into its event log.
Downloading and reinstalling the preview version, then applying the patch to 0.2.6 worked for me.
Change the SDK to a level that you have installed in the SDK manager. The SDK manager can be accessed from Tools -> Android -> SDK Manager. For me, Android Studio was packaged with API Level 17 but the new project wizard tried to target API Level 18.

Import project in Android Studio from Eclipse

I installed new Android Studio 0.1.1 based on IDEA ide and tried Import code from Eclipse.
Go to Eclipse->Export->Grandle so it add gradle file
Open Android Studio and select Import Project and select my project folder with build.gradle file
Press Finish and get an Error: failed to find target android-15 (this is was parget of my project)
I go to system variables and change to %ANDROID_HOME% = d:\dev\android\android-studio\sdk\ (remove platform-tools from path)
And get new error: failed to find Build Tools revision 15.0.0
Also create another New Project and change Android SDK for it, but I still cant import project
I explore this problem and find the weak point: in file build.gradle I change next lines:
from compileSdkVersion 15 to compileSdkVersion "17"
from buildToolsVersion "15" to buildToolsVersion "17"
And it fix my problem with project import. I think it's problem in Eclipse export function. Build tools starts only from version 17 (in ADT 22), so it's imposible to find version 15.
Had same problem, now works. I did this:
Open android studio:
Tools -> android -> SDK manager then install the android 4.0.3 (API 15) and done.
It worked for me.
These simple steps worked for me:
Open new project (new not import)
Press F4
On the left Click on SDKs
Delete all SDKs
Click on +
Choose the SDK you are using for eclipse
Choose the right version
Click OK
Open your project using gradle file
Enjoy :)
This is an import problem. NOT an SDK Level issue.
You need version 22 of the SDK Manager before you attempt the export or it won't be in a format that Android Studio can consume.
Do you have updated SDK for Eclipse?
You need the Rev.22. After you downloaded it, you can Export the Project with a "build.gradle".
Migration of the Projects
Updating your SDK
Update SDK go to config settings, project settings then you will see SDK that isn't correct point to same place eclipse points to for SDK.
Worked for me.
Also it might help to reexport the project with new sdk
Update your android APIs using Android SDK Manager.It seems you have installed API lower than level 15.
For general 'import project' info, search for the word 'import' on
this install-guide document for Android Studio:
http://developer.android.com/sdk/installing/studio.html
EDIT: I've recently learned to use the 'import' dialog, so that I can
import projects from GitHub, which is very cool! (I first watched a tutorial
on YouTube titled 'git and github'). Then I learned that one needs to
use 'git' to "Clone" an entire GitHub repository (to bring a dir-tree full
of separate projects to your development machine). Then, you can navigate
into that sub-tree, to a given project of interest, and then use Android
Studio's 'import' dialog to play with that example project.
WOW, NEAT!
Hope this helps...
Had the same problem when Android studio 0.2.9 on mac and importing an old eclipse project:
By default, it uses /Applications/Android Studio.app/sdk as the android sdk location, instead of whatever you used to use.
On a per-project basis, you can go to the menu's File->Project Structure (command-;) and on the left you can change the project's sdk location.
To handle all projects (new or imported), before opening anything at the start screen click configure -> Project Defaults -> Project Structure -> (on the left) Android SDK to do the same. (re: https://stackoverflow.com/a/18409923/954643)
If you were starting from scratch without any android sdk setup and eclipse though, you'd have to download the missing SDKs via Tools->Android->SDK Manager.
I simply solved the problem by changing the project build target (Project properties->Android->Project Build Target).
In the file build.gradle change your compileSdkVersion to your current version. For me it is 23. Your buildToolsVersion would be the same number. Hence the only thing I had to do was
Change CompileSdkVersion 15 to CompileSdkVersion 23 in the build.gradle
From the quick start window, choose Configure, then choose Project Defaults, and then choose Project Structure. Then on the left under Platform Settings choose SDKs. Then to the right of that choose the current android platform, mine was Android 4.2.2 Platform, and delete it using the red minus button at the top, then add a new android platform using the green plus button at the top and point it to your current SDK folder and that is it.

Unable to build Eclipse library projects after ADT update

I have a main project (mainapp) I am developing for Android under Eclipse. It uses the facebook-android-sdk library (fblib) which is a separate Eclipse project with it's project properties checked as "Library". Under the project properties > android section for mainapp, I have fblib added as a library. everything works fine.
I needed to create a new version of mainapp which uses different database files (assets subdirectory). To do this, I created a new Eclipse project (newapp) and setup mainapp as a library under project properties > android.
Everything was working fine until the latest ADT update. I am getting errors trying to build/run newapp (Conversion to Dalvik format failed with error 1). If I go to mainapp and uncheck "Library" from project properties > android, I can build mainapp as a regular application and it seems to work just fine.
I've searched for multiple jar files in project directories, updated proguard to 4.8beta, deleted/added jars to the build path, removed exports, added exports, deleted dependencies, added "lib" directories, cleaned, restarted, rebooted and pretty much anything else google would turn up, but to no avail.
It was all working fine with ADT 16 so I'm really confused here. Has adding a library project to an application, which also incorporates a library project, become somehow deprecated? I just can't seem to get this working.
The new ADT makes you call it 'libs' instead of lib. rename your directory and see if that fixes it
Refer: http://code.google.com/p/android/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars&groupby=&sort=&id=27490
I've also noticed in my own projects, under Java Build Path > Order and Export, I sometimes need to go in and make sure all my linked sources have their boxes checked.
I had similar issues. The issues were because of different build system introduced "Gradle".
Resolution: Forcibly open Android SDK Manager, and take update to install
1. Android SDK Build Tools revision 17
2. Android SDK platform tools revision 17
3. Android SDK tools revision 17
From all library project dont forget to enable "Android Private Libraries" the check box inside properties-> order and export.
Thanks.

Categories

Resources