I'm created a jar file for my appengine (python) application. I've followed the steps to import my library (.jar) files from this example. It seems Android Studio imported everything correctly (no error) until I try to use the classes in the library. I started to open up the classes that are contained in the jar files to see if everything looked to be in order. This is what I found:
UserMessage does not contain any errors.
Can anyone help explain why the classes can't see/use each other? Is this an issue with the jar or Android studio?
I had the same problem with Android Studio and Eclipse.
My solution is probably not the best and the easiest, but it works.
What I did is I extracted the code from the .jar file and placed it inside src.
Now I have something similar to the following structure:
Related
I'm trying to use Google's Downloader Library and Application Licensing Service since my app is going to use APK Expansion. But the problem is I don't know how to add those 2 libraries to Android Studio. I always import libraries to Android Studio by File -> Import Module and then I select it.
But when I do that this time, it says:
Select modules to import
Even after I've already selected the Downloader Library or Licensing Library.
I also tried importing them by copying the directories to my app directory and then including them in gradle dependencies but that doesn't work either.
Could someone walk me through adding these 2 libraries to my Android Studio because I can't seem to figure it out.
For anyone else coming along with similar problem.
I solved it by importing module (File->New->Import Module) and selecting the licensing and the downloader library folders each time.
Note however that the .project file for downloader has a line that throws Android off (correctly):
android.library.reference.1=../market_licensing
Remove this line and the module imports fine.
Thank you Google once again for your clear instructions and clean environment!!!
BTW: What the heck are they writing in their guide
http://developer.android.com/google/play/expansion-files.html#AboutLibraries
"Select the Properties tab and in Library Repository, enter the
library from the /extras/google/ directory (play_licensing/ for
the License Verification Library or
play_apk_expansion/downloader_library/ for the Downloader Library)."
Does that even make any sense to anyone?!
I solved the problem in a very weird way.
I noticed that I can't import those 2 libraries directly to Android Studio because they are missing a lot of project files and therefore Android Studio doesn't recognize them as libraries.
I then imported both libraries to Eclipse so that everything neccessary was generated and then exported them directly to Android Studio.
That worked like a charm.
Maybe a weird way to import a library but at least it worked.
I just wanted to add a comment that the .project file for downloader should point to correct dependency:
android.library.reference.1=../../market_licensing/library
Now importing downloader will also import licensing which depends and create the correct dependency.
EDIT: That libraries are rather old. I've found new versions here:
https://github.com/google/play-apk-expansion
https://github.com/google/play-licensing
When I tried to import library, I met same issue, and I could resolve by adding 'include ':library-directory-name'
copy your library directory into your project
add "include ':library-directory-name'" in settings.gradle file same as include ':app'
I am new in android. I see a lot of android libraries out there like github.com but when I download them none of them are a *.jar file like this one:
NumberProgressBar
It seems that all these libraries are for android studio NOT eclipse (Am I correct? This is important).
My question is: How do I use these libraries in eclipse?
I tried to import the downloaded library as an android project and then mark it as "is library" and then add to my project, but that did not work.
That library is designed to be built with Gradle for Android (with or without Android Studio), producing an AAR.
Eclipse does not have native AAR support. I have published a recipe and a Ruby script to convert an AAR into a library project that Eclipse can use, though I have not tested it much.
Or, you can download the source code and attempt to reorganize it into an Eclipse-style library project.
I just downloaded it and add it as library project and everything looks fine. How do you do it, it's extremely simple. Let us know in which step you have a problem so we can figure out what is wrong.
You have to build the library first.
For your example, read the Readme file, section 'Build'.
I am going to use SkyEpub 3 library in my android application to read ebooks in epub format. To get familiar with the method of using SkyEpub I have downloaded its android demo project from here.
Its demo project is working properly, But when I use the skyepub.jar in my own project, it says some methods and classes from the jar file are undefined. Of course in the mean time I am using an unlicensed version of this library. I want to test it before buying the license if it was ok. I doubt that the errors are because of using the unlicensed version of the library in my project.
Can any one tell me please what is the problem exactly?
Thank you in advance.
Because there are a lot of classes ,which are not in jar, in example project. In the example, they create a lot of classes by extends another classes from jar. I used this jar before.
I found what was the problem. I increased priority of the jar file in eclipse. Now it works.
I am trying to use Google's URL Shortening service in my Android app. I have imported the necessary jar files as mentioned here
I am following this as my reference to code from.
I am able to import the HTTPTransport class from com.google.api.client.http, but I am not able to import the GoogleTransport, GoogleHeaders, JsonHttpParser, nor Result, and JsonHttpContent doesn't seem to have the no-arg constructor given in the example I'm looking at.
Below is a screenshot of my project properties window, on the Libraries tab.
Copy all your jar files in your project libs folder. And remove these jars from Build Path Libraries as showing in image.
It turns out that you can use the Google Plugin for Eclipse to add an API to an Android project, as detailed here. Unfortunately, I still have the problem that I can't use the classes in any example I have found thus far. I guess I must just be using the library wrong.
I'm just getting started in Android development, and use Netbeans with NBAndroid and SDK 17.
I'd like to use the same Java source code in my Java and Android app.
http://developer.android.com/guide/developing/projects/projects-eclipse.html says how to do it in Eclipse (although it is sketchy on the .JAR connection thing), but I can't seem to make it work in NB.
Based on that link, My understanding is that the correct setup for the Android app is an Android Application project which references an Android Library project which in turn references a .JAR library produced by a Java Library project. I could then also have a Java Application project referring to the same Java Library project.
So, I've set up this project structure... I have an AndroidApp project which is a basic HelloAndroid Activity in a com.ex package. This project includes an AndroidLib library project in the Libraries folder. I also have a LibClass.java file which defines a simple LibClass class which has one function getText() that just returns a String to be displayed. The MainActivity in the AndroidApp calls this to get the String to output.
When I put LibClass.java directly into the AndroidLib project, everything is fine.
But what I want to do is to share the source code with Java.
So I want to move the LibClass.java into the JavaLib library, whose .JAR file is included in the AndroidLib project. However, when I tried that, I get an error in the MainActivity class, complaining it can't find LibClass. Looking at the Projects window, I can see LibClass.class inside the com.ex package in the JavaLib.jar in the Libraries folder of the AndroidLib project. And AndroidLib is visible in the Libraries folder of the AndroidApp project, but it doesn't show any packages or other contents there.
So I feel like I'm just one step away from making this work. Do I need to do something with one or other of the AndroidManifest files perhaps? Or do something with the build.xml files? Or am I on the wrong track altogether?
I'd be really grateful if someone could post a how-to for this.
I'm trying something similar; I've got Java EE projects, built using Eclipse, and I'm trying to utilize some of that code from my Android projects. This should give me a shared codebase rather than a bunch of confusing SVN externals which I've had to endure before.
Rather than creating JAR files I've found that working with the source and building for the platform works best (well, it has been working but I've got a problem with it at the moment). So, what I'm doing is:
c:\MySvnFolderStructure\MyJavaProjectFolder\src\ (and then all the source under that)
c:\MySvnFolderStructure\MyJavaProjectFolder\android\ (and all the Eclipse Android project gubbins)
c:\MySvnFolderStructure\MyJavaProjectFolder\jee\ (and all the Eclipse JEE project gubbins)
The Android and Java EE projects do not have their own src folders, they both link to the src folder in their parent folder. What this means is that each of the Java implementations is building its own byte code version from the source, and using its own external libraries (like the Apache HTTP ones, for example).
Naturally they can't share stuff like awt (as mentioned in another post), but there's plenty of stuff that does cross-over especially if it's core Java classes that are being used.
Also, it's proving a bit tricky writing JUnit tests as there needs to be some duplication of the test code at the moment because the Android ones need extra instrumentation, but I'm working on it.
Also, see this post about relative paths in Eclipse, which means the folders can be checked-out to different places on different machines (like we all do with our version control check-outs) and still be shared.
if I understand your situation correct, you are trying to use a custom java library for both your android and java applications.
For this scenario, you can build the java library first. Instead of adding the java library jar as android library, you can drop the jar directly inside the libs folder of android project and add it to android project's build path.
If you are using ANT scripts for building the java library jar , you can consider adding the source files also as part of jar. This will help you get code assistance when you develop the android part. But this part is purely optional.
The problem is that the Java platform in Android is different from the JDK platform.
In particular, the .JAR library CANNOT refer to anything that is not icluded in the Android platform. An example of things you can't refer to is java.awt.* (except you can have java.awt.fonts).
There is also a difference between JDK String and Android String -- Android does not implement the isEmpty() method.