gpt4 book ai didi

android - Gradle 3.0.0 从 gradle-experimental 升级 :0. 9.3 错误

转载 作者:行者123 更新时间:2023-11-30 00:17:09 25 4
gpt4 key购买 nike

在升级到 Android Studio 3.0 之后,一个项目也被更新了,尽管我仍然保留了它的备份。我虽然会同意从实验性 gradle 插件的早期版本升级到 3.0.0 版,但我遇到了很多麻烦。

我认为顶级 gradle 文件看起来绝对没问题。

buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
//classpath 'com.android.tools.build:gradle-experimental:0.9.3'
}
}

allprojects {
repositories {
google()
jcenter()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

应用程序 gradle 构建文件是我一直在对其进行大量更改的文件。它目前提示 cppFlags 错误:

错误:(25, 0) 找不到方法 cppFlags() 参数 [-std=c++11, -fexceptions, -Isrc/main/android/armeabi-v7a/include, -frtti, -O2] 在 com.android.build.gradle.internal.dsl.NdkOptions 类型的对象上。

到目前为止,这个 gradle 文件的变化是:

//apply plugin: 'com.android.model.application'
apply plugin: 'com.android.application'

//model {
android {
buildToolsVersion "26.0.2"
compileSdkVersion 23

defaultConfig {
minSdkVersion 19
targetSdkVersion 19

ndk {
def ffmpeg = "src/main/android/armeabi-v7a/include"

moduleName = "ffplayer3jni"

ldLibs "log", "android", "GLESv2", "dl", "EGL", "z",
"stdc++", "OpenSLES"

//cppFlags.addAll("-std=c++11", "-fexceptions", '-I'+file(ffmpeg),
// "-D __cplusplus=201103L", "-frtti",
// "-D __GXX_EXPERIMENTAL_CXX0X__", "-O2")

cppFlags "-std=c++11", "-fexceptions", "-I${ffmpeg}", "-frtti", "-O2"

stl "gnustl_static"

//abiFilters.addAll("armeabi-v7a")
abiFilters "armeabi-v7a"
}
}
}

android.buildTypes {
release {
minifyEnabled false
proguardFiles.add(file('proguard-rules.pro'))
}
}

repositories {
def loc = "src/main/jniLibs/armeabi-v7a/"

libs(PrebuiltLibraries) {

libavutil {
binaries.withType(SharedLibraryBinary) {
sharedLibraryFile = file(loc + "libavutil.so")
}
}

libavcodec {
binaries.withType(SharedLibraryBinary) {
sharedLibraryFile = file(loc + "libavcodec.so")
}
}

libavformat {
binaries.withType(SharedLibraryBinary) {
sharedLibraryFile = file(loc + "libavformat.so")
}
}

libavfilter {
binaries.withType(SharedLibraryBinary) {
sharedLibraryFile = file(loc + "libavfilter.so")
}
}

libpostproc {
binaries.withType(SharedLibraryBinary) {
sharedLibraryFile = file(loc + "libpostproc.so")
}
}

libswresample {
binaries.withType(SharedLibraryBinary) {
sharedLibraryFile = file(loc + "libswresample.so")
}
}

libswscale {
binaries.withType(SharedLibraryBinary) {
sharedLibraryFile = file(loc + "libswscale.so")
}
}
}
}

android.sources {
main {
jni {
dependencies {
library "libavformat" linkage "shared"
library "libavcodec" linkage "shared"
library "libavfilter" linkage "shared"
library "libavutil" linkage "shared"
library "libswscale" linkage "shared"
library "libswresample" linkage "shared"
library "libpostproc" linkage "shared"
}
}
}
}
//}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
}

原始的 gradle 文件仍然适用于 Android Studio 2.3,即使它使用的是旧的实验性插件。这个文件是/是:

apply plugin: 'com.android.model.application'

model {
android {
def ffmpeg = "src/main/android/armeabi-v7a/include"

buildToolsVersion "25.0.3"
compileSdkVersion 25

defaultConfig.with {
minSdkVersion.apiLevel = 19
}

ndk {
moduleName = "ffplayer3jni"

ldLibs.addAll("log", "android", "GLESv2", "dl", "atomic", "EGL",
"z", "stdc++", "OpenSLES")

cppFlags.addAll("-std=c++11", "-fexceptions", '-I'+file(ffmpeg),
"-D __cplusplus=201103L", "-frtti",
"-D __GXX_EXPERIMENTAL_CXX0X__", "-O2")
CFlags.add('-I'+file(ffmpeg))

stl = "gnustl_static"
//stl = "stlport_shared"

abiFilters.addAll("armeabi-v7a")
}
}

android.buildTypes {
release {
minifyEnabled false
proguardFiles.add(file('proguard-android.txt'))
}
}

repositories {
def loc = "src/main/jniLibs/armeabi-v7a/"

libs(PrebuiltLibraries) {

libavutil {
binaries.withType(SharedLibraryBinary) {
sharedLibraryFile = file(loc + "libavutil.so")
}
}

libavcodec {
binaries.withType(SharedLibraryBinary) {
sharedLibraryFile = file(loc + "libavcodec.so")
}
}

libavformat {
binaries.withType(SharedLibraryBinary) {
sharedLibraryFile = file(loc + "libavformat.so")
}
}

libavfilter {
binaries.withType(SharedLibraryBinary) {
sharedLibraryFile = file(loc + "libavfilter.so")
}
}

libpostproc {
binaries.withType(SharedLibraryBinary) {
sharedLibraryFile = file(loc + "libpostproc.so")
}
}

libswresample {
binaries.withType(SharedLibraryBinary) {
sharedLibraryFile = file(loc + "libswresample.so")
}
}

libswscale {
binaries.withType(SharedLibraryBinary) {
sharedLibraryFile = file(loc + "libswscale.so")
}
}
}
}

android.sources {
main {
jni {
dependencies {
library "libavformat" linkage "shared"
library "libavcodec" linkage "shared"
library "libavfilter" linkage "shared"
library "libavutil" linkage "shared"
library "libswscale" linkage "shared"
library "libswresample" linkage "shared"
library "libpostproc" linkage "shared"
}
}
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
}

所以我的问题是,我需要做哪些更改才能让这个项目在 Android Studio 3.0 中使用新的 gradle 插件?

如您所见,我做了一些更改。移动部分并更改选项以最终通过 gradle 脚本,但现在我非常卡住。

编辑:最后我放弃了,在 Android Studio 3.0.1 中从头开始创建了一个新项目。经过大量谷歌搜索后,我设法获得了所有 native 代码、ffmpeg 库和正确的构建。

最佳答案

I gave up in the end and created a new project from scratch in Android Studio 3.0.1. After much googling I managed to get all the native code, ffmpeg libraries and correct builds done.

是的,实验性插件的概念非常不同。它试图引入一个新的基于 groovy 的构建系统。在这里,您依靠已建立的工具——cmake 或 Android.mk——来构建原生库。

关于android - Gradle 3.0.0 从 gradle-experimental 升级 :0. 9.3 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47051825/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com