Android Wrap Shell Script Doesn't Work as Expected - android

I have a C library to be integrated with my project, but upon working, I got a stack corruption error. I decided that a malloc debug might help in my case, but can't seemed to configure it properly.
I have tried to follow this tutorial : https://developer.android.com/ndk/guides/wrap-script
I wrote my wrap script, which just contains the following line (I don't even add the malloc debug options yet) :
#!/system/bin/sh
exec "$#"
I put the script on the default resources/lib/{arch} folder and verified that it is indeed got packaged correctly into the apk in the lib folder.
But upon launching the app, it seemed to stuck, and just displayed an empty white screen (I have verified the app working properly without the wrapping shell script, at least until the stack corruption occurred).
I have noticed that the logcat print the following lines :
2019-05-24 16:35:00.524 1927-1942/? W/ActivityManager: Launch timeout has expired, giving up wake lock!
2019-05-24 16:35:00.680 1927-1942/? W/ActivityManager: Process ProcessRecord{e1f6d50 6975:my.package.name/u0a85} failed to attach
2019-05-24 16:35:00.681 1927-1942/? I/ActivityManager: Killing 6975:my.package.name/u0a85 (adj -10000): start time
I had tried using non rooted android 8.1 device, Android Pie, even with Pixel on Android Q, but the result is the same. I tried to move to emulator, but no avail, it fails with the same result. I had tried using both NDK 17c and NDK 19, both produced the same result. I'm working on windows, if that might relevant.
Any help is appreciated.

After trying various alternative, turns out the problem happened because of the different EOL format between windows (my workstation) and linux (the android device). After converting my wrap.sh file EOL fromat from Windows (CR LF) to Unix EOL format (LF), I managed to get it running.

Related

Why adb sync leads to boot failure while make snod works fine?

I am trying to build a custom rom in AOSP angler-debug (Nexus6p, 8.0).
Full build works fine.Then I change some code in
framework/base/core/java/..
and run
mmma framework/base
to rebuild the framework.
Here is the problem :
When I use adb sync to update framework, it leads to boot failure:
"didn't find class "com.android.providers.settings.SettingsProvider on path: ...."
"No original dex files found for dex location /system/priv-app/SettingsProvider/SettingsProvider.apk"
When I use make snod and fastboot flashall to flash system image, the device can boot correctly and the modified code effects.
Question :
Is there something different between these two commands?
There are some mechanisms in framework to make sure the framework.jar is the original one when device is flashed. It seems that other parts of framework does not have this limitation.
In my experience, if your change codes other than framework/base, adb sync is fine, otherwise flash system image to avoid weird things.
You should feel lucky that building speed is way faster in AOSP 8, when I worked with AOSP 5, build the framework/base is a disaster.

How do I run an Android app I've written in Red?

When I enter this in the Windows CMD...
red -c -t Android hello.red
...Red outputs a file called hello with no filename extension. If I transfer this file to my Android device, it doesn't know what to do with it.
What additional steps must I follow to test my Red code on my Android device?
Which of those steps, if any, must I do differently, depending on whether or not my code will attempt to use the Android bridge?
The Android port is a work in progress done in the android branch. In that branch, using:
red -t Android <script.red>
will use the APK backend for the new packaging layer that will handle the whole process of APK generation for you (provided that you have a JDK1.6+ pre-installed). If all went well, you will get an APK in your working folder.
In case you need to debug the building process, you need to edit the system/formats/APK.r file and set on line 11 the verbose word to yes.
Note: We are working on removing all the external dependencies one by one.
EDIT: The Android Red port has been moved to a private branch and actively worked on. It will be made public once beta stage is reached.
Unless you package up the executable into an .APK, then for security reasons Android throws up some walls in your path to chmod +x it and run.
I followed these directions, just with:
$ cd /data/data/jackpal.androidterm/shared_prefs
$ cat /sdcard/Download/hello.bin > hello
$ chmod 755 ./hello
$ ./hello
Without rooting or otherwise, you wind up with that weirdness like using cat instead of cp, and slipping the file into a strange directory where execution is allowed.
Tested on Nexus 5.
I've not tried yet, but check this: http://www.red-lang.org/2011/12/arm-support-released.html
Also you may know, that there is an experimental Android version here: https://github.com/red/red/tree/android
It appears the question has been answered, but for those who want more, there is an article for getting started with Red for Linux and Android in the March 2014 issue of ODROID Magazine at http://magazine.odroid.com .
There is also going to be a short how-to article in the July 2014 edition (released in the next few days) by Gregory Pecheret that will demonstrate building an .apk from scratch in Red.

Sl4A crashes on every script

There was time, when SL4A worked fine on my ICS phone (rooted, ofk). Than a factory reset happend; after it everything works just fine, except problem with SL4A.
I install SL4A; it can run shell scripts.
Than I install Python for Android or Perl for Android. I can run Python or Perl scripts. Nice.
Then I reboot. After reboot any attempt to do anything with SL4A (run script or start private server(any port)) results in
Unfortunately, SL4A has stopped.
Then it crashes second time, even if I have not launched it again manually.
Forever. (Till another clean install).
It occurs with all versions of SL4A and Python apk.
Here is full log(careful: 5k+ lines of text), and here is piece of log, filtered to warnings.
You can see, that first error, that looks relevant, in all cases is
E/sl4a.SimpleServer:156(2564): Failed to start server.
I have no idea what happens.
This is not quite programming question, so would have asked it at android.stackexchange, but it looks that they don't even have special tag for sl4a, so I posted it here.
Thanks in advance.
Go to apps in settings and Force Stop + clear the data. This usually fixes it for me. Seems to be a bug somewhere.
I did have problems with my andriod version.
Installing both SL4A and python from here fixed this.
More details on the original post, over here:
https://groups.google.com/forum/#!topic/android-scripting/tOovx2HprQk

5 Minute Builds for Titanium Android Application Installer

Can't seem to find a solution here, running Lion and at one point early last week my builds were taking the usual time (less than a minute). All of the sudden my builds are taking over five minutes every time I run the application installer (I do not recall changing any configurations).
It seems to be compiling all code completely, I'm not sure exactly what it's doing, but I assume there's something fundamentally wrong with my environment.
Initially used brew to install my android-sdk/uninstalled those and installed through Titanium.
I'm using Titianium Mobile SDK 1.76 (out of necessity) with a Samsung Galaxy.
Let me know if I need to post the whole stack trace while building (really long so I'll throw a few items on here)
[TRACE] Writing out AndroidManifest.xml
[DEBUG] /usr/local/android_sdk/platform-tools/aapt package -m -J
/trunk/build/android/gen -M
/trunk/build/android/AndroidManifest.xml -S
/trunk/build/android/res -I
/usr/local/android_sdk/platforms/android-7/android.jar
[INFO] Compiling Android Resources... This could take some time
[DEBUG] creating unsigned apk: /trunk/build/android/bin/app-unsigned.apk
[DEBUG] from resource zip => assets/Resources/data/Auburn.txt <- This line for almost all resources
[DEBUG] from JAR /Library/Application
Support/Titanium/mobilesdk/osx/1.7.6.v20120320183239/android/titanium.jar => org/apache/Commons-NOTICE.txt
These are a few of the lines that I'm noticing that didn't seem to be around when things were running as they should.
Any pointers would be appreciated.
EDIT:
Did a clean install with Mountain Lion's release, and this issue has resolved. There was obviously something fundamentally wrong with my environment, but if anyone knows what may have happened, please still throw it out there.
Yeah I have also this problem, but, it is solve when I Undo my tiapp.xml file. and Uninstall my app from Android Emulator and also delete Build file from Project File Directory and then run this is running Properly....
Cheers..
If you edit tiapp.xml, the entire app needs to recompile. You probably aren't touching the file that much, so it shoudn't say "Tiapp.xml change, recompiling..hold tight" or whatever it says in the build console.
Are you running on a phone or the emulator? If you're debugging and not using breakpoints, selecting 'run' instead of 'debug' will build it faster. Also, you technically shouldn't have to relaunch the run configuration each time; the whole point of that fastdev server thing is so that you can hit home (on the emulator) and relaunch the app without clicking 'run' from studio.

IOException everytime I try to upload anything to android emulator

I'm using Windows 7 Ultimate 64 bit edition and Eclipse 3.5 with the Android plugin. Every time I create a new project and try to publish it, I get an error like this:
[2010-02-15 22:48:10 - EPG3]Uploading EPG3.apk onto device 'emulator-5554'
[2010-02-15 22:48:15 - EPG3]Failed to upload EPG3.apk on device 'emulator-5554'
[2010-02-15 22:48:15 - EPG3]java.io.IOException: Unable to upload file: timeout
[2010-02-15 22:48:15 - EPG3]Launch canceled!
The emulator is working perfectly, adb can see it, I can even logcat from it, but it can't push or pull anything from it. Nothing appears in logcat to suggest the emulator even received any command. It doesn't matter if I have the Firewall on or off, or if I try invoking adb install to bypass the plugin. Nothing works even with a blank app.
Any ideas?
Not sure if this helps but I had the same exception when I tried uploading a project to the device and fixed it by increasing the value of "adb connection time out (ms)"
PC: (eclipse -> window -> settings -> android -> ddms)
MAC: (eclipse -> preferences -> android -> ddms)
I was pretty pissed at myself that it took me so long to find the setting so I thought I'd share.
I just ran into this error. To resolve it, I deleted my .apk file and built the project again. Voila! Upload works now.
Isnt this a problem with resources loading? Tried all the hello examples without problems, now the first with drawables and now I/O problem as you had.
I think its the reason that in the example they speak of a drawable folder, but in my default project structur there are 3 drawable folders.
Keep on debugging ;)
I got this error about every 30-40 compilations. I don't how, but this solution work for me.
Go to bin/ folder and rename your EPG3-debug.apk file to EPG3.apk (if you are using debug mode) or EPG3-release.apk to EPG3.apk (in Run mode), return to Eclipse, now you can Debug/Run your application. This should "unchoke" this whole situation, so you can make changes in your code and next time Debug/Run program normally (until you get this error once again, then you must repeat this tip).
See this question — Windows 7 and Android don't seem to get on so well initially it seems: Failed to parse the output of 'adb version'?
Are you able to telnet to localhost 5037? That's where the adb server listens for incoming connections from adb clients.
Did you try to add the path of the tools directory to your system PATH as described here ?

Categories

Resources