The new NDK integration requires NDK r9c

On Fri, Jan 17, 2014 at 7:53 AM, Daniele Segato <[email protected]>wrote:

> Hi,
>
> I had the need to update one of my customer app today.
>
> It was using gradle 0.6 with a snipped of code to compile it I wrote
> myself modifying what I found suggested in this very forum.
>
> The new Android Studio forced me to switch to gradle 1.9, which in turn
> force me to switch to android gradle plugin 0.7.
> This include the NDK support.
>
> I'm using NDK version: ndk-r8e
>
> I switched everything to the new version, commented out my custom code for
> building the NDK then tried:
>
> $ ./gradlew clean assemble
>> Relying on packaging to define the extension of the main artifact has
>> been deprecated and is scheduled to be removed in Gradle 2.0
>> :MyProject:clean
>> :play_apk_expansion_downloader_library:clean UP-TO-DATE
>> :play_licensing_library:clean UP-TO-DATE
>> :volley:clean UP-TO-DATE
>> :FacebookSDK:facebook:clean UP-TO-DATE
>> :ViewPagerIndicator:library:clean UP-TO-DATE
>> :MyProject:compileDebugNdk FAILED
>> FAILURE: Build failed with an exception.
>> * What went wrong:
>> Execution failed for task ':MyProject:compileDebugNdk'.
>> > NDK not configured
>> * Try:
>> Run with --stacktrace option to get the stack trace. Run with --info or
>> --debug option to get more log output.
>> BUILD FAILED
>> Total time: 9.791 secs
>
>
>
> Googling I found out I should add the ndk.dir to local.properties, even if
> I had the environment variable ANDROID_NDK_HOME correctly set up.
>
> did so then re-issued the command:
>
> $ ./gradlew clean assemble
>> Relying on packaging to define the extension of the main artifact has
>> been deprecated and is scheduled to be removed in Gradle 2.0
>> :MyProject:clean
>> :play_apk_expansion_downloader_library:clean UP-TO-DATE
>> :play_licensing_library:clean UP-TO-DATE
>> :volley:clean UP-TO-DATE
>> :FacebookSDK:facebook:clean UP-TO-DATE
>> :ViewPagerIndicator:library:clean UP-TO-DATE
>> :MyProject:compileDebugNdk
>> make: *** No rule to make target
>> `/home/mastro/ws/myproject/app/myproject-app-client-android/MyProject/build/ndk/debug//home/mastro/ws/myproject/app/myproject-app-client-android/MyProject/src/main/jni/myprojectToyRenderer.cpp',
>> needed by
>> `/home/mastro/ws/myproject/app/myproject-app-client-android/MyProject/build/ndk/debug/obj/local/armeabi-v7a/objs/MyProject//home/mastro/ws/myproject/app/myproject-app-client-android/MyProject/src/main/jni/myprojectToyRenderer.o'.
>>  Stop.
>> :MyProject:compileDebugNdk FAILED
>> FAILURE: Build failed with an exception.
>> * What went wrong:
>> Execution failed for task ':MyProject:compileDebugNdk'.
>> > com.android.ide.common.internal.LoggedErrorException: Failed to run
>> command:
>>   /home/mastro/usr/android/ndk-r8e/ndk-build NDK_PROJECT_PATH=null
>> APP_BUILD_SCRIPT=/home/mastro/ws/myproject/app/myproject-app-client-android/MyProject/build/ndk/debug/Android.mk
>> APP_PLATFORM=android-18
>> NDK_OUT=/home/mastro/ws/myproject/app/myproject-app-client-android/MyProject/build/ndk/debug/obj
>> NDK_LIBS_OUT=/home/mastro/ws/myproject/app/myproject-app-client-android/MyProject/build/ndk/debug/lib
>> APP_ABI=all
>>   Error Code:
>>   2
>>   Output:
>>   make: *** No rule to make target
>> `/home/mastro/ws/myproject/app/myproject-app-client-android/MyProject/build/ndk/debug//home/mastro/ws/myproject/app/myproject-app-client-android/MyProject/src/main/jni/myprojectToyRenderer.cpp',
>> needed by
>> `/home/mastro/ws/myproject/app/myproject-app-client-android/MyProject/build/ndk/debug/obj/local/armeabi-v7a/objs/MyProject//home/mastro/ws/myproject/app/myproject-app-client-android/MyProject/src/main/jni/myprojectToyRenderer.o'.
>>  Stop.
>>
>> * Try:
>> Run with --stacktrace option to get the stack trace. Run with --info or
>> --debug option to get more log output.
>> BUILD FAILED
>> Total time: 5.578 secs
>
>
>
> I'm not very expert with C / C++ issues...
>
> but I found two things to be very weird:
> NDK_PROJECT_PATH=null
>
> APP_PLATFORM=18
> APP_ABI=all
>
> I specified in Application.mk:
> APP_ABI := armeabi armeabi-v7a
> APP_PLATFORM := android-9
>
> It seems to completely ignore my Application.mk
>
>
>
> This was my perfectly working (on gradle
> 1.8, com.android.tools.build:gradle:0.6.+ plugin) build.gradle file (the
> part I added for compiling NDK):
>
>
> //////////////
>> // NDK Support
>> //////////////
>> // If using this, Android studio will fail run the following to set the
>> environment variable for android studio:
>> // export ANDROID_NDK_HOME=/Android/android-ndk-r8e (Linux)
>> // launchctl setenv ANDROID_NDK_HOME /Android/android-ndk-r8e (Mac)
>> // or, better, add the export to the .profile of your user home and
>> re-login
>> task copyNativeLibs(type: Copy, dependsOn: 'buildNative') {
>>     from(new File('src/main/libs')) { include '**/*.so' }
>>     into new File(buildDir, 'native-libs')
>> }
>> tasks.withType(JavaCompile) { compileTask -> compileTask.dependsOn
>> copyNativeLibs }
>> clean.dependsOn 'cleanCopyNativeLibs'
>> tasks.withType(com.android.build.gradle.tasks.PackageApplication) {
>> pkgTask ->
>>     pkgTask.jniFolders = new HashSet<File>()
>>     pkgTask.jniFolders.add(new File(projectDir, 'native-libs'))
>> }
>> task buildNative(type: Exec) {
>>     def ndkBuild;
>>     def ndkBuildingDir = new File("src/main");
>> //    def ndkSourcesDir = new File(ndkBuildingDir, "jni")
>> //    def ndkOutputDir = new File(buildDir, 'native-libs')
>>     def hasNdk = false;
>>     if (System.env.ANDROID_NDK_HOME != null) {
>>         hasNdk = true;
>>         if (System.getProperty("os.name").startsWith("Windows")) {
>>             ndkBuild = new File(System.env.ANDROID_NDK_HOME,
>> 'ndk-build.cmd')
>>         } else {
>>             ndkBuild = new File(System.env.ANDROID_NDK_HOME, 'ndk-build')
>>         }
>>     }
>> //    inputs.files fileTree(ndkSourcesDir)
>> //    outputs.dir ndkOutputDir
>>     commandLine ndkBuild, "--directory", ndkBuildingDir
>>     doFirst {
>>         if (!hasNdk) {
>>             logger.error('##################')
>>             logger.error("Failed NDK build")
>>             logger.error('Reason: Reason: ANDROID_NDK_HOME not set.')
>>             logger.error('##################')
>>         }
>>         assert hasNdk : "ANDROID_NDK_HOME not set."
>>     }
>> }
>> task cleanNative(type: Exec) {
>>     def ndkBuild;
>>     def ndkBuildingDir = new File("src/main");
>>     def hasNdk = false;
>>     if (System.env.ANDROID_NDK_HOME != null) {
>>         hasNdk = true;
>>         if (System.getProperty("os.name").startsWith("Windows")) {
>>             ndkBuild = new File(System.env.ANDROID_NDK_HOME,
>> 'ndk-build.cmd')
>>         } else {
>>             ndkBuild = new File(System.env.ANDROID_NDK_HOME, 'ndk-build')
>>         }
>>     }
>>     commandLine ndkBuild, "--directory", ndkBuildingDir, "clean"
>>     doFirst {
>>         if (!hasNdk) {
>>             logger.error('##################')
>>             logger.error("Failed NDK build")
>>             logger.error('Reason: Reason: ANDROID_NDK_HOME not set.')
>>             logger.error('##################')
>>         }
>>         assert hasNdk : "ANDROID_NDK_HOME not set."
>>     }
>> }
>> clean.dependsOn 'cleanNative'
>
>
>
> Can you help me out?
> Thanks and regards,
> Daniele
>
>  --
> You received this message because you are subscribed to the Google Groups
> "adt-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
Xavier Ducrohet
Android SDK Tech Lead
Google Inc.
http://developer.android.com | http://tools.android.com

Please do not send me questions directly. Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"adt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to