So I'm trying to implement jfeinsteins slide menu into my application, but before I do that I want to get a good demo, so I know how to implement it. Problem is that I'm stuck.
this is where I'm getting the library.
https://github.com/jfeinstein10/SlidingMenu
This is the project I'm trying to implement it in.
https://github.com/baruckis/Android-SlidingMenuImplementation
I did this part for the set up.
In Eclipse, just import the library as an Android library project. Project > Clean to generate the binaries you need, like R.java, etc.
,but I'm not sure I'm completely understanding this part.
Then, just add SlidingMenu as a dependency to your existing project and you're good to go!
how do I add slidingMenu as a dependency. Also, the error I'm receiving is SlidingMenu cannot be resolved to a variable, SlidingMenu cannot be resolved to a type.
Please can someone help me answer this!? Am I close?
To add a dependancy to an existing project, select the project containing your code (the one you want the dependancy to attach to), right click the project in the Package Explorer and select Properties.
In the Properties window, select Android and ensure that the library projects are added in the Library section. Click add to add an existing project in the workspace to the project as a dependancy.
It may also be worth checking dependancies in the Java Build Path too. Here you can ensure the correct .jar files are correctly assigned to your projects.
I was stuck at this place too. Please follow the below steps.
After downloading the library. In eclipse, go to New->project->android existing project
After downloading SlidingMenuImplementation, add this to eclipse similar to the way above.
I hope till here you have done. Next, right click on the SlidingMenuImplementation project --> properties --> Android --> Below the target window, you'll find references.
Add the Slidemenu library there. Once done clean the project. The errors are gone.
Please note, this supports only Android 4 and above. For lower versions use ActionBarSherlock.
Related
IntelliJ newcomer here. I'm having some issues getting my project dependencies working:
So I have a project called ClearDialogue. It's an IDE for making branching dialogue for video games. It relies on my other project, Clear (ClearVG and ClearWindows) for creating its window and also rendering the UI. ClearDialogue also depends on LWJGL3 and a few other dependencies. The projects use Maven to manage its dependencies.
Clear is a project on my machine that I've set up in IntelliJ and successfully ran its demos. ClearDialogue however is where my trouble started; it relies on Clear to work, which is another project (not a JAR thats uploaded for it to fetch). So what I'm saying is: I need to be able to use another IntelliJ project as a library in ClearDialogue.
According to other similar questions, I can achieve this by referencing the other project in the pom file of the project that's referencing it. So I did that and it actually did appear in the "External Libraries" dropdown:
.
There are a few problems:
1) Despite Clear appearing in the External Libraries section, it's still not being recognized by the IDE as a library and when I try to build the project, errors like this are printed to the console:
.
2) It seems that Clear is the only library being downloaded despite LWJGL3 and other libraries being designated as dependencies in the pom file. They aren't being downloaded and aren't appearing in the External Libraries tab. That said, Clear itself uses some of the same libraries (LWJGL3) so is it that it's just making sure they aren't duplicated? Either way, the code itself is drawing red lines because it can't find the LWJGL3 libraries.
Does anyone know ways to fix these issues? Thanks in advance.
I managed to fix both of these problems myself.
To solve the first problem of using another project as a dependency, I was able to use the maven attributes of the projects to do so. I referenced Clear in ClearDialogue's pom file like this:
.
Then I opened the Maven view (View -> Tool Windows -> Maven) and added the pom files from Clear's own modules to the list along with the needed modules within the project itself:
.
After this I pressed the "Reimport all Maven Projects" button (the button in the picture above that looks like a refresh button) and rebuilt the project (Build -> Rebuild Project). This successfully downloaded all of my needed libraries and successfully added the local libraries from my own projects only available on the machine as well. With that I was able to successfully run to program as well.
As for the second half of my problem, I was able to find this answer from another question here on Stack Overflow, which coincidentally was how I was able to figure out how to add local dependencies as well.
I've spent all afternoon getting absolutely nowhere with this.
I've downloaded Eclipse, downloaded the SDK, installed the updates, but every new Android project I create something's wrong.
Firstly, it would not generate the R.java file, at all, now it does but there's a separate project it's created automatically called appcompat_v7. I don't know what this is, but it's causing problems with any other new project.
This is the error a normal project produces:
The container 'Android Dependencies' references non existing library '/home/omar/workspace/appcompat_v7/bin/appcompat_v7.jar'
I have absolutely no idea how to fix this. What is causing this?
EDIT
It appear this is only with KitKat, every other API platform doesn't produce ANY source files at all.... any idea how to combat this?
It's a support library which presumably your project refers to. You will need to build it as a library project in your workspace. This process is described here Support Library Setup under Adding libraries with resources.
You will find the project you need to copy in your SDK in the folder:
\yourSDKlocation\tools\android-sdk-windows4.4\extras\android\support\v7\appcompat
(It's no use just copying a jar, you must build it as a library project.)
I had this problem when I moved a project to a different laptop. I solved it like this:
If appcompat_v7 is not available in Eclipse:
From the File menu, choose New then Project.
Next, choose Android and Android Project from existing Code, then click next
Browse to find your appcompat_v7 project folder
Make sure there’s a check mark next it in the ‘Projects to Import’ list
If the appcompat_v7 project folder is not currently in your workspace, select ‘Copy projects into workspace’, then click Finish
Now that the library project is available in your workspace, it can be added to a project:
Choose your project from the Project Explorer and open the project properties (on a mac it’s in the Project menu)
Click on Android in the left list
Next to the Library list, click the Add button
Choose appcompat_v7 from the list
You should be good to go now.
So I am fairly new to Java, and I am trying to add this library to my project. The problem is that Android studio 0.3.6 doesn't have a simple way of doing that and all the answers I searched either reference an older version of Android Studio, or describe how to import an external project (source code, not jar file).
After reading a little, I got to the conclusion that manually adding the jar file would be the best way (manual copy/paste and gradle edits) but as I said, I'm fairly new to this technology and don't know where to place the file nor what lines I need to add to the gradle files.
Can someone help me?
UPDATE 1:
I finally made the IDE recognize the .jar file (I get autocomplete and class recognition). The new problem is that I get the following error when compiling: Gradle: package com.google.gson does not exist. Here are the steps I took to import the library:
Creat a folder called libs in the main directory (src/main/libs should be the result)
Copy the .jar file in that directory
add the following line to the dependencies section in the build.gradle file in your project: compile files('libs/gson-2.2.4.jar'). It should look something like this now:
dependencies {
compile 'com.android.support:support-v13:+'
compile files('libs/gson-2.2.4.jar')
}
Recompile the project (not sure if necessary, but I did it)
Right click on the libs folder and select "Add as Library"
Since the GSON library is available in MavenCentral, there's an easy way to add it that avoids having to download an archive file and save it in your project.
Go to Project Structure > Modules > Your module name > Dependencies and click on the + button to add a new dependency. Choose Maven dependency from the list:
You'll get a dialog box where you can enter search terms or the fully-qualified Maven coordinate string. Since GSON is a common library for Android developers to use, it's actually given in this dialog as an example, with the fully-qualified name. You can type it in:
Hit OK on both dialogs and you should be good to go.
With these Maven dependencies, the build system will automatically download the library and cache it if hasn't done so already; it takes care of that for you.
If you had a library that wasn't available on MavenCentral, you could save the archive in a libs folder in your project, and from that module dependencies dialog, add a File dependency instead of a Maven dependency to take care of it.
If you edit your build.gradle file by hand, you need to click on the "Sync Project with Gradle Files" button in the toolbar to force Android Studio to pick up the changes and update your project. If you go through the Project Structure dialog, that's unnecessary.
There are lots of conflicting answers to this issue in Stack Overflow because the functionality for this is in flux as the necessary features are implemented; it has been really broken before. These instructions should work properly for 0.3.6, and things will get a little easier in 0.3.7 and later.
I had the same issue. The new version of Android Studio (0.3.6) removed some necessary features to add an existing library to a project using the IDE. So you have to do this manually.
Adding the library into the build folder "<project>\App\build\libs\" will break the project on "menu > build > clear project / rebuild project".
Updated solution
My solution is to generate a new folder inside "<project>\<app name>\src\main\libs\" and add the library here. Now you have to change your "<project>\<app name>\build.gradle" by adding the following (my example shows the value for android-support library:
dependencies {
compile 'com.android.support:support-v4:13.0.0'
compile 'com.android.support:support-v13:13.0.0'
compile files('libs/gson-2.2.4.jar')
}
Now select the library in "project View" by right click and select "Add as library... > level > Global library". This will fix an import com.google.gson.Gson; issue.
Maybe you still cannot build. In this case you shall check you project module settings and see if there is an error for Gson dependency. I let Android Studio fix this issue by hitting a "small red bulb icon > add dependency" in the lower right corner of module settings dialog. Now it does not show me no errors anymore on build.
Now we have only one remaining problem: The project does lose the library reference on project close. So we have to add the library on open again. Maybe this is an issue of Android Studio 0.3.6. Mario filed a bug report.
BTW: I upvoted this question because I searched without success for a working solution in the internet. I think beginners will always fail to work with the Android developer tutorials of Google when they are forced to deal with the support library.
Update / Recommendation
Unfortunately I did not get AS 0.3.6 working properly. There are to many issues - at least when adding another module with different namespace. So I switched to the origin IDE: IntelliJ IDEA 12 community Edition. It's free and works for me. I did all the stuff in 2 hours which need days using broken Android Studio. I have no idea what forces Google to build its own IDE based on IntelliJ IDEA without additional benefits / noticeable features when the latter works like a charm.
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')
}
I posted the same to
importing jar libraries into android-studio
putting a duplicate here just in case you stumble into this post instead
Click on ProjectName->Libs folder.Paste that jar file into that folder.
Just refresh the project.You are done.
Using Android Studio 0.8.2, I had to do the following (supposing the library you're trying to add is called MyExternalLib):
In the "app/libs" folder on the hard disk, create a sub-folder "MyExternalLib", and copy the external library into that folder.
In the file "app/build.gradle", inside the block named "dependencies", add the line compile project('libs:MyExternalLib')
In the file "settings.gradle", add the line include ':app:libs:MyExternalLib'
Click the button "Sync Project with Gradle Files"
Create a new library module
It is good development practice to group functionality that you may reuse in other apps inside a library module. To create a library module inside the BuildSystemExample project:
Click File and select New Module.
On the window that appears, select Android Library and click Next.
Leave the default module name (lib) unchanged and click Next.
Select Blank Activity and click Next.
Type "LibActivity1" on the Activity Name field and click Finish.
The project now contains two modules, app and lib, with one activity in each module.
https://developer.android.com/sdk/installing/studio-build.html
So these are the three missing libraries, that I still didn't manage to add to my imported project. I tried a lot of things and it simply won't work. I downloaded google play services with SDK manager and google-play-services_lib isn't there, while google-play-services is there, but I need both. As for CaptureActivity and PortraitQR, I tried adding both jars from the project dexedLibs but it didn't work. I also tried downloading this but I don't know how to add it to the project (I only know how to add single jars)
EDIT: Okay so I played around a little bit and I think I'm closer to a solution now. I manually added google play services lib and capture activity and this is how libraries look like now:
The only remaining problem is that now there is a red exclamation mark next to my project and when I go to build paths there is this red error:
I tried to look for captureactivity.jar but I can't find it. Can anyoe help me out here?
you should import them with new project->Android project from existing code-> then locate your projects path and also make sure you make them library project; right click on project-> properties-> android -> scroll to bottom and check 'is library' checkbox
and the path for google play services lib is =>
\extras\google\google_play_services
you can also find sample code on there
These three are library projects. Let's say you have a project in your IDE which is called "PortraitQR". It must be open before your project, Evanturist, can see it as a library project. And it's the same story for the other two library projects. If it doesn't work, try removing them in the dialog you've shown here and adding them again.
You should not use any .jar files for this to work. You should have these three projects open in your IDE.
I am a very beginer, trying to create my first Android application.
To do so, I use Eclipse and an AVD. I created my very first Class (called "Test") and when I run the project it says "Could not find Test.apk!"
I had a look at many solutions an internet:
- delete and import
- clean up my project (I have only one class so there is not much to clean
And it still does not work.
Do you have any idea about how to proceed to fix this up?
Many thank for you help.
You don't give much information to know what's wrong. What steps did you take to create this application?
Does your class Test extend the class Activity?
If it does, is it declared in your project's AndroidManifest.xml file?
Also, make sure that your project is not set up as a library project. Right click on your project's name, select Properties->Android and make sure that IsLibrary is not checked.
Possible solutions:-
Sometimes the apk file is not generated simply because there are some
android build error in your project, In this case, right click your
project, choose Android Tools -> Fix Project Properties.
Is your project termed as library, in this case, Go to
Project->Properties--> Select Android from left-hand side list -->
Uncheck the "Is Library" checkbox
Delete R.java file then clean build project or restart eclipse, this
will force the workspace to be rebuild.
what version of eclipse are you using, version of Eclipse
using(Ganymede – 3.4) is not compatible with the latest version of
the SDK. Try updating Eclipse..
Hope this helps..