How to run and debug a C++ Android program in Eclipse - android

Thanks to cmake-android-chain, I can build a C++ program successfully. By using adb commands, I can also make the program run in Android devices:
adb push c_plus_plus_program /data/local/tmp/c_plus_plus_program
adb shell chmod -777 /data/local/tmp/c_plus_plus_program
adb shell ./data/local/tmp/c_plus_plus_program
Now I want to debug this program in Eclipse. With cmake, I can create a project for Eclipse, and I have also succeeded in building the project. However, the problem is I do not know how to run the program insider Eclipse, hence debugging the program. Any ideas? Thanks.

Related

Android Studio run app/test directly if nothing is changed

If nothing is changed since last compile and run, and then I hit run again (green start button), it complies and then run.
How can I make it run directly without compiling the same thing?
I might be wrong, I don't think but it's possible when you pass by Android Studio, but by using the build apk and install it with Android Debug Bridge (ADB), you should get the desired behaviour.
When the project compiles, AS creates an output apk. Usually, this should be named app-debug.apk and located in build/outputs/apk/ folder:
Your .apk file (signed with either a release or debug key) is in your module build/ directory after you build your application.
cf. Running on emulator
By using adb, you'll be able to install this apk previously generated (and I believe, without compiling again) on the device with the command install:
$ adb install -r path/to/app-debug.apk
Once installed, you should retrive the command to launch your application. A little research bring me to "How to start an Android application from the command line?":
$ adb shell
$ adb am start -n my.package.name/my.package.name.MyActivity
And then, you could combined them on same line to launch the apk just right after its installation. This looks like:
$ adb install -r path/to/app-debug.apk && adb shell am start -n my.package.name/my.package.name.MyActivity
Therefore, you application will run without compiling.
First try right click on the project and then select Run As Android Application. This will change you app default run configuration.
If this does't work then try to change it's run configuration from right click on project in project explorer and select Run as -> Run configurations.
Always run your project if you have opened that projects java class tab in workplace. You cannot run your project directly by clicking Green play button if you opened a XML file of that project. However you can run a project if you have opened manifesto of that project.

How to run an app when it does not show under Apps?

I used ant to build my Eclipse project from the command line in a debug configuration. (Eclipse Luna and Android NDK-R10d is broken, so I can't use Eclipse any longer. Confer, Eclipse/ADT plugin cannot locate symbols for r10d NDK).
I then performed an install using adb:
<Project Directory>$ adb install bin/AndroidPrng-debug.apk
When I rummage for the program on the device in Apps, the program is not offered. When I attempt to search for it by name on the device (AndroidPrng and com.example.prng), I'm provided with useless web search results. When I go to Settings → Apps, the app is shown under the Downloaded tab (it shows the name as com.example.prng). It has the familiar Force Stop and Uninstall.
I have DDMS running and waiting to capture LogCat output from the program. But even though the app is on the device, I cannot figure out how to run it.
How do I run and debug the app when it does not show up under Apps?
Assuming that your app do have an Activity from where you can navigate into other parts of your app.
Try using below command:
$ adb shell am start -n com.example.yourpackagename/.YourMainActivity
or $ adb shell am start -n com.package.yourpackagename/com.example.yourpackagename.YourMainActivity
This am start command, is a command-line interface to the ActivityManager.

Run my projet to android device In titanium Studio

I work with titanium studio version 3.0.3
When I run my project into Android device, I got the errors:
[ERROR] : Project failed to build after 287ms
It can not detect my device.
I installed the USB driver for sumsung and i configure Android device by Enable Unknown sources and Enable USB debugging.
In my eclipse IDE, I can detect my device and run my projects without probleme.
Can I give me some help, how can I deploying my projet to android device In titanium Studio
thanks :)
I use the following little script to launch the app on my device:
$SN variable defines the id of the device. You can get it by running adb devices
ti build -p android --build-only;
adb -s $SN uninstall com.example;
adb -s $SN install build/android/bin/applicationName.apk ;
adb -s $SN shell am start com.example/com.example.ActivityName
If you want to keep your application data in place, you should do the following:
adb -s $SN install build/android/bin/applicationName.apk ;
I'm assuming you have configured your PATH correctly.
Launch the script from your application folder.
You will have to change com.example and com.example.ActivityName to match your configuration.

Debugging Android native applications built with vs-android

I am using vs-android for building native C++ Android applications. I would like to debug from the command line by launching gdbserver on the emulator and connecting to that GDB server. Since I'm not using the Android build scripts I don't get the gdbserver delivered by default. So I added gdbserver to the lib folder from where vs-android collects it and pushes it into the APK. The file is now found on the emulator in the lib folder of the application where my SO is also located when I deploy the application with adb install.
I now try to run gdbserver with run-as but I get the error "Cannot attach to process 924: Operation not permitted (1)".
According to this http://ian-ni-lewis.blogspot.com/2011/05/ndk-debugging-without-root-access.html the server should be able to attach to the process when gdbserver is started with run-as.
Any ideas as to what I could still be doing wrong?
adb shell
su -c setenforce 0
it will solve the problem
To figure out if the problem is with run-as or with gdbserver, try using run-as to execute 'ps' instead of gdbserver, and then see if the 'ps' process is listed as having the same userid as the application's process. If not, you have a problem with run-as. If it is the same userid as the app, then the problem is more likely with gdbserver.

installing and running a script file on android emulator

To make use of ASL library for my screen shot app on android,i need to install a script file (run.ps1) and run it on emulator ... So can any one tell me how can i do it...should i do it using ADB or using Eclipse...?
A .ps1 file appears to be a PowerShell script. PowerShell is a Windows application. Android is not Windows. Hence, if it is indeed a PowerShell script, you cannot run that script on Android.

Categories

Resources