i had download facebook skd import it in my eclipse add v4 jar file and change complier to 1.6 but yet it give me error in class FacebookAppLinkResolver
import bolts.AppLink;
import bolts.AppLinkResolver;
import bolts.Continuation;
import bolts.Task;
above are not import
1.Open your project properties
2.Select "Java Build Path" from left side menu
3.Select "Libraries" tab
4.Press "Add External Jar"
5.MOST IMPORTANT STEPS :-
Select "bolts" jar file of "libs" folder of YOUR CURRENT PROJECT LOCATION(Path Should be
of your project only and not the android sdk).
6.Select "Order and Export" tab and "TICK" the checkbox of "android-support-v4.jar"
Download sdk for Bolts library from
https://github.com/BoltsFramework/Bolts-Android
and add this project with facebook sdk project.
Or if you're using Gradle you can add this to your Gradle file:
dependencies {
compile 'com.parse.bolts:bolts-android:1.1.3'
}
Facebook is also available so you don't have to add that manually either. To include both use the following:
dependencies {
compile 'com.facebook.android:facebook-android-sdk:4.5.0'
compile 'com.parse.bolts:bolts-android:1.1.3'
}
You can check for the latest version of Bolts here.
amalBit's answer works great for Eclipse. Here is the Android Studio equivalent.
I encountered this error after updating to the latest Facebook SDK for Android.
File ->
Project Structure ->
Select the Facebook module on the left
Select the Dependencies tab
Press the + button at the bottom of the
window
Select File Dependency
In the libs folder, you should see the
bolts.jar file you copied over when updating the SDK.
Select the
bolts.jar file and press OK
Then press Apply and OK
Doing a Gradle Sync (happened automatically for me) should resolve the error.
I had the same problem. Check your facebook-sdk/facebook folder to see if there is a libs file (Not directory)
So I think Android studio failed to import the libs as a directory instead included a libs file with "../libs" in it.
Not sure if this was facebook-sdk issue, git cloning issue or android studio issue.
Solution:
1. remove the dummy libs file
2. copy the libs directory manually
3. remove the dependency in project structure
4. add it manually by clicking + sign
Related
I have an Android application created in Eclipse, now I want to import it to Android studio, when I import project I get the following error
Project FinalProject Integrate:/home/vishal/Android_Workspace/FinalProject Integrate/project.properties:
Library reference ../android-support-v7-appcompat could not be found
Path is /home/vishal/Android_Workspace/FinalProject Integrate/../android-support-v7-appcompat which resolves to /home/vishal/Android_Workspace/android-support-v7-appcompat
and it is an unrecoverable error.
Here's what I did: In the the project.properties file I deleted all dependencies, and while importing project in Android studio I simply followed the instructions (making sure the check box are ticked, especially the one that says add any dependency). And it worked.
Edit your build.gradle, remove the dependency of project appcompat-v7
In Android studio, Go to main menu, File -> Project structure -> Dependencies, click add icon on the right side, and add appcompat-v7 as a library dependency.
Try this: Go down to the folder where the workspace and there copy the project to another folder, then open the Android studio as administrator and try again.
I was trying to follow this post to import the mopub SDK into my app, however Android Studio is being difficult.
I unzipped the SDK, and went to Project Structure to select import a New Module. When I chose the unzipped folder, the Finish button is grayed out, and there is an error saying 'Select Modules to import'
I am using Android Studio version 0.8.6. Here is a screenshot of the error menu
I had the same issue so I had to install it manually.
First, unzip the downloaded file and then copy the unzipped mopub-sdk folder into your project directory.
Next, open your project's settings.gradle file and make sure the MoPub SDK is included as a module:
include ':app', ':mopub-sdk'
Open your app's build.gradle file (not your main project one) and add the MoPub SDK as a dependency:
dependencies {
compile project(':mopub-sdk')
}
These instructions are based of those found on the mopub github.
In eclipse, if we create a project which is having library projects inside our project, then
we cannot import this project as module in Android studio. This may be the issue
It's not fault of AndroidStudio, just try archived sdk, it works
https://github.com/mopub/mopub-android-sdk/archive/v3.9.0.zip
from https://github.com/mopub/mopub-android-sdk/releases
// sorry I don't enough reputation to post image
I struggle to import library 'PageSlidingTapStrip'(https://github.com/astuetz/PagerSlidingTabStrip).
I found this question(How to import eclipse library project from github to android studio project?), and I follow this solution.
cf)I'm using win 8.1 , android studio version 0.3.6
First, build new project like this condition.
Second, go to File -> New Module click, create new module as android library and make condition like this.( Unchecked create custom launcher icon, activity )
And this part I got a first question. Which version should I choice version about 'Minimum required SDK' , 'Target SDK', 'Compile with'? Just Follow project version? (image show default value when I create this window first.)
Anyway, I progress under condition ' Minimum required SDK : API 9 / Target SDK : API 19 / Compile with : API 19 '
Third, delete files under 'Project/PageSlidingTabStrip/src/main/' and copy folder&file under external library 'res', 'src', 'AndroidManifest.xml' and move into 'Project/PageSlidingTabStrip/src/main/' then renamed src to java.
And then project & folder become like this. (what I followed question as , told me copy and move file 'ic_launcer-web.png' apart from 'res', 'src', 'manifest' , but I can't find that file)
Fourth, go to 'File -> Project setting -> Module -> click project module -> '+' button -> select Module dependency' then apply.
After that, I face this error and cannot resolve R.
And I can't go next step, can't finish import library.
What should I do?
Is there any other solution?
Thanks for seeing long question. I hope to get a solution!
I also use the PagerSlidingTabStrip Project in my app and everything works fine.
I'm not sure if it's already possible to add a library project via the IDE (-> without any problems).
Please try to add the library project by editing the gradle files like this:
first delete your module PagerSlidingTabStrip
then create a folder in your root project directory (-> NewOne) named 'libs'
copy the complete folder 'library' of the PagerSlidingTabStrip project on git into 'libs'
rename the folder 'library' that you just copied to e.g. "PagerSlidingTabStripLibrary" (just to avoid confusion) -> after the renaming you should have the path: "NewOne/libs/PagerSlidingTabStripLibrary"
now add this library in your settings.gradle with the following command:
include ':libs:PagerSlidingTabStripLibrary'
go to your build.gradle file of your AppProject aps and add the following line to your 'dependencies':
compile project(':libs:PagerSlidingTabStripLibrary')
at least you have to sync your gradle files: Tools -> Android -> Sync Project with Gradle Files
Please try this. If you get errors please post the log file.
For update up to Android Studio 1.2.1.1
There are basically three types of dependencies which we have to add in project of android Studio
Add Normal Dependencies like Support files
Right click on project->open module settings
Select dependencies->Now press right "+" icon button ->Select
library Dependencies
Enter Name and Search
Select file and press ok button.
Add Git Hub Dependencies
Find the dependencies of git repository for example compile 'com.jakewharton:butterknife:6.1.0' from https://github.com/JakeWharton/butterknife
A. open build.gradle(module:app) file
B. Add lines compile 'com.jakewharton:butterknife:6.1.0'
OR
Follow as describe above in Normal Dependencies Step by just enter dependencies in search bar
Add Jar files Dependencies
Right click on project->open module settings
press left "+" icon (insert new Module) button -> Select import Jar or .AAR package->browse Jar file and finish
Now select dependencies-> press right "+" icon button ->Select module Dependencies->select jar files->press ok button.
For what it's worth I had this problem and eventually solved it by consistently using the same sdk version & build tools across projects.
android-studio 0.2.7
Fedora 18
Hello,
I am trying to add the jtwitter jar to my project.
First I tried doing the following:
1) Drag the jtwitter.jar into the root directory of my project explorer, see picture
2) File | project structure
3) Modules | yamba-yamba | dependencies
4) Click the plus sign | jars or directories | and navigate to jtwitter jar | click ok
When I import the jar file I get the following error:
import winterwell.jtwitter.Twitter;
Cannot resolve symbol winterwell
Gradle: error: package winterwell.jtwitter does not exist
I researched and found that android-studio has some issues and that you have to edit the build.gradle file yourself.
So I tried adding this to my build.gradle file:
dependencies {
compile files('libs/jtwitter.jar')
And got an error message: cannot resolve symbol dependencies
Another question, where would the libs folder be. Does it mean the External Libraries?
Try this...
Create libs folder under the application folder.
Add .jar files to libs folder.
Then add .jar files to app's build.gradle dependency.
Finally Sync project with Gradle files.
1.Create libs folder:
2.Add .jar to libs folder:
3.Edit app's build.gradle dependency:
Open app/build.gradle
4.Sync project with Gradle files:
Finally add .jar files to your application.
UPDATE:
Here I'm going to import org.eclipse.paho.client.mqttv3.jar file to our app module.
Copy your jar file and paste it in directory called libs.
Press Ctrl + Alt + Shift + s or just click project structure icon on the toolbar.
Then select your module to import .jar file, then select dependencies tab.
Click plus icon then select File dependency
Select .jar file path, click OK to build gradle.
Finally we're imported .jar file to our module.
Updated answer for Android Studio 2
The easy and correct way to import a jar/aar into your project is to import it as a module.
New -> Module
Select Import .JAR/.AAR Package
Select the .JAR/.AAR file and put a module name
Add the module as a dependency
Running Android Studio 0.4.0
Solved the problem of importing jar by
Project Structure > Modules > Dependencies > Add Files
Browse to the location of jar file and select it
For those like manual editing
Open app/build.gradle
dependencies {
compile files('src/main/libs/xxx.jar')
}
In the project right click
-> new -> module
-> import jar/AAR package
-> import select the jar file to import
-> click ok -> done
You can follow the screenshots below:
1:
2:
3:
You will see this:
Android Studio 1.0.1 doesn't make it any clearer, but it does make it somehow easier. Here's what worked for me:
1) Using explorer, create an 'external_libs' folder (any other name is fine) inside the Project/app/src folder, where 'Project' is the name of your project
2) Copy your jar file into this 'external_libs' folder
3) In Android Studio, go to File -> Project Structure -> Dependencies -> Add -> File Dependency and navigate to your jar file, which should be under 'src/external_libs'
3) Select your jar file and click 'Ok'
Now, check your build.gradle (Module.app) script, where you'll see the jar already added under 'dependencies'
This is how you add jar files from external folders
Click on File and there you click on New and New Module
New Window appears ,,There you have to choose the Import .JAR/.AAR package .
Click on the path option at the top right corner of the window ...And give the whole path of the JAR file .
4)click on finish.
Now you have added the Jar file and You need to add it in the dependency for your application project
1)Right click on app folder and there you have to choose Open Module Settings or F4
2)Click on dependency at the top right corner of the current window .
3)Click on '+' symbol and choose 'Module Dependency' and It will show you the existed JAR files which you have included in your project ...
Choose the one you want and click 'OK/Finish'
Android Studio 1.0 makes it easier to add a .jar file library to a project.
Go to File>Project Structure and then Click on Dependencies. Over there you can add .jar files from your computer to the project. You can also search for libraries from maven.
This is the way I just did on Android Studio version 1.0.2
I have created a folder libs in [your project dir]\app\src
I have copied the jtwitter.jar (or the yambaclientlib.jar) into the [your project dir]\app\src\libs directory
The following the menu path: File -> Project Structure -> Dependencies -> Add -> File Dependency, Android Studio opens a dialog box where you can drag&drop the jar library. Then I clicked the OK button.
At this point Gradle will rebuild the project importing the library and resolving the dependencies.
I see so many complicated answer.
All this confused me while I was adding my Aquery jar file in the new version of Android Studio.
This is what I did :
Copy pasted the jar file in the libs folder which is visible under Project view.
And in the build.gradle file just added this line : compile files('libs/android-query.jar')
PS : Once downloading the jar file please change its name. I changed the name to android-query.jar
There are three standard approaches for importing a JAR file into Android studio. The first one is traditional way, the second one is standard way, and the last one is remote library. I explained these approaches step by step with screenshots in this link:
https://stackoverflow.com/a/35369267/5475941.
I hope it helps.
If the code for your jar library is on GitHub then importing into Android Studio is easy with JitPack.
Your will just need to add the repository to build.gradle:
allprojects{
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}
and then the library's GitHub repository as a dependency:
dependencies {
// ...
compile 'com.github.YourUsername:LibraryRepo:ReleaseTag'
}
JitPack acts as a maven repository and can be used like Maven Central. The nice thing is that you don't have to upload the jar manually. Behind the scenes JitPack will check out the code from GitHub and compile it. Therefore it works only if the repo has a build file in it (build.gradle).
There is also a guide on how to prepare an Android project.
Avoid redundancy. If you have your jars under /libs in your app build.gradle by default you will have
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
...
}
that is enough to add all the jars you have under /libs
this is not necessary
// compile files('libs/activation.jar')
// compile files('libs/additional.jar')
// compile files('libs/mail.jar')
I also faced same obstacle but not able to find out solution from given answers. Might be it's happening due to project path which is having special characters & space etc... So please try to add this line in your build.gradle.
compile files('../app/libs/jtwitter.jar')// pass your .jar file name
".." (Double dot) will find your root directory of your project.
In my android project I am writing a program to connect to a server and below are the libraries that I need to use.
But I get an error saying the following cannot be resolved. How to resolve this error? I am using eclipse JAVA EE on Windows.
import org.apache.http.entity.mime.MultipartEntity;
import org.apache.http.entity.mime.content.ContentBody;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.entity.mime.content.StringBody;
Add these two dependency
compile "org.apache.httpcomponents:httpcore:4.2.4"
compile "org.apache.httpcomponents:httpmime:4.3"
It will work.
Download the jars from the apache commons site and add them to project and path.
[Edit] now in Apache HttpComponents http://hc.apache.org/downloads.cgi
I know this is an old thread but it make be worth mentioning that these jars are now included in the eclipse Android ADT bundle (for MAC anyway, I have not checked for Windows). You do need to check the version is the one you want, but if it is you are good to go.
This means you can add them to your project without having to download them separately first - just follow these steps:
First right click your project and select properties as shown below:
Then select Java Build Path from the pop up window:
and now select the 'Libraries' tab:
and click on 'Add external JARS' and navigate to your ADT bundle/sdk/tools/lib/httpclient (httpmime etc), and then just click open:
You also need to import the Jar file itself into your project. I found the best way to do this was to simply copy the JAR files into the 'libs' folder in your project - i.e. CTRL C and CTRL V, or normal drag and drop file copy. To be safe I would refresh (right click project and select refresh - see menu in first picture above) and then clean your project.
Note if you do the Build Path part above correctly but forget to add the JAR files themselves into your 'libs' folder, you will get an error like:
'Caused by: java.lang.NoClassDefFoundError: org.apache.http.entity.mime.content.FileBody'.
To resolve this just copy the jar files into the 'libs' folder in your project.
You should now be good to go!
download the jar from here : http://commons.apache.org/
install it in your project like this:
Right click on your project and go to properties.
On the left tab go to "java build path". And in that on right go to libraries.
Click on add external jars and give the path of the jar and your library is added.
try to download it from HttpClient Downloads
Download the JAR file "httpmime-4.0-beta2.jar" and add it to your project
If you are using android studio add the following import to your code:
import org.apache.http.entity.mime.content.FileBody;
The IDE will give you an error under "mime" and ask you if you would like to install the dependancy. So if you say yes it will search for it online and then you can download it to app/build/libs directory.
FileBody will then be recognized after this process is complete.
Add
compile files('libs/httpcore-4.3.2.jar')
compile files('libs/httpmime-4.3.4.jar')
to your build.gradle.
Before that download .jar from
http://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore/
http://mvnrepository.com/artifact/org.apache.httpcomponents/httpmime
and to your apps>lib folder.