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.
Hi I have found this github project:
https://github.com/ManuelPeinado/FadingActionBar
I have tried to import "samples-stock" and "library" into eclipse. Then I assign "library" as a library and add it in "samples-stock".
How would you make it work? I dont understand the authors instructions:
The library is pushed to Maven Central as a AAR, so you just need to add the following dependency to your build.gradle.
Thanks
Does your project, in which you want to use this lib, uses Gradle as build system?
If so, add dependency to build.gradle, as author suggests:
dependencies {
compile 'com.github.manuelpeinado.fadingactionbar:fadingactionbar:3.1.2'
}
Else, I believe Android Studio is Intellij IDEA Community Edition, just with android plugin, thus you should be able to add dependency from "Maven" in Libraries. Just copy & paste the
"com.github.manuelpeinado.fadingactionbar:fadingactionbar:3.1.2"
line to the window which opens.
In eclipse:
File->Import->Existing android code into workspace and import library from disk drive.
If you want to run samples that are present in that library you can run them as "Android Application", like any other project.
If you want to use it in your project:
Right click on your project -> Properties -> Android -> Add(select that library) and you are good to go.
I want to use google map in my application
I Have Added google-play-services_lib as project and set as library , And then i have added google-play-services_lib to my project
if i check again it marked as red icon
Can you please help to resolve this
I am assuming you haven't imported the library in correct way.In order to work, the library project and your main project need to be in the same workspace. While importing google-play-services to eclipse make sure you have checked Copy Projects into workspace option as shown in the below image,
Else you can also copy paste the google-play-services library project into your workspace and then import it from there.
You no longer need to add the Google Play Service library in your project. Adding
compile 'com.google.android.gms:play-services:4.3.23'
under dependencies does the job.
Edit:
If you don't know how to add dependencies in Eclipse, take a look here.
In Android Studio (or any other Gradle based IDE), just open build.gradle and add the above line between dependencies brackets.
I recently downloaded Android Studio to develop Android applications (I'm coming from Eclipse), and I am having issues using external libraries and/or external JAR files alongside my own project. NOTE: the following tests were conducted on a new application project created from scratch in Android Studio.
Example 1: JAR Import.
Download a fresh copy of the Admobs SDK from Google.
Copy the library jar GoogleAdMobAdsSdk-6.4.1.jar to the project's /libs/ folder.
In the project explorer, right click on the newly added library.jar and click on 'Add as Library'.
Technically at this point everything works, imports work just fine, the layout editor shows a preview of the AdView widget and all that. The only problem is that it doesn't compile successfully.
Log from console:
Gradle:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':APITests:compilePaidDebug'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Could not execute build using Gradle distribution 'http://services.gradle.org/distributions/gradle-1.6-bin.zip'.
I tried running gradlew compileDebug --stacktrace, and the problem seems to be that the despite being able to import the classes successfully in both the code & design editor, at compile time, it cannot resolve the imports. Here's the relevant part of the log: (full stacktrace here)
java:6: error: package com.google.ads does not exist
import com.google.ads.AdRequest;
java:7: error: package com.google.ads does not exist
import com.google.ads.AdView;
java:11: error: cannot find symbol
AdView mAdView;
symbol: class AdView
location: class MainActivity
java:22: error: cannot find symbol
mAdView = (AdView)this.findViewById(R.id.adView);
symbol: class AdView
location: class MainActivity
java:23: error: cannot find symbol
mAdView.loadAd(new AdRequest());
symbol: class AdRequest
location: class MainActivity
5 errors
:Test:compileDebug FAILED
But again, the imports work well in the editor, and the dependency is there:
It's also worth noting that without attempting to add a library/JAR, the projects compiles just fine.
I then tried editing the build.gradle file to include the new lib like this:
dependencies {
compile files('libs/android-support-v4.jar', 'libs/GoogleAdMobAdsSdk-6.4.1.jar')
}
This time, it did compile successfully, but the app now forces closes, as apparently, it cannot find a specific class from the lib in the application package.
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.ads.AdView" on path: /data/app/com.foo.test-1.apk
Any ideas?
So,
Steps to follow in order to import a JAR sucesfully to your project using Android Studio 0.1.1:
Download the library.jar file and copy it to your /libs/ folder inside your application project.
Open the build.gradle file and edit your dependencies to include the new .jar file:
compile files('libs/android-support-v4.jar', 'libs/GoogleAdMobAdsSdk-6.4.1.jar')
File -> Close Project
Open a command prompt on your project's root location, i.e 'C:\Users\Username\AndroidStudioProjects\MyApplicationProject\'
On the command prompt, type gradlew clean, wait till it's done.
Reopen your application project in Android Studio.
Test run your application and it should work succesfully.
You don't need to close the project and go to command line to invoke grade:clean.
Go to Build-> Rebuild Project
Easy way and it works for me. Using Android Studio 0.8.2.
Drag jar file under libs.
Press "Sync Project with Gradle Files" button.
"simple solution is here"
1 .Create a folder named libs under the app directory for that matter any directory within the project..
2 .Copy Paste your Library to libs folder
3.You simply copy the JAR to your libs/ directory and then from inside Android Studio, right click the Jar that shows up under libs/ > Add As Library..
Peace!
Here is how I got it going specifically for the admob sdk jar file:
Drag your jar file into the libs folder.
Right click on the jar file and select Add Library
now the jar file is a library lets add it to the compile path
Open the build.gradle file (note there are two build.gradle files at least, don't use the root one use the one in your project scope).
Find the dependencies section (for me i was trying to the admob -GoogleAdMobAdsSdk jar file)
e.g.
dependencies {
compile files('libs/android-support-v4.jar','libs/GoogleAdMobAdsSdk-6.3.1.jar')
}
Last go into settings.gradle and ensure it looks something like this:
include ':yourproject', ':yourproject:libs:GoogleAdMobAdsSdk-6.3.1'
Finally, Go to Build -> Rebuild Project
you export the project from Eclipse and then import the project from Android Studio, this should solve your problem, open a eclipse project without importing it from Android Studio you can cause problems, look at:
(Excuse my language, I speak Spanish.)
http://developer.android.com/intl/es/sdk/installing/migrate.html
I had the problem not able to load jar file in libs folder in Android Studio.
If you have added JAR file in libs folder, then just open build.gradle file and save it without editing anything else. If you have added this line
compile fileTree(dir: 'libs', include: ['*.jar'])
save it and clean the project .. In next build time Android Studio will load the JAR file.
Hope this helps.
I'm using Android Studio 0.5.2. So if your version is lower than mine my answer may not work for you.
3 ways to add a new Jar to your project:
Menu under Files-->Project Structure
Just press 'F4'
under Project navigation, right clink on any java library and a context menu will show then click on 'Open Library Settings'
A Project Structure window will popup.
On the left column click on 'Libraries' then look at the right pane where there is a plus sign '+' and click on it then enter the path to your new library.
Make sure the new library is under the 'project\libs\' folder otherwise you may get a broken link when you save your project source code.
I am currently using Android Studio 1.4.
For importing and adding libraries, I used the following flow ->
1. Press **Alt+Ctr+Shift+S** or Go to **File --> Project** Structure to open up the Project Structure Dialog Box.
2. Click on **Modules** to which you want to link the JAR to and Go to the Dependency Tab.
3. Click on "**+**" Button to pop up Choose Library Dependency.
4. Search/Select the dependency and rebuild the project.
I used the above approach to import support v4 and v13 libraries.
I hope this is helpful and clears up the flow.
I use android studio 0.8.6 and for importing external library in project , paste that library in libs folder and inside build.gradle write path of that library inside dependencies like this
compile files('libs/google-play-services.jar')
In Android Studio (mine is 2.3.1) go to File - Project Structure:
Check the libs version requirements. The lib might be trying to call a method from from a higher Android version. Try adding the apps compatability libs.
When all else fails try switching from a Gradle build to an Eclipse build.
Delete and restructure your folders to the eclipse style and delete everything but your code. Then reload the project with your libs.
Once it runs go back to Gradle, if you wish.
I am developing an Android app and I'm trying to include GraphView to plot some graphs.
It is required to include it as a module dependency. After I do that, the IntelliJ IDE properly detects the packages and I can import them, but compiler throws errors when trying to compile:
package com.jjoe64.graphview.GraphView does not exist
cannot find symbol class GraphView
etc.
I followed this guide to include it: http://wiki.jetbrains.net/intellij/Sharing_and_re-using_Android_resources_through_library_projects
If it still occures to anyone , for me the reason was that the module's Android class libarary source folder was not marked as 'Sources' directory .
Simply click on the sources folder and choose mark directory as --> source folder.
After that instead of compile , choose 'make' , and then it will start working for you.
Best of luck with that annoying bug !
I had the same problem and this is how I solved it:
I was using Gradle so I right-clicked on the build.gradle.kts (it may just be build.gradle in your case) and clicked on "Import Gradle project" and everything worked again!