I am having difficulty with building my native android application using NDK. There are no binders, certain headers missing, etc.
But I have earlier experience with building using Android source 2.3, where I used to built android first and then doing mmm /path/to/my/application/ -B would build my application, but that was a forked android version.
This time I want to do it for Android 4.4, but before downloading it, I want to know whether default android sources come with commands like mmm and lunch and whether I can build my native application using it.
Related
So , I created an Empty c++ Project In Visual Studio 2019 And Linked The Libraries Non-Staticly
(That Means I Just The Placed The dll's in The Qutput Directory) And Then Closed VIsual Studio And Switched To VSCode And Now I Build The Project Using Devloper Cmd(Of Visual Studio Of Course) and MSBuild I Use SFML To Make The Project And Now Want To Port It Over To Android (Or IOS Or Both Anything Will Work)
Is There Any Way That This Can Happen ? Please Ask Me If You Want Any Other Information
You should install the Mobile Development with C++ package in the Visual Studio Installer. Create a new C++ project using the template Native-Activity Application (Android).
Trying to convert one project type to another is pointless and a waste of your time. However, your old source code can be included in the new project using the various right click actions.
I'm building a cross-platform Xamarin app and it has been working fine. However, I need to implement some logic in C++ and therefore created a shared Android/iOS project.
The C++ Android project targets the same Android API version as the app project.
If I reference the C++ project (to get the .so file in my Android app project) the app fails to start.
It seems to build fine, and I see Starting Android application ... in the Visual Studio output, but then it just seems to exit without any additional info. In other words, the app is deployed, but it isn't started and the debugger isn't attached.
If I remove the reference again, the app starts normally.
I'm targeting x86 with the C++ library, same architecture as the emulator.
The environment...
I have a brand new Visual Studio 2015 Android NDK Solution.
This contains 2 projects (the default template code that is generated by visual studio):
A native activity. This is where I want to put Android specific code. It has some default code which fades the screen colour between green and black.
A 'Packaging' project to help with deployment.
I have deployed this successfully to an Intel HAXM virtual device as well as to a real device connected via USB. All good so far.
I then added an Android dynamic library project (.so) - this is where I want to put core code (platform agnostic).
I added a reference to this Core library from the native activity project.
Everything compiles and links fine. I can still create an .APK file.
Other info:
Android SDK 5.1 (Android-22)
Android NDK 21
x86
Clang 3.8
C++ 11
Not using Make files or Gradle
The problem...
Now whenever I deploy to the virtual/real device I get the following error (taken from logcat)
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.NATester/android.app.NativeActivity}: java.lang.IllegalArgumentException: Unable to load native library: /data/app/com.NATester-2/lib/x86/libNATester.so
Things I have tried...
changing the Core library to static (.a)
checked the android device to see if the file exists - it does exist.
Manually deploying the .APK to the android device.
Some articles have suggested using Java code to load the libraries - I want to avoid calling Java code e.g. System.LoadLibrary as this seems like a hack - I feel that it should be possible to to have a pure C++ application on android. I can't be the only person to run into this issue?!
This looks relevant but old and again an unnecessary hack for what must be very common situation
- Can't load native shared library with dependencies in a native activity app
- https://github.com/ikonst/android-dl
For what its worth, I am a seasoned C# developer with Visual Studio (15 years).
I therefore take a lot of things for granted when developing apps - this is my first project using C++/Android and it seems more of a manual battle to get everything to work!
Been struggling for a while but managed to deploy the libraries, quite easy in the end.
Right click on the project [theProject (Andorid-xx)] in the Solution Explorer and select add new item, add your .so library.
Right click on the newly added library and select properties, item type should be library, set Content to Yes, this will deploy the lib.
I'm trying to run a Chrome App on Android Mobile using the instructions from:
developer.chrome.com/apps/chrome_apps_on_mobile
From above URL, I could run the calculator app fine in Android Emulator 5.0.1 fine. No issues.
github.com/GoogleChrome/chrome-app-samples/tree/master/samples/calculator
Chrome App Calculator on Android Screenshot
Then I tried running the "Native Client" App on Desktop from example api directory of nacl_sdk:
developer.chrome.com/native-client/sdk/download
nacl_sdk comes with few examples including demo and core api examples. All examples works fine on Desktop. Out of them I took 'file_io' api example which runs fine after compiling (make). I took that folder and used the following command to create cca cordova app:
cca create FileApp --copy-from=/path/to/file_io/manifest.json
Then cd to FileApp and cca prepare
After that ran Android eumlate command:
cca run android --target=avd5
It processed everything fine, and I see no errors building this cordova app like calculator app. But, after 'LAUNCH SUCCESS' when the app launched the Android emulator crashed. The emulator windows closed.
I started the Android Emulator from AVD Manager, and after booting up Android I tried starting the 'File I/O' app, which in result showed me the message
"Unfortunately, File I/O has stopped." Screenshot
Does that mean the PNaCl/NaCl apps still are not supported on Android OS?
The NaCl app contains the .pexe file.
Is there any step in between I could be missing?
I'd really appreciate any help in this regard to test if I could run Native Client Apps on Android OS just like the Chrome Mobile Apps using Apache Cordova examples work.
Native Client (NaCl) isn't supported in Chrome for Android (and by implication the Chrome/Chromium based WebView).
See: http://developer.chrome.com/multidevice/faq
Q: Does Native Client work on Chrome for Android?
A: It does not, and we have no plans to announce at this time.
But then the OP read at: https://github.com/MobileChromeApps/mobile-chrome-apps/blob/master/docs/faq.md#is-nacl--pnacl-supported
Q: Is NaCl/PNaCl supported [in Cordova]?
A: No. However, you can still compile and use native code
by writing a custom Cordova plugin.
And unfortunately the word native is an overloaded word with different meanings depending on context, so the OP started asking about the Android Native Development Kit (NDK).
The Android NDK which uses Java Native Interface (JNI) for C/C++ code to communicate with the Android Java framework. Typically Android apps only use the NDK if there is need to port existing C/C++ libraries or have a computational performance requirement like physics modeling or image processing.
When Cordova is referring to 'native code' its referring to code written in Android Java which would need to be bridged via a Cordova plugin to the JavaScript side.
And of course why to use any of the above frameworks/APIs depends on what the OP wants to do.
I'm working on a custom default android browser. I follow steps here AOSP to build my custom browser:
Clone android source code
Make changes on android browser
Build the Browser only for Nexus 4:
lunch full_mako-eng
make -j Browser
I rooted my Nexus 4 and install the Browser App. Everything is fine but I wonder if there is any other methods that simplier than above steps?
Can we just import the Browser into Eclipse or IntelliJ and build it directly to the phone?
At first, I want to point to some errors in your receipt.
Command make -jN builds all the sources of AOSP, where N is usually equal to "number of processor cores + 2". After the whole build of sources you can just build your browser application using command mmm packages/apps/Browser -jN snod
Browser application is a part of Android and thus, it is possible that it uses some system permissions that are not available for applications that are not installed on system image or not signed with system image. If it is not, then you can extract Browser application from AOSP, import it as a separate application into Eclipse and build it as a separate application (however, you will need to modify some resources).