升级Android Studio 3.0后,externalNativeBuildRelease

时间:2017-11-20 00:52:03

标签: android cmake android-ndk android-studio-3.0 gradle-dependencies

在2.3.3上,构建运行良好,但是在升级3.0.0后出现了这个问题。有没有人可以帮助我? 原因是没有生成libSDL2.so,但是,我不明白为什么SDLActivity模块在SDL2-android-studio完成构建之前就开始构建。

我认为SDLActivity模块在SDL2-android-studio模块的构建作业完成后开始构建。事实上,在2.3.3上,它起作用了。但是,在3.0.0上,它并没有。也就是说,在2.3.3上SDLActivity的任务externaNativeBuildRelease在SDL-android-studio完成之后开始。在3.0.0上,在任务transformClassesAndResourcesWithPrepareIntermediateJasrForDebug的SDL-android-stduio-studio之后,所有的SDLActivity都被处理掉了。 如何控制任务之间的依赖关系?

提前致谢。

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 忍者:错误:' ../../../../../ distribution / SDL2 / lib / arm64-v8a / libSDL2.so',需要' D:/ corelab_proj /GearToTciPlayer2/distribution/main/lib/arm64-v8a/libmain.so' ;,缺少并且没有已知规则来制作它 :SDLActivity:externalNativeBuildRelease FAILED

失败:构建因异常而失败。

  • 出了什么问题: 任务执行失败':SDLActivity:externalNativeBuildRelease'。

      

    构建命令失败。   执行进程D时出错:\ User-expansion \ Android \ sdk \ cmake \ 3.6.4111459 \ bin \ cmake.exe带参数{--build D:\ corelab_proj \ GearToTciPlayer2 \ SDLActivity.externalNativeBuild \ cmake \ release \ arm64-v8a --target main}   忍者:错误:' ../../../../../ distribution / SDL2 / lib / arm64-v8a / libSDL2.so',需要' D:/ corelab_proj /GearToTciPlayer2/distribution/main/lib/arm64-v8a/libmain.so' ;,缺少并且没有已知的规则来实现它

  • 尝试: 使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获得更多日志输出。

  • https://help.gradle.org

  • 获取更多帮助

13s建立失败

69个可操作的任务:19个执行,50个最新

但是,在2.3.3上,构建成功

执行任务:[:SDLActivity:generateReleaseSources,:SDLActivity:prepareReleaseUnitTestDependencies,:SDLActivity:mockableAndroidJar,:SDLActivity:compileReleaseUnitTestSources,:SDLActivity:compileReleaseSources]

按需配置是一项孵化功能。 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-机器人工作室:checkReleaseManifest :SDL2-机器人工作室: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-机器人工作室:incrementalReleaseJavaCompilationSafeguard :SDL2-机器人工作室:javaPreCompileRelease :SDL2-机器人工作室:compileReleaseJavaWithJavac :SDL2-android-studio:processReleaseJavaRes NO-SOURCE :SDL2-机器人工作室:transformResourcesWithMergeJavaResForRelease :SDL2-机器人工作室:transformClassesAndResourcesWithSyncLibJarsForRelease :SDL2-机器人工作室:generateJsonModelRelease :SDL2-机器人工作室: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 \ dis tribution \ SDL2 \ LIB \ arm64-V8A \ libSDL2.so 构建SDL2 x86 [1/114]构建C对象 ... [114/114]链接C共享库D:\ corelab_pr OJ \ GearToTciPlayer2 \分布\ SDL2 \ LIB \ 86 \ 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-机器人工作室:mergeReleaseJniLibFolders :SDL2-机器人工作室:transformNativeLibsWithMergeJniLibsForRelease :SDL2-机器人工作室:transformNativeLibsWithStripDebugSymbolForRelease :SDL2-机器人工作室:transformNativeLibsWithSyncJniLibsForRelease :SDL2-机器人工作室: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:preReleaseUnitTestBuild UP-TO-DATE :SDLActivity:prepareAndroidArchLifecycleRuntime100Library :SDLActivity:prepareComAndroidSupportAnimatedVectorDrawable2610Library :SDLActivity:prepareComAndroidSupportAppcompatV72610Library :SDLActivity:prepareComAndroidSupportSupportCompat2610Library :SDLActivity:prepareComAndroidSupportSupportCoreUi2610Library :SDLActivity:prepareComAndroidSupportSupportCoreUtils2610Library :SDLActivity:prepareComAndroidSupportSupportFragment2610Library :SDLActivity:prepareComAndroidSupportSupportMediaCompat2610Library :SDLActivity:prepareComAndroidSupportSupportV42610Library :SDLActivity:prepareComAndroidSupportSupportVectorDrawable2610Library :SDLActivity:prepareReleaseDependencies :SDLActivity:compileReleaseAidl UP-TO-DATE :SDLActivity:compileReleaseRenderscript UP-TO-DATE :SDLActivity:generateReleaseBuildConfig UP-TO-DATE :SDLActivity:generateReleaseResValues UP-TO-DATE :SDLActivity:generateReleaseResources UP-TO-DATE :SDLActivity:mergeReleaseResources UP-TO-DATE :SDLActivity:processReleaseManifest UP-TO-DATE :SDLActivity:processReleaseResources :SDLActivity:generateReleaseSources :SDLActivity:prepareReleaseUnitTestDependencies :SDLActivity:mockableAndroidJar UP-TO-DATE :SDLActivity:incrementalReleaseJavaCompilationSafeguard :SDLActivity:javaPreCompileRelease :SDLActivity:compileReleaseJavaWithJavac 注意:某些输入文件使用或覆盖已弃用的API。 注意:使用-Xlint重新编译:弃用以获取详细信息。

: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 shar ed library D:\ corelab_proj \ GearToTciPlayer2 \ dist ribution \主\ LIB \ armeabi-V7A \ libmain.so :SDLActivity:compileReleaseSources

在1米38秒内建立成功 133个可执行的任务:77个执行,56个最新

1 个答案:

答案 0 :(得分:3)

我解决了引用此问题的问题https://github.com/googlesamples/android-ndk/issues/450