Sorry it's my first time with cross-platform programming and I spent 4 hours for naught this afternoon.
I currently have a cocos2dx win32 project. I can run it on Visual Studio. My mentor told me to find a way to convert it to an android project. I have followed the instructions to set up the android environment, so I have: the recommended ADT (modified eclipse), NDK, and cygwin. Honestly I do not really know what NDK and cygwin is for. I have never played with linux either. Is there an informative page for how they work? All the pages I found are how-to-set-up-environment.
I think I set up the environment just ok, because I built a default helloworld project and ran it on the ADK emulator. However, I find no way to convert the win32 project I have to an android project.
I also found that in the folder of my project there is a .bat file called create-android-project.bat. And I followed some instructions from online to set up the three parameters for this batch file: the package path, project name, and target id. However the batch failed with errors like "No such file or folder...". I tested with other win32 projects I have. Ended up with similar errors.
Interestingly, if I ran this batch in the original cocos2dx project (the one with samples, templates, and built multi-platform projects), the batch ran just fine.
I really don't know what to do now. Can any one give me a solid guide page on this? Thanks a lot!
You need the classes and resources folder in the project created. Once done, you need to add all the CPP files and the includes folder in Android.mk file and build it using a script available build_native.sh
For cocos2dx v3, you need to run cocos compile -p android from within the project's directory. You need to make sure to have your JAVA_HOME path set correctly in your environment variables.
I can't say for sure that it mattered, but I had run proj.android/build_native.py as admin through cmd.exe before hand.
I have successfully converted my Cocos2d-x 2.1.5 project to Android project with the reference with this link. And I conclude some problems I met in my Blogger. I also found an official tutorial
To conclude:
Setup Java Build Path
Setup Builder Settings, I didn't use cygwin but using ndk_build
Setup NDK_MODULE_PATH
Copy the Resources
Modify Android.mk
Related
I do not use any Android features of Qt, my only purpose is to program some little softwares for Windows with minGW and QMake, no other project configurations is relevant for my needs. I'm simply curious if I missed a part, it does not affect the fonctionnality.
Project ERROR: You need to set the ANDROID_NDK_ROOT environment variable
to point to your Android NDK
And a bunch of other errors like that. Its my 4th clean install of 4 different version of Qt bundle, (now I carefully unselect everything except minGW32 and it still showing up!) God's sake why?
Did I missed a part on How to use Qt? Do I need extra-steps to remove it manually on a project creation?
If you want to code for Windows: just setting up your project with default setting (without Android/IOS setting).
If you want to code for Android: The problem was that the file wasn't the correct NDK file. Make sure you get the correct NDK from the website. Other than that it is pretty easy just unzip it and that directory is the root directory.
So if I understand, I can't remove "Android options" from Qt as it is pre-installed for all platforms.
Then yes, even if I don't use it, I must install Android NDK. Then continue to unselect the kit. Then these Error messages will disapear.
Recently I've been learning how to use TensorFlow, and wanted to set up the Android demos on my computer to see how they worked. I followed the instructions provided here, with the only differences being that I installed the Android SDK through Android Studio, and installed the Android NDK through the SDK Manager. Up until $ bazel build //tensorflow/examples/android:tensorflow_demo, everything worked fine, but after that, I got this error from the terminal:
ERROR: no such package '#androidndk//': Could not read RELEASE.TXT in Android NDK: /home/me/.cache/bazel/_bazel_me/f3471be34d1e62bf21975aa777cedaa3/external/androidndk/ndk/RELEASE.TXT (No such file or directory).
ERROR: no such package '#androidndk//': Could not read RELEASE.TXT in Android NDK: /home/me/.cache/bazel/_bazel_me/f3471be34d1e62bf21975aa777cedaa3/external/androidndk/ndk/RELEASE.TXT (No such file or directory).
From looking around at similar issues, my understanding is that this error is because the RELEASE.TXT file isn't included in the most recent version of Android NDK. This issue suggested downgrading to a previous version of NDK which contains a RELEASE.TXT file, and provided links to download such versions. However, the link that I followed (https://dl.google.com/android/ndk/android-ndk-r10e-linux-x86_64.bin) downloaded a .bin file, which is unusable to me. That post also suggested commenting out the NDK entry in the WORKSPACE file, but I haven't tried that yet, since I don't know if it will cause further complications down the road.
Another approach that I've tried is going to the path indicated by the error log (/home/me/.cache/bazel/_bazel_me/f3471be34d1e62bf21975aa777cedaa3/external/androidndk/ndk) and creating a blank RELEASE.TXT file, which made no difference. (I wasn't able to create one in the NDK that I installed, since it was in the form of a .jar file at the path /home/me/android-studio/android-studio/plugins/android-ndk/lib, thus the only way I could see was this path.)
As it stands, I'm at a dead end. Is there another way to resolve this issue without downgrading or commenting out the NDK entry? If not, how can I install a previous version of Android NDK?
I also posted this as issue #3175 in the official GitHub repository for TensorFlow, and it's been resolved. A play-by-play of the steps I followed to solve the problem can be found in that thread. It's a bit convoluted, so the steps I believe will solve an issue like this are as follows:
If you didn't use the --recursive option when git cloning the TensorFlow repository, re-clone it using that.
Downgrade to Android NDK r11c (and make sure to update the WORKSPACE file accordingly). A link for the Linux version can be found in the GitHub thread.
Check the version of your Android SDK and build tools. If they differ from the default versions written in the WORKSPACE file, make sure to change that.
You may run into a TensorFlow issue that is, as of yet, unresolved. (#3374) If so, run ./configure as a workaround.
And that should allow the Bazel build to proceed successfully.
Have you looked at using an alternative way to compile TensorFlow for Android without using Bazel? It's described in TensorFlow Makefile
Just starting with Phonegap and having some trouble understanding the directory structure and setup (on Windows).
I have been able to install and setup phonegap, jdk, android sdk, ant, etc. Using the command line I can now create a new project, edit the source files in www , build it and run it on my phone, Android Emulator and even Genymotion .
But the one thing that I just can not seem to understand is how I could edit and run the Phonegap project from within Intellij IDEA. All examples and how-tos I can find use the older Phonegap 2.9 structure, which is quite different from 3.0.
I enabled and configured all plugins, etc. I then try to import the existing project folder as a new project in IDEA, but it says "Source files for your project not found".
But when I build the project first with phonegap build android using the CLI, and then try to import it in IDEA, source files are found and I can continue the import of the project. But the Project Structure then seems to point to source files in platforms/android (platforms/android itself and also platforms/android/gen and platforms/android/src , I have no idea what to choose, so I choose all). I then click Next a couple of times until the Android project is created. After changing Project Language Level to 5 (no idea what this means) , I can now run the project from within IDEA.
But... changes that I make in www (in the root) don't end up in the compiled project!
So do I have to copy all files manually to platforms/android/assets then ? (the command line phonegap builder did not require this). Or do I have to edit the files in platforms/android/assets/www directly ? (which seems odd, since I would like to be able to only maintain the same code for all different platforms).
What do I need to do to achieve this in IDEA?
Somehow I think some things in Project Structure are wrong, but I have no idea what all this means (Modules, Libraries, Facets....).
Where should the manifest file be located, and the resources, and assets and libs?!
Could anyone point me in the right direction?
After phonegap create & build , there is a whole Android project located in %my_project_root%\platform\android
if you don't have the Android SDK at left, use the green icon to add one.
That's all
We don't need to modify manually the code under %my_project_root%/platforms/* but only under the %my_project_root%/www/* and %my_project_root%/merges/*
After running
phonegap build android
it automatically replaces platform specified code.
I found solution for me the next way:
After importing source code to IDEA, I added new web module which points to the %my_project_root% to be able to see all needed directories.
Also I created new IDEA command line tool with alias phonegap and tool path /usr/local/share/npm/bin/phonegap.
So before running default android running configuration I run phonegap build android just directly from IDEA (I think it's more convenient) and then run usual android run command to deploy the app to emulator or real device.
I hope this stuff will help you.
Hello there is one question which comes in my mind from last 2 days. Can we compile our android project without Eclipse? If yes then what is alternatives? Please share it.
one option is ant, and an extremely reduced tutorial goes like this:
first update your project with a proper build script and all the files that ant needs, you can do that with just one command, for example
android update project -p . -t android-10
this command has many options, feel free to browse for those options.
after that just do
ant debug
or
ant release
depending on what you want to produce, again, ant has other variations and you can easily discover them with the Android docs.
If you are developing in a non-Eclipse environment, you can build your
project with the generated build.xml Ant file that is in the project
directory. The Ant file calls targets that automatically call the
build tools for you.
Look at Here for more details.
cd /path/to/my/app
ant release
it will ask you every time for your private key to sign the app, it can be configured to auto-sign by editing "build.properties" file:
key.store=release.keystore
key.alias=release
key.store.password=my_key_password
key.alias.password=my_key_password
you can also investigate Android SDK, find the ANT build scripts it actually uses, and insert your custom obfuscator/optimizer call in middle of build process.
For people that are not used to coding in java and want to use HTML/JavaScript and CSS to build native apps for android -- you can use PhoneGap -- you can upload your code in a zip and get an APK. Currently its in beta, and thats why free.
https://build.phonegap.com/
Other Phone OSes are also supported. Its pretty interesting.
You can use maven with the maven android plugin http://code.google.com/p/maven-android-plugin/. Afterwards you can use any IDE that supports maven (NetBeans, Eclipse, IntelliJ IDEA).
If you just do not want to use Eclipse IDE you can choose other IDE like IntelliJ IDEA.
I've been running the Android SDK for a while now in Eclipse (MAC OSX). I've downloaded the NDK and installed the C/C++ tools in Eclipse, but could anyone guide me on using the NDK? For example, do I just create an Android project like normal and build it with the NDK instead?
Really could do with a decent tutorial if anyone know of any.
EDIT: OK so I have the NDK installed now (I think) but does anyone have any idea how to use it? I got as far as this (taken from here):
Run Terminal
cd ~/android-ndk-1.5_r1
make APP=hello-jni
In order to run the hello-jni sample application, but I get an error in terminal saying:
Android NDK: APP variable defined to
unknown applications: hellojni
Android NDK: You might want to use
one of the following:
build/core/main.mk:81: *** Android
NDK: Aborting . Stop.
Any ideas why?
As simply as I can describe it, building an Android app from within Eclipse that uses the NDK requires two steps.
First, inside your terminal you need to run the NDK build script on your project. cd into the root of your project directory and then execute the ndk-build script within that directory.
For example:
cd ~/workspace/hello-jni
./~/android-ndk-1.5_r1/ndk-build
After doing this, you should see some output that results in the creation of a *.SO file within the obj directory within your project directory.
Once you have the *.SO file, the final step to building an application with the Android NDK through Eclipse is to build it with Eclipse like you would any other application and then deploy it for testing.
If you make any changes to the C/C++ code you'll need to repeat step one and regenerate your *.SO file before building and deploying your application from within Eclipse again.
I would like to note that by using the Android NDK your android apps are still based upon Java. They're just communicating with code written in C/C++ by way of the Java Native Interface.
Finally, I am not aware of any Eclipse plugins that will aid with NDK development. Everything I know about the NDK I have learned the official Android NDK documentation. Please feel free to comment and let me know if there anything I can clear up in my response.
Native development and debugging support came into Eclipse environment as of ADT version 20. http://tools.android.com/recent/usingthendkplugin
Set path to NDK from Eclipse Preferences -> Android -> NDK
Right-click on your project and choose Android Tools -> Add Native Support
developer.android.com states you also need Cygwin.
http://developer.android.com/tools/sdk/ndk/index.html#Contents
Required development tools
For all development platforms, GNU Make 3.81 or later is required. Earlier versions of GNU Make might work but have not been tested.
A recent version of awk (either GNU Awk or Nawk) is also required.
For Windows, Cygwin 1.7 or higher is required. The NDK will not work with Cygwin 1.5 installations.
The docs directory in the NDK has some pretty good information on how to use the NDK itself. Read the overview, Application.mk, and Android.mk HTML docs. You'll want to google for the Sun JNI PDF, download it, and learn what JNI is all about before you go any further. This is because simply compiling a bunch of C/C++ code into libraries with the NDK is only part of the process. You have to write native Java code that calls your C/C++, and you have to create wrapper functions in C/C++ that adhere to JNI conventions that the native Java code can invoke. JNI has been around a long time, it's not Android specific by any means. So, you can, to learn about it, go quite far following tutorials geared towards JNI, using command line tools like javah and javac, and then return to integrating with the NDK after you know the basics. (For an example of what these C shims look like, take a look at the hello-jni sample in the NDK; the C source file there shows you typically what the shims look like. Using javah to generate these shims is the way to go, you create Java classes that have native methods, process them with javah, and it generates the C headers for you, then you code up C functions that adhere to the generated function prototypes).
Note: while the NDK docs would have you manually building from command line and then going into Eclipse to build your app (a laborious sequence of steps, to be sure, especially if you are changing the C/C++ code), it turns out you can integrate easily with Eclipse so that the NDK is run each time you build from Eclipse. To see how, read here.
This is for benefit of others who want to create the project from scratch from within eclipse: I followed steps mentioned here in this blog here and it works fine: http://mhandroid.wordpress.com/2011/01/23/using-eclipse-for-android-cc-development/
To attempt to answer the question directly - you need to run ndk-build in the folder with the native code within your project folder. This creates the .so files found in the file explorer/resources tree under jni in Eclipse. These functions, if the syntax in the code is correct, can now be called from your java code.
I found many sources of help when install and getting to grips with Android Developer Tools and the NDK. I wrote a blog post to share my experiences and hopefully give back to the community that helped me get there which may help understand my answer: http://workingmatt.blogspot.co.uk/2013/03/set-up-android-sdk-and-ndk.html