Search code examples
androidscreenshot

Embedding Android Screenshot Library


Currently I'm working on an app which is supposed to take screenshots from the device screen.

I read about Android Screenshot Library and it sounds very promising.

I want to start using it in my app. The problem is I'm having hard times embed it into my project.

I tried to import the project folder(asl-1.2) into my libs directory inside the app module.

I followed this post but it still doesn't help me.

The problem is the project is not linked with my app module and therefore I can't use the classes that reside in the library.

Here is a screenshot of the project hierarchy:

https://i.gyazo.com/f496e790d5ab06fc4c785df77e0984bd.png

As you can see, the ScreenshotService.java file is marked with the red icon with the letter 'J'


Solution

  • I read about Android Screenshot Library and it sounds very promising.

    That code has not been updated in six years. AFAIK, it requires that users have USB cables and the Android SDK installed (since it relies upon developer tools).

    On Android 5.0+, you can use the media projection APIs to take screenshots.

    I tried to import the project folder(asl-1.2) into my libs directory inside the app module.

    That is not going to work. libs/ is for bare JAR files, such as legacy Java code.

    Either merge its contents directly into your app module, or set up a separate library module for that code. Most likely, that code will require substantial reorganization, to be buildable by Android Studio and the modern NDK.

    Or, don't use that code, which IMHO is the best answer.