ndk-samples icon indicating copy to clipboard operation
ndk-samples copied to clipboard

android studio doesnot execute exteralnativebuild task

Open AllonJunior opened this issue 5 years ago • 3 comments

I'm using android studio 3.2 to build osg libs, my build.gradle as following:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.renren.myapplication"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        externalNativeBuild {
            cmake {
                arguments '-DOSG_BUILD_PLATFORM_ANDROID=ON'
                '-DUSE_ANDROID_STUDIO=ON'
                '-DOSG_GL_DISPLAYLISTS_AVAILABLE=OFF '
                '-DOSG_GL_MATRICES_AVAILABLE=OFF '
                '-DOSG_GL_VERTEX_FUNCS_AVAILABLE=OFF '
                '-DOSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE=OFF '
                '-DOSG_GL_FIXED_FUNCTION_AVAILABLE=OFF'
                '-DOSG_CPP_EXCEPTIONS_AVAILABLE=OFF '
                '-DOSG_GL1_AVAILABLE=OFF '
                '-DOSG_GL2_AVAILABLE=OFF '
                '-DOSG_GL3_AVAILABLE=OFF '
                '-DOSG_GLES1_AVAILABLE=OFF '
                '-DOSG_GLES2_AVAILABLE=ON'
                '-DDYNAMIC_OPENTHREADS=OFF'
                '-DDYNAMIC_OPENSCENEGRAPH=OFF'
                cppFlags "-Wno-narrow"
                abiFilters "arm64-v8a","armeabi-v7a"
            }
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    externalNativeBuild {
        cmake {
            path "../../osg-android-master/CMakeLists.txt"
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

but when I build the project, nothing happens, the log like this: `Executing tasks: [:app:assembleDebug]

:app:checkDebugClasspath UP-TO-DATE :app:preBuild UP-TO-DATE :app:preDebugBuild UP-TO-DATE :app:compileDebugAidl NO-SOURCE :app:compileDebugRenderscript UP-TO-DATE :app:checkDebugManifest UP-TO-DATE :app:generateDebugBuildConfig UP-TO-DATE :app:prepareLintJar UP-TO-DATE :app:mainApkListPersistenceDebug UP-TO-DATE :app:generateDebugResValues UP-TO-DATE :app:generateDebugResources UP-TO-DATE :app:mergeDebugResources UP-TO-DATE :app:createDebugCompatibleScreenManifests UP-TO-DATE :app:processDebugManifest UP-TO-DATE :app:splitsDiscoveryTaskDebug UP-TO-DATE :app:processDebugResources UP-TO-DATE :app:generateDebugSources UP-TO-DATE :app:javaPreCompileDebug UP-TO-DATE :app:compileDebugJavaWithJavac UP-TO-DATE :app:generateJsonModelDebug UP-TO-DATE :app:externalNativeBuildDebug :app:compileDebugSources :app:mergeDebugShaders UP-TO-DATE :app:compileDebugShaders UP-TO-DATE :app:generateDebugAssets UP-TO-DATE :app:mergeDebugAssets UP-TO-DATE :app:transformClassesWithDexBuilderForDebug UP-TO-DATE :app:transformDexArchiveWithExternalLibsDexMergerForDebug UP-TO-DATE :app:transformDexArchiveWithDexMergerForDebug UP-TO-DATE :app:mergeDebugJniLibFolders UP-TO-DATE :app:transformNativeLibsWithMergeJniLibsForDebug UP-TO-DATE :app:transformNativeLibsWithStripDebugSymbolForDebug UP-TO-DATE :app:checkDebugLibraries UP-TO-DATE :app:processDebugJavaRes NO-SOURCE :app:transformResourcesWithMergeJavaResForDebug UP-TO-DATE :app:validateSigningDebug UP-TO-DATE :app:packageDebug UP-TO-DATE :app:assembleDebug

BUILD SUCCESSFUL in 1s 30 actionable tasks: 1 executed, 29 up-to-date ` and in commen, there should the native building information below the :app:externalNativeBuildDebug block. Is this a bug of android studio or is there something wrong with my configuration?

AllonJunior avatar Oct 09 '18 06:10 AllonJunior

nothing wrong except 2 minor things, from what I see,

  • arguments is a list, separated by comma like
arguments '-DOSG_BUILD_PLATFORM_ANDROID=ON',
                '-DUSE_ANDROID_STUDIO=ON',
  • abiFilters normally get set inside ndk block, not under cmake block
 defaultConfig {
    ndk {
          abiFilters 'arm64-v8a', 'armeabi-v7a', 'x86'
    }
  }

Anyhow those would not block you to generate something. you could try to look at the a couple files under $project/$module/.externalNativeBuild/cmake/debug/armeabi-v7a, *.txt, *.json; the exact command invoking the cmake is there, and also the log file. Once you open them, you will know. That is the first place to go to debug things ( IDE sometimes does not show errors ). Or go to command line run gradlew assembleDebug might also get you some more error message ( I hate this, but sometimes it get the job done ).

I personally kind of busy with other projects, if you do not mind you could share your project, I will try to learn in my spare time, and hope able to help a little ( there are real experts here in this company, that is good things )

ggfan avatar Oct 09 '18 17:10 ggfan

Oops: clicked the wrong button, re-opened it.

ggfan avatar Oct 09 '18 17:10 ggfan

@ggfan thanks a lot for your reply, I will try it and reply the result. Thanks again!

AllonJunior avatar Oct 11 '18 01:10 AllonJunior

Not sure what this has to do with the samples?

DanAlbert avatar May 03 '24 23:05 DanAlbert