i used eclipse "run as an android application" option to updating .apk(with new .so file) to phone, but found .so file were still old. What happened when updating apk to android device? Can .so file be updated also?
You need to generate .so file again by build command of ndk .And then run your application again.It will then use new .so file. "run as an android application" makes new .apk of java as well as xml code but when you are dealing with c++ or c code the eclipse can't compile that code.
First you need to compile your native code by running ndk-build command.
Then you need to make a build.xml file using android update project.
Before running android update project, find ID of the target you want to use for your project.
Run android list targets and find the ID for your target.
Now run android update project --target your-target-id --name your-project-name --path /path/to/your/project. It will populate your project with build.xml and local.properties.
Related
I am attempting to add a main expansion file to my Cordova Android project. Before I can go further, I need to link up two libraries with the project. I am stuck on the following instructions in http://developer.android.com/google/play/expansion-files.html#AboutLibraries:
from a command line, update your project to include the libraries:
Change directories to the /tools/ directory.
Execute android update project with the --library option to add both
the LVL and the Downloader Library to your project. For example:
android update project --path ~/Android/MyApp \
--library ~/android_sdk/extras/google/market_licensing \
--library ~/android_sdk/extras/google/market_apk_expansion/downloader_library
I formatted the first part to match my system (my best understanding of what to do):
android update project --path ~/Documents/AndroidApps/apkext --library ~/Developer/android-sdk-mac_x86/extras/google/market_licensing
I got this error message:
Error: /Users/Steve/Documents/AndroidApps/apkext is not a valid project (AndroidManifest.xml not found).
I don't know how to go further. This being a Cordova app, the AndroidManifest.xml file resides in apkext/platforms/android/ and the apk build for the project is in apkext/platforms/android/ant-build
I have already successfully downloaded the two libraries asked for and they are in the tools/ folder in the path indicated. Am I applying the instructions wrong?
I think you're following instructions intended for a native android application and your project is a multiplatform cordova app.
Either you only want to focus on the android platform and don't want to use cordova CLI anymore (so you'll have to install plugins manually or using plugman) or you want to use the CLI and continue with the cordova project.
In the first case, just focus on the paltforms/adroid part of the project and forget all the rest.
paltforms/adroid contains the android native app.
So for example use
android update project --path ~/Documents/AndroidApps/apkext/platforms/android --library ~/Developer/android-sdk-mac_x86/extras/google/market_licensing
should work better.
In the other case, if you want to keep using the cordova cli, you should build a cordova plugin that would be composed of your libraries, a java class and javascript to call the native code from your cordova app. In that case you just have to configure the plugin to put the libraries in the libs folder.
Anyway, even if you're only interested in android, I think you will have to make a plugin if you want to do something with your libraries?
I've been trying to write a simple android app using NDK in Eclipse IDE.
Added NDK plug in
Added jni folder in the project and written a Cpp code
Built it properly using ndk-build
so file(s) are also generated
Compilation was successful and error-free. Yet, I'm unable to run it as an Android App as the apk file hasn't been generated.
Kindly help :)
I know that Ant is a build tool. We write script (steps while releasing android project) to build an android project and create a signed apk. Thats is one of the uses of Ant. But I want a method/script to create a new project in Android and I also want to build it so that an apk file can be created through that method/script. Is it possible through Ant?i.e. Ant script create a new project with a package name and activity name provided in the script, build it and create an apk file ready to be loaded in the emulator or device.Is there any solution(method/script) to the above mentioned problem?
yes you can do this through ant via a command line call to 'android create project' which will in turn generate all the ant scripts.
I've a project in the IntelliJ IDEA IDE and I want to set up a parallel, production Ant build process that I can extend over time.
I have used IntelliJ's feature to create an Ant build file, and it is on the Build menu, so the Ant build process is running, and working within the IDE. All good.
But the Ant script IntelliJ has created is only compiling to class files, and is not doing a full Android build process through to an APK (as far as I can tell).
Can you point me towards a reference source (or an example) to help me understand how to get an ANT script doing a full build of an Android project?
If you know, would also be v useful to know how to then extend it to include Proguard, production signing, and inserting the production Maps key :)
Use this as a starting point:
http://developer.android.com/guide/developing/other-ide.html
I don't know IntelliJ but I shoudn't be very hard to create an ant file with the most frequent commands you need.
UPDATE:
run the following command:
android create project --target 8 --name "MyFirstProject" --path /path/to/project --activity StartingActivity --package net.sample.package
This will create a project structure. This includes a build.xml file that contains targets to build the project.
To build the application, in the root folder (/path/to/project/) run:
ant debug
It should compile your application.
You may have to install or configure ant before this works correctly but you should be able to figure it out by yourself! :)
(All the info is in the link I posted earlier)
It's pretty well described in SDK documentation. Just 3 steps to make it work:
Assuming you have been developing your activity for a while with such powerful thing as IntelliJ Idea. So as Ollie mentioned in comment you don't have to create android project from scratch. Run in command line:
android update project --path "Path to your project" --target "android-X"
where X is API level
After step one build.xml was created automatically. Now you open IntelliJ, go to ant build panel and add that build.xml.
The important step is to open properties of created task and add debug OR release to command line at execution tab.
Now you can run target and enjoy the result. It will take some more efforts to compile into signed release.
Note: your existing project structure should match to android project. Please review documentation. E.g. I had external library put in "lib" subfolder and I managed it to work only after renaming "lib" to "libs"
I am new to Android and using Android 2.3 .
There is sample Browser plugin in the source code I am trying to build
it but unable to do so.
To compile plugin [ In README.txt ]
run "make SampleBrowserPlugin" (compiles libsampleplugin.so and
builds the apk)
the previous command produces an apk file so record its location.
Using the above steps I am unable to build it.
I have tried the following things :-
I thought to build the code in JNI folder first so as to get the
plugin ".so" so that after getting the ".so" would build the project
apk using the eclipse .
I tried building the code in the JNI folder using NDK build.The code
was not geting build it was giving "undefined reference to
JNIRegisterNativeMethod in JNIHelp.h "
Can anyone tell me how to build the Sample plugin and install it
on Emulator.
You need to "make SampleBrowserPlugin" from the root of your source installation (on a Linux machine). That is, the same directory that contains "bionic", "build", "dalvik", etc. as child directories.