I'm trying to keep track of the entire app flow so I figured using the Loggable annotation on every single method in my code would do the job.
My issue is that I can't seem to understand how to setup form scratch the Loggable option, including(to my limited understanding of it):
Importing all dependencies with gradle
Configuring the log4j properties , from inside the code or from a file
Using a PackageInfo class to log all methods in my project
A while ago I played around with Gradle and Android SDK in connection with AspectJ in order to help another user. Maybe you want to check this answer.
P.S.: Your question is very general, so my answer is too. This is StackOverflow, please show some code and/or configuration. Give the community a concrete problem to solve and make your own problem reproducible, ideally via an SSCCE.
Related
I have to estimate the time it takes to update a specific application made for Android 4.4 to Android 10 and I need to see all the methods that are deprecated or not working. Is there any way to see the methods without going file by file? (I'm using Android Studio with Java)
When I build the application I only get one or two types of error at a time, when I correct them I get another one and so on.
Thanks and best regards.
P.S: How long does it take you to update something like that? I'm a junior and I'm a little lost doing this.
Here, go to Analyze -> Inspect code. After inspecting check maturity there you will have depreciated methods. (Don't forget to change minSdk)
After you will do that it give you method with a warning and you can filter it by having API not support warning
Hi every one could you please help me to fix that error:
I use android studio so i found this: https://github.com/realm/realm-java/tree/rw-performance-comparison
So my probleme is : I can't run this project I really tried a lot of time before asking you.
Christian from Realm here.
You are trying to compile an old branch that is not maintained anymore. If you are interested in performance numbers I would encourage you to write your own performance test. Then you would also be able to test the stuff you care about instead of looking at generalised numbers.
I'm trying to call ffmpeg.c to trim a video based on this code 'video-trimmer'. So when I try to run the activity (that loads and uses the native lib) the first time I click trin it works and I could trim the video but when I try to run it again it crashes (and it only work with the application restarts).
So I spend three days looking for a solution for this issue, most of the answers says the issue with the static variables in ffmpeg.c and creating a lib that loads and unload the class fixes the issue (answer1, answer2). So I tried to apply the solution that is based on the answers and this github repo on the video-trimmer project but all my attempts failed.
Is there any one knows about a fork of the 'video-trimmer' project that fixes the issue?. or can anybody provide step by step answer of how to implement the solution in the 'video-trimmer' project (because I tried to follow all the solution on the web and apply them in that project but with no luck).
the problem seems to be with the initialized values (some variables are declared as global static vars, presumably for ease of access but breaks OOP principles and causes us problems like you're facing), however, there are a few ways round this that I can think of:
write a quick function to manually set the static vars back to their correct init values (quick and dirty but works). A list of methods which should not be allowed to fire off as and when they please follows:
avcodec_register_all(), avdevice_register_all(), av_register_all()
avcodec_find_encoder(), avcodec_find_decoder(), av_find_stream_info()
avcodec_open(), avcodec_close()
these could be wrapped in a boolean controlled method for example so that if they have run previously they cannot run again.
another way to control things is to manually force the variable values (by use of a class or struct to control the ffmpeg global vars) that are being re-initialised on subsequent runs, for example on running the method which currently causes the code to fail, the first step could be to manually set the variables back to their default settings so that they run correctly as at the moment I suspect you have data remaining resident between iterations, and thats what is causing problems.
you could utilse mutexes to ensure that the aforementioned methods behave more responsibly when used with threads.
Addendum:
also (at the C level) use libffmpeginvoke in preference to libffmpeg if you are going to invoke main() multiple times
forcibly invoke Garbage Collection (yep this is another 'ugly' fix) on the call to load the ffmpeg lib, which would then clean things up allowing you to call another instance
Let me know if you need something more in-depth: I can try making a test framework to replicate your problems and see where I get, although that needs access to my home PC as when I am at work I have no Android SDK.
Help us help you, please provide your implemented code or a part of it. Also Crash Log will be helpful.
Hint: Initialise ffmpeg object/thread.
Then use a call back interface. Once the VideoTrimmer gets over, give a callback.
In that callback call the destroy/kill of the ffmpeg object/thread.
May be this link can help you.
I have recently used the "android-ffmpeg-java" project from github, this is a working library, I can guarantee. You just have to implement a wrapper (test application) which will do the work.
Check this link for Source : android-ffmpeg-java
Check this link for example : android-ffmpeg-cmdline. See if you can solve on with this.
I am not sure if this will help, but C files typically have a header where you can use
ifndef
Please see the following:
http://www.cprogramming.com/reference/preprocessor/ifndef.html
Use that syntax to sandwhich the declaration in the associated .h file to ensure multiple imports don't cause a crash in the importing code.
Good Luck!
Edit: Ok, looks like that would mean recompiling ffmpeg to the .so file. You should just try to verify that it has a mechanism as described above in the codebase and try to confirm it isn't somehow being loaded twice.
While somewhat crude, a potential workaround could be to utilize/link to ffmpeg from a Service (you had better be doing that anyway) which is declared in the manifest to run in its own process rather than that of client Activities. Then have that process terminate itself - calling native exit() if needed - when the task is completely finished. Android won't particularly like that happening - it's not good practice - but you can probably make it work.
Re-engineering the library to be able to reset itself to a fresh state (or even make it entirely contextual) would be better, but for a huge legacy codebase may prove to be a large project.
Here is a screenshot of my Project:
The lines hidden behind the error window are:
pi.setValue(namePart);
pi.setType(Integer.class);
as you can see I have included the ksoap-j2se-full-2.1.2.jar and also all the imports are in place.
Still pi.setName(""); (and all the ones below it) is giving resolution error! apparently no such method exists in class PropertyInfo... I have already googled this and no one else seems to have any such problem anywhere on the Net or on StackOVerflow! Please help I'm stuck at the very starting point of learning Ksoap and Web Services!
Seems like you are using ksoap2-j2se library which is wrong. You need to use ksoap2-android library in order to get it work.
I've got an android project that I started from an old standard Java project, so because of the vast difference in target platform, I have a lot of dead code to cleanup.
I've seen UCDetector recommended for finding unused public methods in java projects in Eclipse. I installed it as directed, and it just doesn't show up on the menu, and I have no idea how to get it to work.
Has anyone got this combo to work, or have another recommendation? Or know how to get it to show up?
(I've tried Find Bugs which found some good stuff, but it doesn't find unused public code.)
Big warning!
It might partially work, but beware, cause it doesn't seem to know about XML-defined callback functions.
If you have installed a callback function on a widget, say a button in an XML Style Sheet, and it is not called in code, UCdetector will think it has 0 references, and suggest it deleted. This obviously is wrong, and will render your code uncompilable.
There might be other similar issues, related to Android specifics.
Viggo
Yes, UCDetector works for android projects. I just installed it and it works.
It's available in context menu of project in Package Explorer.