I downloaded android source from source.android.com and followed the instruction to setup build environment on MAC OS X, Everything went fine except when i run make it gives me following error
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=4.0.1
TARGET_PRODUCT=full
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a
HOST_ARCH=x86
HOST_OS=darwin
HOST_BUILD_TYPE=release
BUILD_ID=ITL41D
============================================
host C++: aapt <= frameworks/base/tools/aapt/AaptAssets.cpp
frameworks/base/tools/aapt/AaptAssets.cpp:2161:38: warning: unused parameter 'bundle' [-Wunused-parameter]
AaptAssets::slurpResourceZip(Bundle* bundle, const char* filename)
^
In file included from frameworks/base/tools/aapt/AaptAssets.cpp:5:
In file included from frameworks/base/tools/aapt/AaptAssets.h:10:
In file included from frameworks/base/include/utils/AssetManager.h:25:
frameworks/base/include/utils/KeyedVector.h:193:17: error: use of undeclared identifier 'indexOfKey'
ssize_t i = indexOfKey(key);
^
this->
frameworks/base/tools/aapt/AaptAssets.h:446:46: note: in instantiation of member function 'android::DefaultKeyedVector<android::String8, android::sp<AaptSymbols> >::valueFor' requested here
sp<AaptSymbols> sym = mNestedSymbols.valueFor(name);
^
frameworks/base/include/utils/KeyedVector.h:66:29: note: must qualify identifier to find this declaration in dependent base class
ssize_t indexOfKey(const KEY& key) const;
^
1 warning and 1 error generated.
make: *** [out/host/darwin-x86/obj/EXECUTABLES/aapt_intermediates/AaptAssets.o] Error 1
I just started in android so do not have any clue, any small help also would be appreciated
Just to expand on Pete's answer, in case anyone really wants to know:
The indexOfKey is defined in DefaultKeyVector's parent class, KeyedVector. For class templates, a function call is resolved during compile-time, not during run-time. The error happens because at the point indexOfKey is called, the compiler wouldn't know where that template function might be located. Here is how the base and derived classes look like:
template <typename KEY, typename VALUE>
class KeyedVector
{
...
ssize_t indexOfKey(const KEY& key) const;
...
template <typename KEY, typename VALUE>
class DefaultKeyedVector : public KeyedVector<KEY, VALUE>
{
...
And the offending call:
template<typename KEY, typename VALUE> inline
const VALUE& DefaultKeyedVector<KEY,VALUE>::valueFor(const KEY& key) const {
ssize_t i = indexOfKey(key);
...
Most likely, using the older MacOS SDK compiler (or other compilers) works because it was probably just guessing the function exists in some base class, instead of failing. However, that is not standard behavior.
More info from this clang entry, and from the C++ FAQ.
I finally figured out the problem.
There's an error in the sourcecode of frameworks/base/include/utils/KeyedVector.h:193
Some of the member functions require Scope resolution operator "this->" to build the android source on MAC OS X Lion with xcode 4.3.x and on gcc version 4.9.2 (Debian 4.9.2-10).
Without scope resolution operator compiler will not be able to identify the existence of the function.
Open frameworks/base/include/utils/KeyedVector.h
Change the line 193 from:
ssize_t i = indexOfKey(key);
to
ssize_t i = this->indexOfKey(key);
and Android 4.0.1 compiles.
To build ICS on newer GCC versions, you must apply these patches:
https://groups.google.com/forum/#!msg/android-building/2EwtWQTqjdI/fbZlzXErscwJ
I faced this problem several times when building Browser for Android 4.0.3 with make -j Browser on MAC OS X 10.8.4. I dont have any problem with Android 4.2.1.
So my solution is
make CC=gcc CXX=g++ -j Browser
Hope it helps
Related
I setup conan for cross building android app on my linux, i have my_profile below for conan for this cross building, which that I run conan create . user/testing -pr=my_profile
include(default)
target_host=aarch64-linux-android
android_ndk=$HOME/android-ndk-r21
api_level=21
[settings]
arch=armv8
build_type=Release
compiler=clang
compiler.libcxx=libc++
compiler.version=9
os=Android
os.api_level=$api_level
[build_requires]
[options]
[env]
PATH=[$android_ndk/toolchains/llvm/prebuilt/linux-x86_64/bin]
CHOST=$target_host
AR=$target_host-ar
AS=$target_host-as
LD=$target_host-ld
STRIP=$target_host-strip
RANLIB=$target_host-ranlib
CC=$target_host$api_level-clang
CXX=$target_host$api_level-clang++
CONAN_MAKE_PROGRAM=$android_ndk/prebuilt/linux-x86_64/bin/make
CONAN_CMAKE_TOOLCHAIN_FILE=$android_ndk/build/cmake/android.toolchain.cmake
and I made a very simple file:
#include <fcntl.h>
int raw_fallocate(int fd, off_t length) {
if (fallocate(fd, 0, 0, length) == 0) return 0;
return -1;
}
I found that in the fcntl.h, it only defines fallocate when __ANDROID_API >=21 with #ifdef
so in my CMakeLists.txt, I need to put
target_compile_definitions(hello PRIVATE __ANDROID_API__=21) to make it compile, otherwise, the compiler will complain it cannot find definition of fallocate.
That all make sense. However, when I put this preprocessor definition, I still got a warning message saying:
In file included from <built-in>:413:
<command line>:1:9: warning: '__ANDROID_API__' macro redefined [-Wmacro-redefined]
#define __ANDROID_API__ 21
^
<built-in>:405:9: note: previous definition is here
#define __ANDROID_API__ 16
^
1 warning generated.
What I don't understand is I could not find this built-in thing..., i searched my whole android_ndk folder, and could not find where is this #define __ANDROID_API__ 16
Also I only have android_ndk v21 installed, I have no idea where this version of 16 came from.
Any idea?
This #define __ANDROID_API__ 16 comes from the NDK itself (this is the lowest supported API for android-ndk-r21. To set it to 21, you must pass ANDROID_PLATFORM parameter to CMake. Update: this is actually wrong. For ABI arm64-v8a the minimal API is 21. So, the problem is that arch=armv8 didn't work.
According to the conan instructions, set os.api_level=21 should have worked. But with this approach, you should not supply the CONAN_CMAKE_TOOLCHAIN_FILE. Update: this does not work because conan is not compatible with NDK r21.
I assume that when you do supply CONAN_CMAKE_TOOLCHAIN_FILE, all the settings, like CC= and AR= become irrelevant. Same for os.api_level and arch. But if you replace cmake with a script that calls the original cmake binary and sets the necessarycommand-line parameters, including -DANDROID_PLATFORM=android-21, you should be set. Simply add to my_profile:
CONAN_CMAKE_PROGRAM=cmake-wrapper
This approach is used in https://github.com/bincrafters/conan-android_ndk_installer package.
So I've been digging into this a little bit, and I think I found where the problem is. As #Alex Cohn said, the android ndk sets the min api level to 16 in the file
$android_ndk/build/cmake/platforms.cmake, it says on the first line set(NDK_MIN_PLATFORM_LEVEL "16"). After I change it to 21, everything works.
Now the question becomes: How can I override this value externally without touching this platforms.cmake file (I just don't want to touch files come with ndk package)? I tried to put set(NDK_MIN_PLATFORM_LEVEL "16") in my CMakelists.txt file for my project, but that does not work as I believe it is overridden later on by platforms.cmake.
Of course the second method of using conan's ndk-installer also works, and I checked the same platforms.cmake file in the installed ndk folder, it has the same value of 16. So there must be somewhere in conan settings that updated the value to 21, and I would like to learn where / how this is changed when using ndk-installer, so I can do the same for my manually installled android ndk.
I am using pyqtdeploy to pack a much simple python script into Qt Project. Then I will try to compile it as .apk file. I consider the environment has been completely set up so far, including Android SDK, Android NDK, Qt, android studio, ant etc. A strange error always appears when running pyqtdeploy.
Here is my code:
import sys
from PyQt5.QtWidgets import QApplication, QWidget, QLabel
class Main(QWidget):
def __init__(self):
super().__init__()
self.build_inter()
def build_inter(self):
self.lb = QLabel("Test", self)
self.lb.move(0, 0)
self.show()
if __name__ == '__main__':
app = QApplication(sys.argv)
w = Main()
sys.exit(app.exec_())
I intercepted a part of error information:
..\include/pyport.h:617:60: error: expected constructor, destructor, or type conversion before '(' token
# define PyAPI_FUNC(RTYPE) __declspec(dllexport) RTYPE
^
..\include/fileutils.h:109:1: note: in expansion of macro 'PyAPI_FUNC'
PyAPI_FUNC(int) _Py_get_inheritable(int fd);
^
..\include/pyport.h:617:60: error: expected constructor, destructor, or type conversion before '(' token
# define PyAPI_FUNC(RTYPE) __declspec(dllexport) RTYPE
^
..\include/fileutils.h:111:1: note: in expansion of macro 'PyAPI_FUNC'
PyAPI_FUNC(int) _Py_set_inheritable(int fd, int inheritable,
^
..\include/pyport.h:617:60: error: expected constructor, destructor, or type conversion before '(' token
# define PyAPI_FUNC(RTYPE) __declspec(dllexport) RTYPE
^
..\include/fileutils.h:114:1: note: in expansion of macro 'PyAPI_FUNC'
PyAPI_FUNC(int) _Py_dup(int fd);
and the screenshot:
My config:
Have anyone encountered a similar problem? What am I supposed to do?
Thanks in advance!
I'm far from being an expert, but in the documentation it reads it does not make sense to check "run application" unless the target environment is equal to the source environment. From your windows it seems you are cross compiling from Windows to Android, thus I would try to omit the last parameter of "Additional build steps" ("run application"). You would then have to test it yourself from e.g. Android studio I guess. Hope it helps.
ACE+TAO: 6.3.2
OpenDDS: 3.11
Host compiler: GCC 5.4
As I cross-compile OpenDDS for Android, I'm looking at ACE_wrappers/build/arm/include/makeinclude/platform_android.GNU which appears to do the cross-compiling for ACE, and it appears to only build for ARM-v7a.
The reason why I say this is that I'm getting the following error when compiling the auto-generated files in my application ((which come from using opendds_idl on the *.idl), and after a bunch of "In file included from" lines, ends up with ...
[exec] /home/me/tools/crystax-ndk/sources/cxx-stl/gnu-libstdc++/5/include/limits:1601:7: internal compiler error: Illegal instruction
[exec] max() _GLIBCXX_USE_NOEXCEPT { return __FLT_MAX__; }
[exec] ^
I've seen something like this before when I've compiled code which had some wrong flags for the CPU architecture. So my thinking is that maybe there's some incompatible toolchain settings on GCC which I use on my app and those settings used by ACE+TAO/OpenDDS? The CROSS_COMPILE variable in platform_android.GNU is arm-linux-androideabi- ... which as far as I know is a 32 bit toolchain, i.e., arm-v7a and I see no v8a references. And yet in my app I'm using aarch64-linux-android-5. Should these be compatible? Can the tool chain be changed?
What I'd like to do is build ACE+TAO/OpenDDS/my-application for the target architecture and ABI ... arm64: arm64-v8a and use the NDK toolchain and target ABI ... aarch64-linux-android-5: arm64-v8a.
Thoughts?
This should be possible, but probably configuration files are outdated. First, update to ACE+TAO 6.3.4 which is the latest. Second, check the file include/makeinclude/platform_android.GNU and see if your target is there. It could be that some small updates are necessary, if so, please open a pull request at https://github.com/DOCGroup/ACE_TAO with the necessary changes. Search for arm-v7a and look if at that place a new check for arm-v8a is necessary.
I'm compiling C++ code written primarily for Mac OS, using the Android NDK and I get the following error:
- Type 'errno_t' could not be resolved
In Xcode this type is defined on OSX 10.0/usr/include/sys/_types/_errno_t.h as this:
#ifndef _ERRNO_T
#define _ERRNO_T
typedef int errno_t;
#endif /* _ERRNO_T */
Any suggestions on how to convert this to the NDK, or add compiler flags to make this compile, or where to even get the source code to define this type in my source code itself?
Thanks.
See this answer for information on errno_t.
errno_t is not a part of the C standard, and bionic doesn't support it.
The fix is simply to change all the errno_ts to be ints.
I followed the instructions on source.android.com to build the Android framework, but when I run the make command I get many errors. I'm running a virtualized 32-bit Ubuntu 11.04 on vmware under a 64-bit Windows Vista.
cat /proc/version
says
Linux version 2.6.38-8-generic (buildd#vernadsky) (gcc version 4.5.2 (Ubuntu/Linaro 4.5.2-8ubuntu3) ) #42-Ubuntu SMP Mon Apr 11 03:31:50 UTC 2011
I have synchronized everything by using:
repo init -u https://android.googlesource.com/platform/manifest
repo sync
and I chose the full-engineering target by using:
lunch full-eng
This is a partial list of the errors I get:
PLATFORM_VERSION_CODENAME=AOSP
PLATFORM_VERSION=4.0.3.0.2.0.1.0
TARGET_PRODUCT=full
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=OPENMASTER
OUT_DIR=out
/bin/bash: line 0: cd: cts/tools/cts-native-xml-generator/src/res: No such file or directory
host Java: doclava (out/host/common/obj/JAVA_LIBRARIES/doclava_intermediates/classes)
external/doclava/src/com/google/doclava/ClassInfo.java:20: package com.sun.javadoc does not exist
import com.sun.javadoc.ClassDoc;
^
external/doclava/src/com/google/doclava/ClassInfo.java:62: cannot find symbol
symbol : class ClassDoc
location: class com.google.doclava.ClassInfo
public ClassInfo(ClassDoc cl, String rawCommentText, SourcePositionInfo position,
^
external/doclava/src/com/google/doclava/PackageInfo.java:21: package com.sun.javadoc does not exist
import com.sun.javadoc.*;
^
external/doclava/src/com/google/doclava/ClassInfo.java:1406: cannot find symbol
symbol : class ClassDoc
location: class com.google.doclava.ClassInfo
private ClassDoc mClass;
^
external/doclava/src/com/google/doclava/PackageInfo.java:33: cannot find symbol
symbol : class PackageDoc
location: class com.google.doclava.PackageInfo
public PackageInfo(PackageDoc pkg, String name, SourcePositionInfo position) {
^
external/doclava/src/com/google/doclava/PackageInfo.java:185: cannot find symbol
symbol : class PackageDoc
location: class com.google.doclava.PackageInfo
private PackageDoc mPackage;
^
external/doclava/src/com/google/doclava/apicheck/XmlApiFile.java:28: package com.sun.javadoc does not exist
import com.sun.javadoc.ClassDoc;
^
external/doclava/src/com/google/doclava/Converter.java:19: package com.sun.javadoc does not exist
import com.sun.javadoc.*;
^
external/doclava/
Below is what removed these errors in my case. An offending extraneous '/' at the end.
bad:
export PATH=/home/rev/BIN/jdk-6u34/jdk1.6.0_34/bin/:$PATH
Good:
export PATH=/home/rev/BIN/jdk-6u34/jdk1.6.0_34/bin:$PATH
To fix this on OSX, add the Java bin directory to PATH
export PATH=/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/bin:$PATH
PS: The jdk folder(jdk.1.7.0_51.jdk) might be different for folks as it depends on the version on jdk you have installed. Just use the jdk folder you have installed. The path to bin is the same.
Another cause of this error is if you are using something like jenv to manage multiple Java environments. The Android build tools, by default, search for tools.jar relative to the location of the javac binary. If you are using jenv (or any other tool that hijacks javac), this will not work.
However, you can set the environment variable ANDROID_JAVA_HOME to point to your "real" JDK, in which case the build tools will look in $ANDROID_JAVA_HOME/lib/tools.jar.
The following was my fix in OSX. You have to see what JVMs you have and set it appropriately.
export ANDROID_JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home
It is recommended to build Android sources using 64bit Ubuntu Linux. But I do not think that this is a problem in your case. It seems to me that the problem in JDK. Have you installed JDK 6 version on your machine?
I ran into this too, and the issue was that I was missing some Ubuntu packages. Once I followed the instructions in http://source.android.com/source/initializing.html to install the packages, things worked fine.
It's confusing since the error is in Java, but the problem is in the OS.
Finally I Finished My Project with AOPS
There is a error about [doclava] that up mentioned
I check a lot information than I ADD the
export ANDROID_JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home
Good Luck...