Sample code for integrating ijkplayer with Android studio

introduce

Ijkplayer is a very popular open source video player, which is common to Android and IOS. There are many holes in how to compile and import your own projects in Android studio. This article records your own operation records. The current version of ijkplayer is 0.8.3. Of course, it is integrated with the latest version.

Compile ijkplayer

As for compilation, I compiled it on Ubuntu and copied it to win10. The source code of ijkplayer needs GCC compilation. Windows is not easy to use. If you use cynwin, you might as well compile it under Ubuntu.

The compilation process is to download SDK and NDK. After setting the environment variable, compile according to the instructions on GitHub

Android studio integration ijkplayer

1. Import into your project

Android studio opens your project, file - > import module... Select the Android / ijkplayer directory of ijkplayer. Ijk example depends on all libraries, so all projects will be imported into your project after import.

2. Copy the tools folder in the Android / ijkplayer directory to the root directory of your project.

3. Create a new folder named jnilibs under the ijkplayer Java \ SRC \ main \ directory, and copy the folders under the \ SRC \ main \ LIBS directory in each ijkplayer XXX directory to the jnilibs folder. For example, the directory of ijkplayer -- armv7a contains the folder armeabi-v7a, which contains the. So files corresponding to the platform. If you want to include the files of all platforms, Copy all the ijkplayer XXX files. If you only want some platforms, copy them.

4. Delete all the directories of ijkplayer xxx from the project, and only keep the ijkplayer example, ijkplayer Java, ijkplayer exo and tools folders, where ijkplayer example depends on the following. Delete items from Android studio as shown in the following figure:

And delete the corresponding folder.

5. Change the ijkplayer example to the form of module. Because ijkplayer example itself is an application project, it does not generate AAR files by default, and the resources in it depend on each other, so it is difficult to use it in the same way as the old version by copying several required java files into its own project. Therefore, it is better to convert the whole ijkplayer example into a module of our project. The specific methods are:

First modify the build.gradle file in the ijkplayer example directory, as follows:

be careful:

These modifications are the versions installed for yourself.

6. Add a gradle.properties file in the ijkplayer example root directory, as follows:

7. Add dependencies to your project, as shown in the following figure:

After completing the above operations, click async gradle.

Other errors:

If present

Error:(3) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Borderless.Colored'.

The above similar errors are caused by different SDK versions of several projects. Four projects include your own project's compilesdkversion

Buildtoolsversion, targetsdkversion and compile 'com. Android. Support: appcompat-v7: 25.0.0' versions must be unified. If they are not unified, various problems will occur.

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>