I'm currently working on a project trying to get my Samsung Galaxy S2 to interface with the Arduino Mega ADK for Android and I'm getting a bunch of errors.
I've followed directions given here: http://stream.tellart.com/controlling-arduino-with-android/ to the letter. And I've tried running their examples
Specifically the "TapOn" Example (which should allow me to control an LED connected to Arduino from my Android). But each time I run it I get errors on both the processing code for the Android and the arduino code.
Arduino Errors:
AndriodAccessory has not been declaired
AndroidAccessory.cpp:38: error: 'AndroidAccessory' has not been declared
AndroidAccessory.cpp:43: error: ISO C++ forbids declaration of 'AndroidAccessory' with no type
AndroidAccessory.cpp: In function 'int AndroidAccessory(const char*, const char*, const char*, const char*, const char*, const char*)':
AndroidAccessory.cpp:43: error: only constructors take base initializers
AndroidAccessory.cpp: At global scope:
AndroidAccessory.cpp:54: error: 'AndroidAccessory' is not a class or namespace
AndroidAccessory.cpp: In function 'void powerOn()':
AndroidAccessory.cpp:56: error: 'max' was not declared in this scope
AndroidAccessory.cpp:57: error: 'delay' was not declared in this scope
AndroidAccessory.cpp: At global scope:
AndroidAccessory.cpp:60: error: 'AndroidAccessory' is not a class or namespace
AndroidAccessory.cpp:60: error: 'byte' was not declared in this scope
AndroidAccessory.cpp:61: error: expected ',' or ';' before '{' token
AndroidAccessory.cpp:71: error: 'AndroidAccessory' is not a class or namespace
AndroidAccessory.cpp:71: error: variable or field 'sendString' declared void
AndroidAccessory.cpp:71: error: 'byte' was not declared in this scope
AndroidAccessory.cpp:71: error: expected primary-expression before 'int'
AndroidAccessory.cpp:71: error: expected primary-expression before 'const'
AndroidAccessory.cpp:82: error: 'AndroidAccessory' is not a class or namespace
AndroidAccessory.cpp:82: error: 'byte' was not declared in this scope
AndroidAccessory.cpp:83: error: expected ',' or ';' before '{' token
Android/Processing Errors:
Error from inside Android tools
API<=15: Adding annotations.jar to the classpath.
Merging AndroidManifest files into one.
Manifest merger disabled. Using project manifest only.
No AIDL files to compile.
No RenderScript files to compile.
Generating resource IDs...
Generating BuildConfig class.
BUILD FAILED
C:\Users\Nate\Desktop\AndriodSDK\tools\ant\build.xml:705: The following error occurred while executing this line:
C:\Users\Nate\Desktop\AndriodSDK\tools\ant\build.xml:718: Compile failed; see the compiler error output for details.
I don't understand whats wrong and why I'm getting these errors when I haven't changed any of the code from the samples. Also I can write programs for the arduino and android independently of each other, and they work fine... I only get the errors when I want the two to communicate with each-other.
Looks like your code has no library to work with. For me that meant roaming the internet till I found the correct libraries. I would try the following:
Make sure you have the latest Arduino IDE
Download the libraries, probably this.
Although if you want just try the step by step here.
Related
I am able to compile tcl8.6.1 source using GNU Makefile for X86 successfully. Also able cross compile for arm using Android standalone tool chain with make.
When I try to build the same tcl source using Android environment by writing my own Android.mk file and with "mm" command, i am seeing "error: expected ')' before '->' token" error. Detailed error log is given for reference. Please suggest how and where it can go wrong.
system/extras/work/tcl8.6.1/unix/../generic/tclOODecls.h:183:16: error: expected ')' before '->' token
(tclOOStubsPtr->tcl_NewObjectInstance) /* 13 */
^
system/extras/work/tcl8.6.1/unix/../generic/tclOO.c:1562:1: note: in expansion of macro 'Tcl_NewObjectInstance'
Tcl_NewObjectInstance(
^
system/extras/work/tcl8.6.1/unix/../generic/tclOODecls.h:157:16: error: expected ')' before '->' token
(tclOOStubsPtr->tcl_CopyObjectInstance) /* 0 */
^
system/extras/work/tcl8.6.1/unix/../generic/tclOO.c:1840:1: note: in expansion of macro 'Tcl_CopyObjectInstance'
Tcl_CopyObjectInstance(
^
make: Leaving directory `/local/mnt/workspace/Code/TAG_JUNE_15'
make failed to build some targets (38 seconds)
That file (tclOODecls.h) is an auto-generated C header file that describes the C Interface to the TclOO part of the Tcl API. The error indicates that something is not handling the tclOOStubsPtr token well, which is exceptionally strange; it should be a variable that is defined in the stub library. There's something horribly wrong, and given that you appear to be the only person with the problem, I'm guessing it is in your configuration or how you are using it.
I'm trying to get the Eventinjector project from pocketmagic.net found here.
This means working with a precoded jni library writen in C. My problem is that I get some build errors when I try to compile the native code. The error log is long and I believe all errors are the same, therefore I'll only post part of it.
jni/EventInjector.h:718:9: error: (near initialization for 'mt_tool_labels[0].value')
jni/EventInjector.h:719:9: error: 'MT_TOOL_PEN' undeclared here (not in a function)
jni/EventInjector.h:719:9: error: initializer element is not constant
jni/EventInjector.h:719:9: error: (near initialization for 'mt_tool_labels[1].value')
jni/EventInjector.h:720:9: error: 'MT_TOOL_MAX' undeclared here (not in a function)
jni/EventInjector.h:720:9: error: initializer element is not constant
jni/EventInjector.h:720:9: error: (near initialization for 'mt_tool_labels[2].value')
jni/EventInjector.c: In function 'debug':
jni/EventInjector.c:82:2: error: format not a string literal and no format arguments [- Werror=format-security]
cc1.exe: some warnings being treated as errors
make: *** [obj/local/armeabi/objs/EventInjector/EventInjector.o] Error 1
Going throught the comments under the blogpost I discovered that "Alessandro" had the same problem but had found a solution. (post 51) " I had the same issue and imported my own input.h version containing all the missing declarations."
This is the part of the .c file that generates most of the errors:
static struct label key_labels[] = {
LABEL(KEY_RESERVED),
LABEL(KEY_ESC),
LABEL(KEY_1),
LABEL(KEY_2),
LABEL(KEY_3),
LABEL(KEY_4),
LABEL(KEY_5),
LABEL(KEY_6),
LABEL(KEY_7),
LABEL(KEY_8),
LABEL(KEY_9),
LABEL(KEY_0),
LABEL(KEY_MINUS),
LABEL(KEY_EQUAL),
LABEL(KEY_BACKSPACE),
...
I have no experience in C, and don't know what he means. So my question is: how do I do this?
I have succesfully compiled other JNI libs, using NDK v9 and cygwin, so there should not be a problem with my settings and enviroment.
I had the same issue and imported my own input.h version containing all the missing declarations.
You can do same thing and replace your input.h (you can search for input.h with those undefine identifiers in linux kernel sources), but easier way is to remove lines containing undefined identifiers from EventInjector.h. Just comment all lines that highlighted red in eclipse, and it should work.
I am trying to build boost 1.54 for android. I am able to do it for date_time, filesystem, regex, program_options, signals, system and thread libraries of boost. But if I add boost log library among these, build fails as saying 'failed updating 8 targets'.
I appended following lines to my user-config.jam
import os ;
androidNDKRoot = C:/android-ndk-r8e ; # put the relevant path
using gcc : android :
$(androidNDKRoot)/toolchains/arm-linux-androideabi-4.7/prebuilt/windows/bin/arm-linux-androideabi-g++ :
<compileflags>--sysroot=$(androidNDKRoot)/platforms/android-8/arch-arm
<compileflags>-mthumb
<compileflags>-Os
<compileflags>-fno-strict-aliasing
<compileflags>-O2
<compileflags>-DNDEBUG
<compileflags>-g
<compileflags>-lstdc++
<compileflags>-I$(androidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.7/include
<compileflags>-I$(androidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi/include
<compileflags>-D__GLIBC__
<compileflags>-D_GLIBCXX__PTHREADS
<compileflags>-D__arm__
<compileflags>-D_REENTRANT
<archiver>$(androidNDKRoot)/toolchains/arm-linux-androideabi-4.7/prebuilt/windows/bin/arm-linux-androideabi-ar
<ranlib>$(androidNDKRoot)/toolchains/arm-linux-androideabi-4.7/prebuilt/windows/bin/arm-linux-androideabi-ranlib
;
I also changed libs/filesystem/src/operations.cpp file in order to compile threading libraries. You can find the necessary change here.
My build command is as following
set CXXFLAGS="-I%ANDROID_NDK%/platforms/android-8/arch-arm/usr/include -I%ANDROID_NDK%/sources/cxx-stl/gnu-libstdc++/4.4.3/include -I%ANDROID_NDK%/sources/cxx-stl/gnu-libstdc++/4.4.3/libs/armeabi/include "
set TOOLSET=gcc-android
.\b2 --toolset=%TOOLSET% --user-config=./user-config-android.jam cxxflags=%CXXFLAGS% threadapi=pthread --prefix=..\boost_android_arm --builddir=./ target-os=linux --with-date_time --with-filesystem --with-regex --with-log define=BOOST_FILESYSTEM_VERSION=3 --with-program_options --with-signals --with-system --with-thread link=static runtime-link=shared threading=multi install
As I already told before, it does compile if I don't type --with-log at build command.
Here are couple of lines from output,
gcc.compile.c++ bin.v2\libs\log\build\gcc-android\release\build-no\link-static\log-api-unix\target-os-linux\threadapi-pthread\threading-multi\attribute_name.o
In file included from libs\log\src\attribute_name.cpp:32:0:
./boost/log/detail/light_rw_mutex.hpp:131:5: error: 'pthread_rwlock_t' does not name a type
./boost/log/detail/light_rw_mutex.hpp: In constructor 'boost::log::v2s_mt_posix::aux::light_rw_mutex::light_rw_mutex()':
./boost/log/detail/light_rw_mutex.hpp:136:30: error: 'm_Mutex' was not declared in this scope
./boost/log/detail/light_rw_mutex.hpp:136:43: error: 'pthread_rwlock_init' was not declared in this scope
./boost/log/detail/light_rw_mutex.hpp: In destructor 'boost::log::v2s_mt_posix::aux::light_rw_mutex::~light_rw_mutex()':
./boost/log/detail/light_rw_mutex.hpp:140:33: error: 'm_Mutex' was not declared in this scope
./boost/log/detail/light_rw_mutex.hpp:140:40: error: 'pthread_rwlock_destroy' was not declared in this scope
./boost/log/detail/light_rw_mutex.hpp: In member function 'void boost::log::v2s_mt_posix::aux::light_rw_mutex::lock_shared()':
./boost/log/detail/light_rw_mutex.hpp:144:32: error: 'm_Mutex' was not declared in this scope
./boost/log/detail/light_rw_mutex.hpp:144:39: error: 'pthread_rwlock_rdlock' was not declared in this scope
./boost/log/detail/light_rw_mutex.hpp: In member function 'void boost::log::v2s_mt_posix::aux::light_rw_mutex::unlock_shared()':
./boost/log/detail/light_rw_mutex.hpp:148:32: error: 'm_Mutex' was not declared in this scope
./boost/log/detail/light_rw_mutex.hpp:148:39: error: 'pthread_rwlock_unlock' was not declared in this scope
./boost/log/detail/light_rw_mutex.hpp: In member function 'void boost::log::v2s_mt_posix::aux::light_rw_mutex::lock()':
./boost/log/detail/light_rw_mutex.hpp:152:32: error: 'm_Mutex' was not declared in this scope
./boost/log/detail/light_rw_mutex.hpp:152:39: error: 'pthread_rwlock_wrlock' was not declared in this scope
./boost/log/detail/light_rw_mutex.hpp: In member function 'void boost::log::v2s_mt_posix::aux::light_rw_mutex::unlock()':
./boost/log/detail/light_rw_mutex.hpp:156:32: error: 'm_Mutex' was not declared in this scope
./boost/log/detail/light_rw_mutex.hpp:156:39: error: 'pthread_rwlock_unlock' was not declared in this scope
It includes many lines like these, but these are the first error that it gave.
Can someone see what I did wrong or what should I change?
Thanks
Just changing platform to android-9 solved the problem.
After that it gaves another error which is already fixed in here
I build cocos2d-x android project on windows 7.
$. / Build_native.sh - run, and the process falls on
Compile++ thumb : cocos2dx_static <= CCFileUtilsAndroid.cpp
D:/work/Android/rep/cocos2d-2.1rc0-x-2.1.3/testCocos2dx/proj.android/../../cocos2dx/platform/android/CCFileUtilsAndroid.cpp: In member function 'virtual bool cocos2d::CCFileUtilsAndroid::isFileExist(const string&)':
D:/work/Android/rep/cocos2d-2.1rc0-x-2.1.3/testCocos2dx/proj.android/../../cocos2dx/platform/android/CCFileUtilsAndroid.cpp:88:9: error: 'FILE' was not declared in this scope
D:/work/Android/rep/cocos2d-2.1rc0-x-2.1.3/testCocos2dx/proj.android/../../cocos2dx/platform/android/CCFileUtilsAndroid.cpp:88:15: error: 'fp' was not declared in this scope
D:/work/Android/rep/cocos2d-2.1rc0-x-2.1.3/testCocos2dx/proj.android/../../cocos2dx/platform/android/CCFileUtilsAndroid.cpp:88:50: error: 'fopen' was not declared in this scope
D:/work/Android/rep/cocos2d-2.1rc0-x-2.1.3/testCocos2dx/proj.android/../../cocos2dx/platform/android/CCFileUtilsAndroid.cpp:92:22: error: 'fclose' was not declared in this scope
D:/work/Android/rep/cocos2d-2.1rc0-x-2.1.3/testCocos2dx/proj.android/../../cocos2dx/platform/android/CCFileUtilsAndroid.cpp: In member function 'virtual unsigned char* cocos2d::CCFileUtilsAndroid::getFileData(const char*, const char*, long unsigned int*)':
D:/work/Android/rep/cocos2d-2.1rc0-x-2.1.3/testCocos2dx/proj.android/../../cocos2dx/platform/android/CCFileUtilsAndroid.cpp:133:13: error: 'FILE' was not declared in this scope
D:/work/Android/rep/cocos2d-2.1rc0-x-2.1.3/testCocos2dx/proj.android/../../cocos2dx/platform/android/CCFileUtilsAndroid.cpp:133:19: error: 'fp' was not declared in this scope
D:/work/Android/rep/cocos2d-2.1rc0-x-2.1.3/testCocos2dx/proj.android/../../cocos2dx/platform/android/CCFileUtilsAndroid.cpp:133:50: error: 'fopen' was not declared in this scope
D:/work/Android/rep/cocos2d-2.1rc0-x-2.1.3/testCocos2dx/proj.android/../../cocos2dx/platform/android/CCFileUtilsAndroid.cpp:137:32: error: 'fseek' was not declared in this scope
D:/work/Android/rep/cocos2d-2.1rc0-x-2.1.3/testCocos2dx/proj.android/../../cocos2dx/platform/android/CCFileUtilsAndroid.cpp:138:28: error: 'ftell' was not declared in this scope
D:/work/Android/rep/cocos2d-2.1rc0-x-2.1.3/testCocos2dx/proj.android/../../cocos2dx/platform/android/CCFileUtilsAndroid.cpp:141:62: error: 'fread' was not declared in this scope
D:/work/Android/rep/cocos2d-2.1rc0-x-2.1.3/testCocos2dx/proj.android/../../cocos2dx/platform/android/CCFileUtilsAndroid.cpp:142:22: error: 'fclose' was not declared in this scope
/cygdrive/d/work/Android/android-ndk-r8-crystax-1/build/core/build-binary.mk:320: recipe for target `obj/local/armeabi/objs/cocos2dx_static/platform/android/CCFileUtilsAndroid.o' failed
ScreenShot : http://joxi.ru/wy6OUdg5CbBkfuw7mZ4
How to fix it to build the project on?
Seems the Cocos2d-x code is not including the cstdio header where those things are declared. To fix this, edit the CCFileUtilsAndroid.cpp file and add the line
#include <cstdio>
up there at the top with the other includes. Now all those f* functions and FILE should be found.
have you solved this problem? Arleryd's solution worked for me, and the later error you post could be solved by this:
import the C:\cocos2d-x-2.2.0\cocos2dx\platform\android to eclipse, then done. see this:
http://www.cocos2d-x.org/wiki/How_to_set_up_the_android_cocos2d-x_development_environment_on_Windows_7
I am trying to compile a file using gcc from Android toolchain. For some reason, when including
android-ndk-r8//platforms/android-3/arch-arm/usr/include, it is compiled. However, when using andriod-8
android-ndk-r8//platforms/android-8/arch-arm/usr/include, it gives me this error:
error: dereferencing pointer to incomplete type
The problem is regarding refrences fields of struct tm. i.e.
struct tm *t;
t->tm_hour;
Any ideas?
Thanks