博客源码 : https://download.csdn.net/download/han1202012/88215731
在 【ijkplayer】编译 Android 版本的 ijkplayer ⑥ ( 进入 ijkplayer-android/android 目录 | 执行 compile-ijk.sh 脚本完成编译 ) 博客中 , 完成了 ijkplayer 的编译 ,
编译后的 Android 项目源码在 https://download.csdn.net/download/han1202012/85008881 下载 ;
下载后 , 解压文件 , 文件目录如下 , 该目录结构就是一个 Android Studio 目录 ;
在 Android Studio 中打开该项目 ;
报错如下信息 :
Unsupported Gradle.
The project uses Gradle version which is incompatible with Android Studio 2021.3.
Possible solution:
- Open Gradle wrapper settings, upgrade version to 3.0 or newer and reload the project
修改 Gradle 构建工具版本号 : 根目录下的 gradle/wrapper/gradle-wrapper.properties 中配置 gradle-4.6-all.zip 版本号 ;
#distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
修改 Android Gradle 插件版本号 : 根目录下的 build.gradle 构建脚本中设置 AGP 版本号 ;
buildscript {
dependencies {
//classpath 'com.android.tools.build:gradle:2.1.3'
classpath 'com.android.tools.build:gradle:3.2.0'
}
}
jcenter 仓库无法访问 , 该程序中只设置了 jcenter 仓库 , 肯定无法下载对应的依赖 , 这里重新设置依赖仓库 ;
jcenter 仓库已经停止维护 , 这里重新设置为 google 和 mavenCentral 仓库 ;
在 根目录下的 build.gradle 构建脚本中 , 配置依赖仓库 ;
buildscript {
repositories {
google()
mavenCentral()
//jcenter()
}
}
allprojects {
repositories {
google()
mavenCentral()
//jcenter()
}
}
添加阿里云仓库 , 避免出现由于网络导致的某些依赖无法下载的问题 ;
allprojects {
repositories {
maven {
url 'https://maven.aliyun.com/repository/public/'
}
maven{
url 'https://maven.aliyun.com/repository/google/'
}
google()
mavenCentral()
//jcenter()
}
}
编译时 , 报如下错误 ,
A problem occurred configuring root project 'ijkplayer'.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not find com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/jfrog/bintray/gradle/gradle-bintray-plugin/1.7/gradle-bintray-plugin-1.7.pom
https://dl.google.com/dl/android/maven2/com/jfrog/bintray/gradle/gradle-bintray-plugin/1.7/gradle-bintray-plugin-1.7.jar
https://repo.maven.apache.org/maven2/com/jfrog/bintray/gradle/gradle-bintray-plugin/1.7/gradle-bintray-plugin-1.7.pom
https://repo.maven.apache.org/maven2/com/jfrog/bintray/gradle/gradle-bintray-plugin/1.7/gradle-bintray-plugin-1.7.jar
Required by:
project :
Possible solution:
- Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
注释掉 在 根目录下 build.gradle 构建脚本中的 android-maven-gradle-plugin 和 gradle-bintray-plugin 插件 , 这是向 jcenter 仓库上传依赖库的 AGP 插件 , 现在已经没有任何作用了 , 直接删除 ;
buildscript {
dependencies {
//classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
//classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7'
}
}
将编译工具版本号设置为 28.0.2 ;
设置完毕后 , 完整的 根目录 build.gradle 构建脚本如下 :
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
//jcenter()
}
dependencies {
//classpath 'com.android.tools.build:gradle:2.1.3'
classpath 'com.android.tools.build:gradle:3.2.0'
//classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
//classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven {
url 'https://maven.aliyun.com/repository/public/'
}
maven{
url 'https://maven.aliyun.com/repository/google/'
}
google()
mavenCentral()
//jcenter()
}
}
ext {
compileSdkVersion = 25
//buildToolsVersion = "25.0.3"
buildToolsVersion = "28.0.2"
targetSdkVersion = 25
versionCode = 800800
versionName = "0.8.8"
}
wrapper {
gradleVersion = '2.14.1'
}
在 ijkplayer-example 项目中的 build.gradle 中设置了 productFlavors 风味 , 因为这个报错很多 , 直接取消 productFlavors ;
productFlavors {
all32 { minSdkVersion 21 }
all64 { minSdkVersion 21 }
// armv5 {}
// armv7a {}
// arm64 { minSdkVersion 21 }
// x86 {}
}
将上述 风格 都注释掉 ;
productFlavors {
//all32 { minSdkVersion 21 }
//all64 { minSdkVersion 21 }
// armv5 {}
// armv7a {}
// arm64 { minSdkVersion 21 }
// x86 {}
}
将 所有的 Module 中的 compile 依赖都改为 implementation 依赖 ;
尤其是 ijkplayer-example 项目中的 build.gradle 中的 依赖 ;
apply plugin: 'com.android.application'
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 {
applicationId "tv.danmaku.ijk.media.example"
minSdkVersion 21
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode rootProject.ext.versionCode
versionName rootProject.ext.versionName
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
//flavorDimensions "minSdkVersion"
productFlavors {
//all32 { minSdkVersion 21 }
//all64 { minSdkVersion 21 }
// armv5 {}
// armv7a {}
// arm64 { minSdkVersion 21 }
// x86 {}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:23.0.1'
implementation 'com.android.support:preference-v7:23.0.1'
implementation 'com.android.support:support-annotations:23.0.1'
implementation 'com.squareup:otto:1.3.8'
implementation project(':ijkplayer-java')
implementation project(':ijkplayer-exo')
implementation project(':ijkplayer-armv5')
implementation project(':ijkplayer-armv7a')
implementation project(':ijkplayer-x86')
implementation project(':ijkplayer-armv5')
implementation project(':ijkplayer-armv7a')
implementation project(':ijkplayer-arm64')
implementation project(':ijkplayer-x86')
implementation project(':ijkplayer-x86_64')
/*compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.0.1'
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')
all32Compile project(':ijkplayer-armv5')
all32Compile project(':ijkplayer-armv7a')
all32Compile project(':ijkplayer-x86')
all64Compile project(':ijkplayer-armv5')
all64Compile project(':ijkplayer-armv7a')
all64Compile project(':ijkplayer-arm64')
all64Compile project(':ijkplayer-x86')
all64Compile project(':ijkplayer-x86_64')*/
// compile 'tv.danmaku.ijk.media:ijkplayer-java:0.8.8'
// compile 'tv.danmaku.ijk.media:ijkplayer-exo:0.8.8'
// all32Compile 'tv.danmaku.ijk.media:ijkplayer-armv5:0.8.8'
// all32Compile 'tv.danmaku.ijk.media:ijkplayer-armv7a:0.8.8'
// all32Compile 'tv.danmaku.ijk.media:ijkplayer-x86:0.8.8'
// all64Compile 'tv.danmaku.ijk.media:ijkplayer-armv5:0.8.8'
// all64Compile 'tv.danmaku.ijk.media:ijkplayer-armv7a:0.8.8'
// all64Compile 'tv.danmaku.ijk.media:ijkplayer-arm64:0.8.8'
// all64Compile 'tv.danmaku.ijk.media:ijkplayer-x86:0.8.8'
// all64Compile 'tv.danmaku.ijk.media:ijkplayer-x86_64:0.8.8'
// armv5Compile project(':player-armv5')
// armv7aCompile project(':player-armv7a')
// arm64Compile project(':player-arm64')
// x86Compile project(':player-x86')
// x86_64Compile project(':player-x86_64')
}
在 Gradle 面板中 , 执行 ijkplayer-example 项目下的 Tasks/build/assemble 任务 , 即可编译生成 debug 版本的 apk 安装包 ;
博客源码 : https://download.csdn.net/download/han1202012/88215731