Importing library in Android Studio - android

I have little experience with importing libraries. I am using Android Studio, and am trying to use parse.com's library with no luck. I followed these instructions, and tried a few other things when that didn't work. Please help me out. Let me know if you need any more information. Thanks for your time.
This is my MainActivity where I would initialize my Parse client key:
Project Structure showing I have imported the libraries:
UPDATE
Gradle:
UPDATE:
When I try to Build, I get this error: Gradle: error: package com.parse does not exist
When I try cleaning through command prompt

Put the jar into the libs folder
Right click it and hit 'Add as library'
Ensure that compile files('libs/~~~~~~~~.jar') is in your build.gradle file
Do a clean build (You can do this easily in android studio but just as a better method, go to your project folder using windows explorer and open a Command window there by right clicking the folder while holding shift and type gradlew build.

To add to the answer of #ThePoloDoc and for your update Command Prompt image, you need to do the following to clear that error:
Go to Control Panel -> System -> Right Side see for Advanced System settings
Select Environmental Variables
In the new window, search for the PATH variable. Add the java installation folder something similar to C:\PATH_TO_JDK\bin
Replace the PATH_TO_JDK with the installation of your java directory
Try opening the command prompt and you'll see the error gone.
UPDATE:
I have got a doubt in your question. Why do you manually compile gradle? I use Android Studio. But I always click the Sync Project with Gradle Files button on the top. It does everything for me

Related

AndroidStudio newbie: when running, how to set a module

When I try to run the application I get a message that I should choose the configuration.
When I do, I try to go with AndroidApplication, and then I get this message with an error saying module not specified. But when I try to choose a module from the dropdown, I get no options.
How can I fix this? Thank you!
I see two possible issues:
1) I don't see that you are using gradle(no gradle files shown in your 'project view', and I don't see the 'Gradle Scripts' drop down in the 'project view'.
This is an issue because it looks like this project is from Eclipse, not Android Studio. The inclusion of 'project.properties' hints at this too. Android Studio doesn't include the ant-based build system that can build a project from the Eclipse build system.
If this is the problem then close the project, and use the 'Import Project' wizard from the "Welcome to Android Studio" start window and re-import your proeject. This wizard will import the project for you and convert it to use the gradle build system.
2) If you ARE using gradle (and it just looks like you aren't)... Then this might be your problem...
In your 'settings.gradle' file (topmost level of your project...)
You should have something like
include ':<library-etc(obviously just placeholder)....>'
include ':app'
":app" here refers to the folder where your project lives. If it isn't in your 'settings.gradle' file then it won't be listed as a 'module' you can configure.

Android Studio - Android Project View is Missing

I've found some webpage but it does not guide me back to normal android project view.
http://developer.android.com/sdk/installing/studio-androidview.html
I did File => Other Settings => Default Project Structure => Default Settings => OK It make even worse, import library become not function-able.
I also had this problem (creating new project also looked similar to IntelliJ IDEA), got it fixed when I enabled some Android-related plugins.
Go to Preferences (Settings on Windows and Linux) > Plugins and enable Android Support, at a minimum.
Now you will have "Android" option in the Project View.
Try:
View -> Tool Windows -> Project OR the shortcut is alt+1.
If that's not working try:
Window -> Restore Default Layout OR the shortcut is shift+F12.
Also, check that Studio is up to date:
Help -> Check for update...
None of the above solutions worked for me so I fixed this by removing the .gradle and .idea folders from my project.
The square at the bottom left corner of android studio lets you spread the screen or it populates it with side menus.
For me, it happened when I used Kotlin KTS for Gradle files, but created a java library module for this project. After trying to reimport project I got an error:
New Gradle Sync is not supported due to containing buildSrc module
Solution:
Migrate added module to kts
Remove created by Wizard settings.gradle, if you already use settings.gradle.kts
Reimport project
File -> Close project
Android Studio: import project
Show it your current project location
Just had the problem happen to me again. I got the problem solved, but unfortunately I can't confirm the solution, now that it's fix; but I have strong suspicions on what was the cause.
In my case, the problem occurred as a result of reorganizing my project directory. My projects are stored in given directory lets call it "Projects". I renamed that fold to "ProjectsBackup" and created a new "Projects" directory. I then moved selected projects now contained in the "ProjectBackup" directory to the new "Projects" directory. After moving the first project, I used Android Studio to open that project. That's when the problem occurred. I got a message that it couldn't find the gradle-wrapper and offered me the choice to create it. The gradle-wrapper is stored in a directory call "gradle" and its stored in the "Projects" directory. I had not copied that directory over from the "ProjectsBackup" to the new "Projects" directory. At the time, I thought nothing about that since, a new one was created. After trying all the various suggestion in this problem discussion, android studio offered a notification from me to update my "android gradle" plugin. I did the update and after that the "android" view was now available for me to select. The android gradle update fixed the problem.
I unfortunately, can't tell you what changed as a result of the update, nor can I tell you how you can force Android Studio to update or reinstall the android gradle plugin. All I can tell you is that I got lucky that android studio gave me that notification to update the android gradle plugin. Things like "file/project structure" and changing the Android Gradle Plugin Version, didn't fix the problem. What I did notice, was that when I first looked at that, the drop-down list of android gradle versions was an empty list. I manually put one in "3.6.3", but it didn't help. If you run into this problems I would suggest you look at the dates of the two file in the "wrapper" directory and compare those to projects you may have that are working correctly with the android view. I wish I would have checked the date of the wrapper jar file, when it wasn't working. That's what I think might have been wrong (i.e. I got a wrapper.jar file that was incompatible with my version of android studio - unfortunately I can't prove that)
problem solve i have click this button

Unable to start Android Studio after installation

I am trying to start Android Studio for the first time but getting error mentioned below
Could someone please let me know how to solve this error?
You need to set your JAVA_HOME path, which will allow Android Studio to run. Have you done that?
Here is how to do that:
Right click your Computer icon, and click Properties
Windows 8 Users: Then click Advanced System settings to your left.
Now, go to the advanced tab, click Environment variables, under
system variables, click New, and add a JAVA_HOME variable, it should
look like this (relative to your jdk version, if its the latest
it should be identical).
If you already have that covered I found a solution here that can help you:
Go to your AndroidStudio directory where you installed your studio Like D:\User\AndroidStudio
In AndroidStudio go to \AndroidStudio\plugins\gradle\lib and copy gradle.jar
Paste this gradle.jar file to \AndroidStudio\lib directory.
Download gradle directly from Gradle
Copy the contents of gradle-1.7-bin.zip - After extracting zip file - (bin, media, init.d, lib folders) to \AndroidStudio\plugins\gradle
Restart AndroidStudio
http://developer.android.com/sdk/installing/studio.html#Troubleshooting
Scroll to the bottom.
Troubleshooting
Figure 1. Error dialog when opening an existing project.
Error: Gradle project refresh failed
Android Studio 0.2.0 has updated the Gradle plug-in to 0.5.0, which is not backwards compatible. When opening a project that uses an older version of the plug-in, Studio will display the error shown in figure 1 in the upper right corner of the IDE. To resolve the error, you must change the version of the Android Gradle plug-in to 0.5.0.
Click the link in the error dialog Search in build.gradle files. If the dialog is no longer visible, click Event Log in the bottom-right corner of the IDE, then click Search in build.gradle files.
Double-click the line under the build.gradle usage. For example: classpath 'com.android.tools.build:gradle:0.4. This opens the project build.gradle file.
Edit the classpath to change the gradle version to 0.5.+. For example:
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
For me, I searched for task manager, opened it, went to more options, ended all background android studio tasks, and it worked.\
This happens because sometimes android studio does not fully close properly

Error in Android Dependencies , while integrating FB-SDK 3.0

I have tried all the threads related to errors while integrating FB-SDK but was not successful , any answers are welcomed .
My Java Compiler is set to 1.6.
I get this error while integration the Facebook SDK to my App
it is giving me the error at that marked place as
path\facebook-android-sdk-3.0.2\facebook\bin(missing)
i get this error after added this by clicking OK .
Thanks in Advance .
Before moving on, I recommend you to get latest Facebook SDK, because there are some important changes between yours (3.0.2) and 3.0.
Here's what I do to import Facebook SDK
1- Download the latest SDK, extract it to a directory, i.e. X. (~/X)
2- Open Eclipse, New Project -> Android Project From Existing Code, then browse and choose ~/X/facebook-android-sdk-3.0 as root directory
3- Select only "facebook" project and click finish
4- Right click to facebook project -> properties. Choose Compiler Compliance level as 1.6 from Java Compiler section
5- Create new android project, and set it's compliance level 1.6 as well. Also in Android section of Project Properties, Click add button, and choose facebook project (that we imported in Step 3)
6- Finally, Project -> Clean. For me this works like a charm all the time.
Have you checked if you have the facebook jar inside your fb-sdk/bin folder? If it's not there, do a clean and build procedure first in your fb-sdk folder. It will produce a facebook.jar file on your bin folder.
After that, then, you may already do another clean and build on your main project folder.

Error: Android source build in eclipse

While trying to add android source to eclipse, I am getting the following errors.
Project 'android' is missing required library: 'out/target/common/obj/JAVA_LIBRARIES/gsf-client_intermediates/javalib.jar'
Project 'android' is missing required library: 'out/target/common/obj/JAVA_LIBRARIES/google-common_intermediates/javalib.jar'
FYI, I have built the source successfully with full_maguro-userdebug configuration (for Galaxy Nexus) before adding this to eclipse. Since I couldn't find "create project from existing source" in Eclipse Indigo, I changed the location of the project to the root directory of the source. I refreshed the project several times with same error.
How to solve this issue?
You should go to Project -> Properties -> Java Build Path.
There open tab Libraries.
In this tab out/target/common/obj/JAVA_LIBRARIES/google-common_intermediates/javalib.jar should be changed to out/target/common/obj/JAVA_LIBRARIES/android-common_intermediates/javalib.jar by selecting javalib.jar from google-common_intermediates, pressing Edit and selecting instead android-common_intermediates.
Entry with gsf-client_intermediates javalib.jar can be simply deleted.
A more comprehensive answer at here: https://groups.google.com/forum/?fromgroups=#!topic/android-platform/XIbR8ZKe7Tw
I would not recommend using eclipse for android source. Android is not a single project and it too big for an IDE like eclipse to handle.
Use simpler plain text editors like vim, emacs to browse the code

Categories

Resources