Light version of appcompat v4 to only use NotificationCompat - java

I've seen that the android support library appcompat v4 takes actually about 1Mo on my final apk while I only use it to create Notifications with NotificationCompat.
I use a .jar of the library.
Since the source code is available (https://github.com/android/platform_frameworks_support/tree/master/v4/java/android/support/v4) do you think it would help if I include the source code in my project instead of the .jar file? So the compiler would only include the necessary files.
Is it bad practice to do that?

In my application i got the same problem as you: a huge jar file to use just a single class. I copied the sources of LocalBroadcastManager to my application and everything worked fine.

Related

How to use com.google.android.collect.list in Android Studio

I want to use com.google.android.collect.List in my apk. But I don't understand which library I should include in the project.
I see that this class must be in frameworks/base/core. And I think that frameworks/base/core is included in framework.jar or framework2.jar.
But, framework.jar and framework2.jar from my phone contains odex files, and Android Studio can't use it.
Can anyone explain to me how to use classes from frameworks/base/core in apk?
In addition, how I understand android sdk don't include frameworks/base/core.
I don't think you need to download the android source code. If you are looking for Lists, Maps then use Guava library.
I've solved my problem. It's not easy way. I've download android source codes and compile it. Then i get jar file with compiled classes and set as library for my project. I know that it's crazy solution :) but i don't found another way.

Implementing and using SoundTouch class (Java Android)

I've been trying to use the library SoundTouch in my android app in order to change the tempo of an mp3 file.
I've managed to compile the library following the steps outlined here: http://www.surina.net/soundtouch/README-SoundTouch-Android.html
My question now is how do I import and use the compiled library in my android project in Eclipse?
From following the steps in the link above I've ended up with .so files that I've added into the libs folder of my project. I've also changed the build path to include this new library.
The library is now showing up under "referenced libraries" so I'm guessing I'm some where on the right track?
In my java file I've tried importing the library like this:
static
{
System.loadLibrary("soundtouch");
}
The program builds and runs fine but I don't think the library is actually being loaded as I can't reference any of soundTouch's methods.
Any help would be much appreciated!
The JNI file provided with the SoundTouch library is merely a demonstration and does not provide any means of using any of SoundTouch's features in an Android app from Java.

How to I tell Eclipse to build using a different version of a package from a different library?

I'm currently trying to build an android application using the Android 4.1.2 Java libraries.
Unfortunately, I want to use a newer version of the org.json package, which appears in that library.
Am I able to tell Eclipse not to use the org.json package in the Android 4.1.2 Jar?
It sounds like you are encountering a Java package name collision. Unfortunately as the code in Android comes pre-packaged, your best bet is to rename the newer json package and use that to avoid using the prebuilt one.
If same class with package is available through two different JARs in the buildpath, you can't do that properly.
One step you may try is to put new jar on top in the order using Order and Export tab of Eclipse build path UI.
The best way is to update you Android Lib folder in the file system and replace the older jar with the newer JAR.
Please note: There might be an compatibility issue when you attempt to use a different JAR than the one supplied with the package.

java.lang.VerifyError on imported jar

I have imported a .jar into my Eclipse Android project (importing it to the libs folder and adding the jar to the libraries in Java Build Path), but when I attempt to use it, I get a java.lang.VerifyError. The library is Jiwigo 0.13.1.1; a java library for accessing Piwigo image galleries. I know this should work, because there's an open source android project called RegalAndroid that uses it too (though, an older version, and it copied the source instead of properly importing it). The .jar is the only copy of the library on my computer, so I'd be surprised if it was a version clash error. Any ideas?
Here's my error log (shortened because all the rest is normal android stuff):
FATAL EXCEPTION: main
java.lang.VerifyError: fr.mael.jiwigo.transverse.session.SessionManager
at com.terrapages.itemdetailsactivities.FavoritesDetailsActivity.initViews(FavoritesDetailsActivity.java:179)
at com.terrapages.itemdetailsactivities.FavoritesDetailsActivity.onResume(FavoritesDetailsActivity.java:83)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1149)
at android.app.Activity.performResume(Activity.java:3823)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3118)
[...]
And the line it crashes on (with dummy string values that are different in the code):
SessionManager sessionManager = new SessionManager("username", "password", "gallery-url");
This is the first use of the library anywhere in the code.
I'm the developer of Jiwigo and read this post this afternoon by chance.
As I do not develop on Android, I didn't even know that my api was not compatible with android.
So after I read this post, I made some changes on my API : I replaced the old Apache HttpClient version with a newest one : 4.1 (I think it's compatible with android isn't it ?)
And I removed all JDom references. The code now uses org.w3c.dom.Document instead. The jar is here : http://maven.le-guevel.com/artifactory/libs-release-local/fr/mael/jiwigo/jiwigo-ws-api/0.2b/
As I said, I just made the modifications this afternoon, and I did not test it very well, so it could be unstable (it seems to work on my project).
Bye.
Any ideas?
SessionManager is using a class or method that does not exist in Android. Assuming this is the source for the class in question, there is no way that will work on Android without substantial modifications, as it uses:
an old version of Apache HttpClient
JDOM
neither of which are in Android.
I had a similar issue with my projects after doing the Android ADT , and Java updates.
Try these steps
Remove links to your external libraries in your Android project.
Move all your external libraries (including Google Ad libraries) to \libs folder inside your Android project.
Re-link your libraries, that now exist in the Project\libs directory.
Hopefully this will help

Android shared library which is not JNI based

I am developing a library for Android applications which does not use native code (JNI). I have tried suppling the library as an external jar in my Android projects but this method does not include the library contents in the apk and thus throws class not found errors when run in the emulator or device. I have also tried creating the library as an Android project in itself and this does work, but only for public static properties (not methods). With the library and application both being in separate apk's I can see that the VM notices references to the library and can read some properties, but when an attempt to instantiate a class in the library is executed I get class not found even though I can read the public static properties from it (very frustrating!!).
I realize that Davlik byte code is not the same as Java byte code but I am having trouble even finding good information about how to solve what would seem to be a very simple issue in Android. I am looking into the old PlatformLibrary stuff right now but I am not convinced this will work either since the sample has been removed from the Android site :(
So help me out if you can, if I find the answer before this happens I will share it.
viva la Android!
I have tried suppling the library as
an external jar in my Android projects
but this method does not include the
library contents in the apk and thus
throws class not found errors when run
in the emulator or device.
Put the JAR in your libs/ directory, and it will automatically be included in the APK.
This sample project from one of my books shows using the BeanShell JAR this way. Also, all of the GitHub repos starting with "cwac-" on my GitHub page are projects designed to build JARs to be included in Android projects via the libs/ directory.

Categories