Android studio integrates ijkplayer and androiw.player

Source: Internet
Author: User

Android studio integrates ijkplayer and androiw.player
Introduction

Ijkplayer is a very popular open-source video player for android and IOS. There are many pitfalls 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

For compilation, I compiled it on Ubuntu and copied it to win10. The ijkplayer source code needs to be compiled by gcc, which is not easy to use in windows. If cynwin is used, it is better to compile it In ubuntu.

The compiling process is to download the sdk, ndk. After setting environment variables, compile the environment variables according to the instructions on github. For details, refer to this article.

Integrate ijkplayer with android studio

1. Import to your project

Open your project in android studio, File-> Import Module... select the ijkplayer anroid/ijkplayer directory. ijk-example depends on all libraries. Therefore, all projects will be imported to your project.

2. Copy the tools Folder under the android/ijkplayer directory to the root directory of your project.

3. create a folder named jniLibs in the ijkplayer-java \ src \ main \ directory, copy the folders under the \ src \ main \ libs directory in the ijkplayer-xxx directory to the jniLibs folder, for example, ijkplayer -- armv7a contains the armeabi-v7a folder, it contains the corresponding platform. so files. If you want to include all the platforms, copy all the ijkplayer-xxx files. If you only want the files on a few platforms, copy them.

4. delete all ijkplayer-xxx directories from the project. Only the ijkplayer-example, ijkplayer-java, ijkplayer-exo, and tools folders are retained. ijkplayer-example depends on the following. Shows how to delete a project in android studio:

Delete the corresponding folder.

5. change ijkplayer-example to the Module format. Because ijkplayer-example is an application project, the aar file is not generated by default and the resources in the project are mutually dependent, it is difficult to use the old version by copying several required java files to your own project, so it is better to convert the entire ijkplayer-example into a Module of our project. The specific method is:

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

apply plugin: 'com.android.library'android {    // http://tools.android.com/tech-docs/new-build-system/tips    //noinspection GroovyAssignabilityCheck    compileSdkVersion rootProject.ext.compileSdkVersion    //noinspection GroovyAssignabilityCheck    buildToolsVersion rootProject.ext.buildToolsVersion    lintOptions {        abortOnError false    }    defaultConfig {        minSdkVersion 9        targetSdkVersion rootProject.ext.targetSdkVersion        versionCode rootProject.ext.versionCode        versionName rootProject.ext.versionName    }    buildTypes {        release {            minifyEnabled false            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'        }    }    buildToolsVersion '25.0.0'}dependencies {    compile fileTree(include: ['*.jar'], dir: 'libs')    compile 'com.android.support:appcompat-v7:25.0.0'    compile 'com.android.support:preference-v7:23.0.1'    compile 'com.android.support:support-annotations:23.0.1'    compile 'com.squareup:otto:1.3.8'    compile project(':ijkplayer-java')    compile project(':ijkplayer-exo')}

 Note:

  • Apply plugin: 'com. android. application' should be changed to apply plugin: 'com. android. library'
  • Remove applicationId "TV. danmaku. ijk. media. example ".
  • Compile 'com. android. support: appcompat-v7: 25.0.0'

Compile 'com. android. support: preference-v7: 23.0.1'

Compile 'com. android. support: support-annotations: 23.0.1'

Compile 'com. squareup: otto: 1.3.8'

These are modified to your own installed version.

6. Add a gradle. properties file under the ijkplayer-example root directory. The content is as follows:

POM_NAME=ijkplayer-examplePOM_ARTIFACT_ID=ijkplayer-examplePOM_PACKAGING=aar

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

 

After completing the preceding operations, click async gradle.

Other errors:

If

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

The above error is caused by different sdk versions of several projects. Four projects contain compileSdkVersion,

BuildToolsVersion, targetSdkVersion, and compile 'com. android. support: appcompat-v7: 25.0.0'
Several versions must be unified. If not, various problems may occur.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.