SDL2模块的build.gradle如下。
apply plugin: 'com.android.library'
android
{
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
minSdkVersion 21
targetSdkVersion 21
versionCode 1
versionName "1.0"
ndk {
abiFilters 'x86', 'armeabi-v7a', 'arm64-v8a'
}
externalNativeBuild {
cmake {
arguments '-DANDROID_TOOLCHAIN=clang'
}
}
}
externalNativeBuild {
cmake {
path 'android-cmake/CMakeLists.txt'
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
debug {
jniDebuggable true
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
}
而且,SDLActivity 的 build.gradle 如下所示。
apply plugin: 'com.android.library'
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
minSdkVersion 21
targetSdkVersion 21
versionCode 1
versionName "1.0"
ndk {
abiFilters 'x86', 'armeabi-v7a', 'arm64-v8a'
}
externalNativeBuild {
cmake {
arguments '-DANDROID_TOOLCHAIN=clang',
'-DANDROID_PLATFORM=android-21'
cppFlags "-std=c++11"
}
}
}
externalNativeBuild {
cmake {
path 'CMakeLists.txt'
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
jniDebuggable true
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
androidTestCompile 'junit:junit:4.12'
testCompile 'junit:junit:4.12'
compile project(':SDL2-android-studio')
compile project(':libtciplayer')
compile project(':TciSdk')
compile project(':soundtouch')
}
在3.0.0上,构建失败了。
执行任务:[:SDLActivity:generateReleaseSources, :SDLActivity:mockableAndroidJar, :SDLActivity:compileReleaseUnitTestSources, :SDLActivity:compileReleaseSources]
...
:SDLActivity:preReleaseUnitTestBuild UP-TO-DATE :SDLActivity:javaPreCompileReleaseUnitTest :SDLActivity:compileReleaseUnitTestJavaWithJavac :SDLActivity:processReleaseJavaRes NO-SOURCE :SDLActivity:processReleaseUnitTestJavaRes NO-SOURCE :SDLActivity:compileReleaseUnitTestSources :SDLActivity:generateJsonModelRelease :SDLActivity:externalNativeBuildRelease 构建主程序 arm64-v8a ninja: 错误: '../../../../../distribution/SDL2/lib/arm64-v8a/libSDL2.so',需要 by 'D:/corelab_proj/GearToTciPlayer2/distribution/main/lib/arm64-v8a/libmain.so',且没有已知规则来生成它。 :SDLActivity:externalNativeBuildRelease FAILED
失败: 构建出现异常。
什么出问题了: 执行任务':SDLActivity:externalNativeBuildRelease'失败。
尝试: 使用--stacktrace选项运行以获取堆栈跟踪。 使用--info或--debug选项运行以获取更多日志输出。
在https://help.gradle.org获取更多帮助。
构建失败,用时13秒
69个操作任务: 执行了19个,50个最新的
然而,2.3.3上,构建成功了。
执行任务:[:SDLActivity:generateReleaseSources, :SDLActivity:prepareReleaseUnitTestDependencies, :SDLActivity:mockableAndroidJar, :SDLActivity:compileReleaseUnitTestSources, :SDLActivity:compileReleaseSources]
Configuration on demand是一个孵化中的功能。 setTestClassesDir(File)方法已被弃用,计划在Gradle 5.0中删除。请改用setTestClassesDirs(FileCollection)方法。 getTestClassesDir()方法已被弃用,计划在Gradle 5.0中删除。请改用getTestClassesDirs()方法。 ConfigurableReport.setDestination(Object)方法已被弃用,计划在Gradle 5.0中删除。请改用ConfigurableReport.setDestination(File)方法。 :SDL2-android-studio:preBuild UP-TO-DATE :SDL2-android-studio:preReleaseBuild UP-TO-DATE :SDL2-android-studio:checkReleaseManifest :SDL2-android-studio:prepareReleaseDependencies :SDL2-android-studio:compileReleaseAidl UP-TO-DATE :SDL2-android-studio:compileLint UP-TO-DATE :SDL2-android-studio:copyReleaseLint NO-SOURCE :SDL2-android-studio:mergeReleaseShaders UP-TO-DATE :SDL2-android-studio:compileReleaseShaders UP-TO-DATE :SDL2-android-studio:generateReleaseAssets UP-TO-DATE :SDL2-android-studio:mergeReleaseAssets UP-TO-DATE :SDL2-android-studio:mergeReleaseProguardFiles UP-TO-DATE :SDL2-android-studio:packageReleaseRenderscript NO-SOURCE :SDL2-android-studio:compileReleaseRenderscript UP-TO-DATE :SDL2-android-studio:generateReleaseResValues UP-TO-DATE :SDL2-android-studio:generateReleaseResources UP-TO-DATE :SDL2-android-studio:packageReleaseResources UP-TO-DATE :SDL2-android-studio:processReleaseManifest UP-TO-DATE :SDL2-android-studio:generateReleaseBuildConfig UP-TO-DATE :SDL2-android-studio:processReleaseResources UP-TO-DATE :SDL2-android-studio:generateReleaseSources UP-TO-DATE :SDL2-android-studio:incrementalReleaseJavaCompilationSafeguard :SDL2-android-studio:javaPreCompileRelease :SDL2-android-studio:compileReleaseJavaWithJavac :SDL2-android-studio:processReleaseJavaRes NO-SOURCE :SDL2-android-studio:transformResourcesWithMergeJavaResForRelease :SDL2-android-studio:transformClassesAndResourcesWithSyncLibJarsForRelease :SDL2-android-studio:generateJsonModelRelease :SDL2-android-studio:externalNativeBuildRelease 编译SDL2 arm64-v8a [1/114] 编译C对象 CMakeFiles/SDL2.dir/D_/corelab_proj/GearToTciPlayer2/SDL2-android-studio/src/SDL_log.c.o ... [114/114] 链接C共享库 D:\corelab_proj\GearToTciPlayer2\distribution\SDL2\lib\arm64-v8a\libSDL2.so 编译SDL2 x86 [1/114] 编译C对象 ... [114/114] 链接C共享库 D:\corelab_pr oj\GearToTciPlayer2\distribution\SDL2\lib\x86\libSDL2.so 编译SDL2 armeabi-v7a [1/114] 编译C对象 CMakeFiles/SDL2.dir/D_/corelab_proj/GearToTciPlayer2/SDL2-android-studio/src/dynapi/SDL_dynapi.c.o ... [114/114] 链接C共享库 D:\corelab_proj\GearToTciPlayer2\distribution\SDL2\lib\armeabi-v7a\libSDL2.so :SDL2-android-studio:mergeReleaseJniLibFolders :SDL2-android-studio:transformNativeLibsWithMergeJniLibsForRelease :SDL2-android-studio:transformNativeLibsWithStripDebugSymbolForRelease :SDL2-android-studio:transformNativeLibsWithSyncJniLibsForRelease :SDL2-android-studio:bundleRelease :SDLActivity:preBuild UP-TO-DATE :SDLActivity:preReleaseBuild UP-TO-DATE :SDLActivity:checkReleaseManifest :SDLActivity:preDebugAndroidTestBuild UP-TO-DATE :SDLActivity:preDebugBuild UP-TO-DATE :SDLActivity:preDebugUnitTestBuild UP-TO-DATE :SDLActivity
:SDLActivity:incrementalReleaseUnitTestJavaCompilationSafeguard NO-SOURCE :SDLActivity:javaPreCompileReleaseUnitTest :SDLActivity:compileReleaseUnitTestJavaWithJavac :SDLActivity:processReleaseJavaRes NO-SOURCE :SDLActivity:processReleaseUnitTestJavaRes NO-SOURCE :SDLActivity:compileReleaseUnitTestSources :SDLActivity:generateJsonModelRelease :SDLActivity:externalNativeBuildRelease [1/10] 正在构建 CXX 对象 CMakeFiles/main.dir/src/cpp/SDLAudioImpl.cpp.o ... [10/10] 链接 CXX 共享库 D:\corelab_proj\GearToTciPlayer2\distribution\main\lib\armeabi-v7a\libmain.so :SDLActivity:compileReleaseSources
构建成功,耗时 1 分 38 秒 共有 133 个可执行任务:77 个已执行,56 个已经最新