Hi,
I tried with NDK r9c.
But I still have some problem:
$ ./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
> /home/mastro/ws/myproject/app/myproject-app-client-android/MyProject/src/main/jni/myprojectToyRenderer.cpp:10:62:
>
> fatal error: assimp/Importer.hpp: No such file or directory
> compilation terminated.
> make: ***
> [/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]
>
> Error 1
> :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-r9c/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:
>
> /home/mastro/ws/myproject/app/myproject-app-client-android/MyProject/src/main/jni/myprojectToyRenderer.cpp:10:62:
>
> fatal error: assimp/Importer.hpp: No such file or directory
> compilation terminated.
> make: ***
> [/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]
>
> Error 1
>
> * 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: 4.892 secs
I still see it trying to execute with "ALL" abi even if I specified
arm-only ABI. and APP PLATFORM 18 even if I specified version 9.
Anyway the error is about assimp/Importer.hpp missing.
In my Android.mk I have this:
LOCAL_EXPORT_C_INCLUDES := ${PROJECT_PATH}/assimp/include
witch worked before.
PROJECT_PATH is computed like this:
PROJECT_PATH := $(abspath $(call my-dir)/../../../)
The path is correct because it would complain about missing assimp.so
otherwise.
This is my Android.mk
# An Android.mk file must begin with the definition of the LOCAL_PATH
> # variable. It is used to locate source files in the development tree. Here
> # the macro function 'my-dir' (provided by the build system) is used to
> return
> # the path of the current directory.
> LOCAL_PATH := $(call my-dir)
> # I need this to know the path of my project (to import assimp)
> PROJECT_PATH := $(abspath $(call my-dir)/../../../)
>
> #-----------------------------------------------------------------------------
> # The CLEAR_VARS variable is provided by the build system and points to a
> # special GNU Makefile that will clear many LOCAL_XXX variables for you
> # (e.g. LOCAL_MODULE, LOCAL_SRC_FILES, LOCAL_STATIC_LIBRARIES, etc...),
> # with the exception of LOCAL_PATH. This is needed because all build
> # control files are parsed in a single GNU Make execution context where
> # all variables are global.
> # -------- Vuforia Include --------
> # The following section is used for copying the libQCAR.so prebuilt library
> # into the appropriate folder (libs/armeabi and libs/armeabi-v7a
> respectively)
> # and setting the include path for library-specific header files.
> # ANDROID_VUFORIA_HOME environment path must have been set to the home of
> the Vuforia SDK
> include $(CLEAR_VARS)
> LOCAL_MODULE := QCAR-prebuilt
> LOCAL_SRC_FILES =
> ${ANDROID_VUFORIA_HOME}/build/lib/$(TARGET_ARCH_ABI)/libQCAR.so
> LOCAL_EXPORT_C_INCLUDES := ${ANDROID_VUFORIA_HOME}/build/include
> include $(PREBUILT_SHARED_LIBRARY)
> # see below LOCAL_SHARED_LIBRARIES := QCAR-prebuilt
> # -------- assimp library Include -------
> include $(CLEAR_VARS)
> LOCAL_MODULE := assimp
> LOCAL_SRC_FILES =
> ${PROJECT_PATH}/assimp/binaries/$(TARGET_ARCH_ABI)/libassimp.so
> LOCAL_EXPORT_C_INCLUDES := ${PROJECT_PATH}/assimp/include
> include $(PREBUILT_SHARED_LIBRARY)
> # see below LOCAL_SHARED_LIBRARIES += assimp
> # -------- My local AugmentedToy module --------
> include $(CLEAR_VARS)
> # The LOCAL_MODULE variable must be defined to identify each module you
> # describe in your Android.mk. The name must be *unique* and not contain
> # any spaces. Note that the build system will automatically add proper
> # prefix and suffix to the corresponding generated file. In other words,
> # a shared library module named 'foo' will generate 'libfoo.so'.
> LOCAL_MODULE := AugmentedToy
> # This sample always uses OpenGL ES 2.0.
> OPENGLES_LIB := -lGLESv2
> OPENGLES_DEF := -DUSE_OPENGL_ES_2_0
> # An optional set of compiler flags that will be passed when building
> # C and C++ source files.
> #
> # The flag "-Wno-write-strings" removes warnings about deprecated
> conversion
> # from string constant to 'char*'.
> # The flag "-Wno-psabi" removes warning about "mangling of 'va_list' has
> # changed in GCC 4.4" when compiled with certain Android NDK versions.
> LOCAL_CFLAGS := -Wno-write-strings -Wno-psabi $(OPENGLES_DEF)
> LOCAL_CFLAGS += -fexceptions
> # The list of additional linker flags to be used when building your
> # module. Use the "-l" prefix in front of the name of libraries you want to
> # link to your module.
> LOCAL_LDLIBS := \
> -llog $(OPENGLES_LIB)
> # android is beeing added to use asset manager (target version android 9)
> LOCAL_LDLIBS += -landroid
> # The list of shared libraries this module depends on at runtime.
> # This information is used at link time to embed the corresponding
> information
> # in the generated file. Here we reference the prebuilt library defined
> earlier
> # in this makefile.
> LOCAL_SHARED_LIBRARIES := QCAR-prebuilt
> LOCAL_SHARED_LIBRARIES += assimp
> # The LOCAL_SRC_FILES variables must contain a list of C/C++ source files
> # that will be built and assembled into a module. Note that you should not
> # list header file and included files here because the build system will
> # compute dependencies automatically for you, just list the source files
> # that will be passed directly to a compiler.
> LOCAL_SRC_FILES := myprojectToyRenderer.cpp VuforiaIntegration.cpp
> # By default, ARM target binaries will be generated in 'thumb' mode, where
> # each instruction is 16-bit wide. You can set this variable to 'arm' to
> # set the generation of the module's object files to 'arm' (32-bit
> # instructions) mode, resulting in potentially faster yet somewhat larger
> # binary code.
> LOCAL_ARM_MODE := arm
> # BUILD_SHARED_LIBRARY is a variable provided by the build system that
> # points to a GNU Makefile script being in charge of collecting all the
> # information you have defined in LOCAL_XXX variables since the latest
> # 'include $(CLEAR_VARS)' statement, determining what and how to build.
> # Replace it with the statement BUILD_STATIC_LIBRARY to generate a static
> # library instead.
> include $(BUILD_SHARED_LIBRARY)
The project directory structure is this:
> myprojectToybox/
> ├── 3dmodels
> │ └── android
> │ └── dae
> ├── assimp
> │ ├── binaries
> │ │ ├── armeabi
> │ │ └── armeabi-v7a
> │ └── include
> │ └── assimp
> │ └── Compiler
> ├── build
> │ └── ndk
> │ └── debug
> │ ├── lib
> │ └── obj
> ├── libs
> └── src
> ├── debug
> │ ├── java
> │ │ └── com
> │ └── res
> │ ├── layout
> │ └── values
> ├── instrumentTest
> │ ├── assets
> │ │ └── jsons
> │ └── java
> │ └── com
> ├── main
> │ ├── assets
> │ │ ├── augmentedreality
> │ │ ├── fonts
> │ │ └── tagmanager
> │ ├── java
> │ │ └── com
> │ ├── jni
> │ ├── libs
> │ │ ├── armeabi
> │ │ └── armeabi-v7a
> │ ├── obj
> │ │ └── local
> │ └── res
> │ ├── anim
> │ ├── color
> │ ├── drawable
> │ ├── drawable-hdpi
> │ ├── drawable-mdpi
> │ ├── drawable-xhdpi
> │ ├── drawable-xxhdpi
> │ ├── drawable-xxxhdpi
> │ ├── layout
> │ ├── layout-land
> │ ├── layout-w520dp
> │ ├── menu
> │ ├── values
> │ ├── values-land
> │ ├── values-sw600dp
> │ ├── values-sw720dp-land
> │ ├── values-v11
> │ ├── values-v14
> │ └── xml
> └── release
> └── res
> └── values
Am I doing something wrong?
If this can't be easily solved is there a way to disable the default NDK
from the plugin and leave my previous code running?
Thank you!
Cheers,
Daniele
On Friday, January 17, 2014 5:37:35 PM UTC+1, Xavier Ducrohet wrote:
>
> The new NDK integration requires NDK r9c
>
>
> On Fri, Jan 17, 2014 at 7:53 AM, Daniele Segato
> <[email protected]<javascript:>
> > 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] <javascript:>.
>> 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.