How to build CM system app without odex? - android

When I build CM7 's system app (eg. ADWLauncher) , I switch to ADWLauncher's folder and run "mm" command, then I get .apk and .odex file, How can I just get .apk file with dex in it. I mean should I change somewhere in Android.mk or generic.mk to let the compilation just result apk file which can instsall directly.

Try this mm WITH_DEXPREOPT=false -B

You can use backsmali which can combine odex and apk files
baksmali -a [api_level] -x [odex_file] -d [framework_dir]
Or change the WITH_DEXPREOPT environment variable in
build/target/board/generic/BoardConfig.mk

This usually happens (at least to me) when I have not declared a device I'm building for with breakfast. For example, without running breakfast hammerhead, I got Dialer.apk and arm/Dialer.odex in the output directory. Furthermore, the device refused to run the binary, even after putting the .odex file in place.
Running breakfast first causes make to generate a single proper Dialer.apk that installs cleanly (using adb root/remount/push) on my device.

Related

How to rename multiple files with adb?

I want to rename all files in my /sdcard/Android/data/com.miui.gallery/files/gallery_disk_cache/small_size folder to shorter names.
Each file is 65 characters long and i would like that to be as short as possible, there are +- 9000 files in my folder. The file names contain both letters and numbers.
I have acces to adb debugging with my windows pc and USB-Debugging is turned on
I however cant acces my phone, it is stuck in a bootloop and turns off after 20 seconds, touch is only usable to enter my passcode so that i can acces the above named directory.
I have pulled 5GB so far, but cmd is limited to 8000 characters and it would take ages to pull everything without renaming files first
This is certainly possible with tasker, though I cannot give you the "complete recipe". Basically, you could create a task like this:
Execute Command: ls -1 /path/to/your/files, and capture the output into a variable
the command will list all files in the given directory, one file per line
Work on the variable. There are possibilities to convert it into an array, so you can use a for loop to handle each file
again with variables, you can setup the rename command (e.g. using Variable Search Replace) in a new variable. Pseudo-Code: mv "$old_name" "$(s/ /_/,$old_name)"
But it is much easier to use a simple shell script in some terminal app (or via adb shell) to achieve the same:
cd /path/to/your/files
for file in $(ls -1); do mv "$file" "$(echo $file|sed 's/ /_/g')"; done

Android source framework modify rebuild but become effective in emulator

i modify /framework/base/services/core/java/com/android/server/am/ActivityManagerService.java some logcat output string.
and i try to use different ways to rebuild it:
make -jN from top folder or
mmm /framework/base -jN or
mmm /framework/base/services -jN
and then i get a new output file in /out/target/product/generic_x86/system/framework/x86/services.odex
and then i update system.img by make snod
then i try to restart emulator, or adb remount adb sync, or kill system_server process
but sadly, no matter what kinds of methods i use, the emulator always output the original string.(so angry)
i even extract the new output system.img to get the new services.odex file, and use oat2dex.jar to decompile it to java code, and i indeed see the string has changed in it.
so why when i run the emulator, it won't become effective...
The system image file used by the emulator is system-qemu.img.
For some reason that file isn't made by make snod, which only makes system.img. I think what is needed is an additional target so you could say make qsnod or something, but there doesn't seem to be one. I don't know how anyone can work like this.
I don't understand the Makefile structure well enough at this point to figure out how to add a qsnod target, but here's a way to hand-roll
system-qemu.img.
Notice that the very last step that make -nN reports is:
[100% 255/255] Create system-qemu.img
To find out what command it ran there, you can say make showcommands -jN. I did this, and found it was the following, on my Macbook Pro:
[100% 255/255] /bin/bash -c "(export SGDISK=out/host/darwin-x86/bin/sgdisk; device/generic/goldfish/tools/mk_qemu_image.sh out/target/product/generic_x86_64/system.img)"
So that's the command for making system-qemu.img from input system.img (which is what make snod makes).
So, my recipe for rebuilding system.img on my machine, after changing a .java file under framework/base, is:
mmm frameworks/base -jN
make snod -jN
SGDISK=out/host/darwin-x86/bin/sgdisk device/generic/goldfish/tools/mk_qemu_image.sh out/target/product/generic_x86_64/system.img
Then when I restart the emulator, I see that my change has taken effect.

One command for multiple deployments

I'd like to know if some of you worked out how to generate signed APKs and IPA with multiple configurations (ie : beta for hockeyapp, and production for stores) in a single command.
I'm exploring all the possibilities there, it looks like there are lots of ways to do this.
I'd also like to be able to pass a variable like ENVIRONMENT to set Javascript constants such as an API url or turn on/off debugs.
Here's what I'm thinking right now :
Using https://www.npmjs.com/package/react-native-config to solve the former problem.
On android :
I'm thinking about adding a type in buildTypes in gradle. So far, I couldn't get it to work, I'm not very experienced with native configurations.
I would then make a bash script to create the offline bundle with the chosen env (staging / dev / prod) and use gradle's assembleRelease / assembleBeta. Do you think that's doable ?
On iOS, it looks a bit more complicated :
It looks like it's hard to change the project's configuration in CLI when building. So I was thinking that I should duplicate the project for each environement : project-dev.xcodeproj, project-prod.xcodeproj... you got the point.
Once again, I would make the bundle, then cp it inside the given project. A nice touch would be to trigger the xcode compilation in CLI too, I don't know if this is hard to set up.
What do you think about this ? Maybe some of you are already using custom scripts to do that ?
The icing on the cake would be to use HockeyApp's 'puck' cli tool to upload it, but that should be quite easy to set up once the application has been build for both iOS and Android.
This is the process I use for command line build with parameters. My system builds a release version .ips file and then copies and resigns that file with a development provisioning profile that I can put on my development devices to test exactly what is being sent to the customer or to the app store. Not all of this will be useful to you, but hopefully some will.
First, I have a variables file that sets the global parameters that I'm going to use for the build:
Scheme="(The scheme I am going to build inside my project)"
WindowsSavePath="(path to my source archive directory on a shared computer)"
InstallSavePath="(path to my .ipa archive directory on a shared computer"
Customer="(relative path inside archive directories)"
Fleet="(Continued relative path)"
PathToProject="(path to the folder on my Mac with the xcode project file)"
ProjectName="(project name).xcodeproj"
PlistPath="$Scheme-Info.plist"
appScheme="$Scheme"
AppName="(The name that I want to give my .ipa file)"
Version="(The version number for this build)"
AppendedFileName="-QA" //I use this for QA and Production distinction
exportPath="$InstallSavePath/$Fleet/$Customer/$Version$AppendedFileName/"
CompanyAppIdentifierPrefix="(my generic provisioning profile identifier)"
ArchiveLocation="$WindowsSavePath/$Fleet/$Customer/$Version$AppendedFileName"
SourceCodeDestination="(my compiled absolute path to the archive directories)"
This is all contained in a SetVariables.sh file. Now we get to start building the project. In another .sh file first I call the SetVariables file, then I start compilation:
#Update the version number in the plist file for the project
/usr/libexec/PListBuddy -c "Set :CFBundleShortVersionString $Version" "$PathToProject/$PlistPath"
/usr/libexec/PListBuddy -c "Set :CFBundleVersion $BuildVersion" "$PathToProject/$PlistPath"
#Now build and archive the project, the create the .ipa file for either submittal or giving to customers
mkdir -p "$exportPath"
mkdir -p "${ArchiveLocation}/dSYM"
xcodebuild -project "$PathToProject/$ProjectName" -scheme "$Scheme" DSTROOT="$exportPath" DEBUG_INFORMATION_FORMAT="dwarf-with-dsym" DWARF_DSYM_FOLDER_PATH="${ArchiveLocation}/dSYM" archive -archivePath "$exportPath${appScheme} $Version$AppendedFileName.xcarchive"
/usr/bin/xcrun -sdk iphoneos PackageApplication -v "${exportPath}Applications/${AppName}.app" -o "${exportPath}${appScheme} $Version$AppendedFileName.ipa"
#Now resign and create an internal dev version to test on development ipads
rm -r Payload SwiftSupport
unzip -q "${exportPath}${appScheme} $Version$AppendedFileName.ipa"
BUNDLE_ID=$(/usr/libexec/PlistBuddy -c "Print :CFBundleIdentifier" "Payload/${AppName}.app/Info.plist")
. ./CreateInternalEntitlements.sh "$CompanyAppIdentifierPrefix.$BUNDLE_ID"
. ./resign.sh "${exportPath}${appScheme} $Version$AppendedFileName.ipa" "${exportPath}${appScheme} ${Version}${AppendedFileName} Internal" internalDev.mobileprovision "(My developer account tied to the internal provisioning profile" Entitlements.plist
rm -r Payload SwiftSupport
#Now delete the intermediate files from the installs directory
rm -rf "$exportPath${appScheme} $Version$AppendedFileName.xcarchive"
rm -rf "${exportPath}Applications"
I have left out a few things in there (resign.sh, createentitlements.sh), but those processes I found on stackoverflow, so it shouldn't be too hard for you to find as well.
I've never done it, but I'm relatively certain that you can change the command line arguments for the xcodebuild to build either release or debug like you are trying to do. You could also run the xcodebuild twice, once for debug and once for release, and save the builds to different locations.
I hope this helps you at least a little with your goals. This took my a week or two to put all together and get working for my needs. Good luck.

Where to I place the OBB file to test Android Expansion Pack Files (OBB) on my Nexus 4?

I'm trying to test the Expansion Pack Files (OBB) In Android following the guide here:
http://developer.android.com/google/play/expansion-files.html
I'm in the step where I need to test my app on my Nexus 4.
I generated my .obb file with jobb and adb-pushed it in the device in this location:
/mnt/shell/emulated/0/Android/obb/my.package/main.1.my.package.obb
When the app run it doesn't find the file.
Method:
Helpers.doesFileExist(context, fileName, xf.mFileSize, false)
return false for my file.
I debugged and found out it is looking for the file in:
/storage/emulated/0/Android/obb/my.package/main.1.my.package.obb
Specifically this is the path returned by:
Helpers.generateSaveFileName(c, fileName)
The /storage/emulated/0, returned by Environment.getExternalStorageDirectory() doesn't exist browsing the device with adb shell.
But it DOES at runtime, inside the app, I also checked what it contains: it contains almost the same things I found in /mnt/shell/emulated/0, it contains the Android/obb dir, which is empty.
How I found out the path /mnt/shell/emulated/0/Android/obb/my.package/main.1.my.package.obb where I placed my obb file:
$ adb shell
$ ls -ld sdcard
lrwxrwxrwx root root 2013-10-16 17:34 sdcard -> /storage/emulated/legacy
$ ls -ld /storage/emulated/legacy
lrwxrwxrwx root root 2013-10-16 17:34 legacy -> /mnt/shell/emulated/0
And inside that I already found the Android/obb directory, empty.
So the question is: where should I put my obb file for it to be in the right position at runtime?
I did everything said there:
created a draft application in the Market to get the public key
generated a random array of 20 byte (salt)
integrated play_licensing/library and play_apk_expansion/download_library
wrote my Service / Receiver
did the check using the Helpers etc.. exactly like the documentation say.
I suppose everything works but I can't just yet release on Play Store! I need to test locally and I'll have the need to change my obb file pretty often in this initial phase of development.
I can't test on the Emulator because I use 3D and device camera.
Since Android 4.2 multi users support have been added.
To support that Android mount an emulated disk for each users acting as a sandbox layer around the actual filesystem: this let Android handle gracefully either sharing of files between users either personal files.
Long story short:
/storage/emulated
is the emulated filesystem.
if you enter that directory from adb shell you may see a
/storage/emulated/obb
directory. Sometimes it doesn't show up, for some reason (see below for what to do if this happen)
It's not in /Android/obb but that's the right directory where to place your app package / obb file!
If you don't see that directory try looking in:
/mnt/shell/emulated/obb
You should be able to put your file there.
It will be correctly picked up at runtime ending at the
/storage/emulated/0/Android/obb/my.package/main.1.my.package.obb
path.
I think the Android documentation should explain this.
(I answer my own question because I found out how to solve it while writing it.)
For me the correct location is : mnt/sdcard/Android/obb/nameofyourpackage/
NOT "/mnt/shell"

How can I copy the contentsof data/ to sdcard/ without using adb?

Hi I need to copy/move the contents of data/tombstones to sdcard/tombstones
I'm using the command below:
mv data/tombstones /sdcard/tombstones
"failed on 'tombstones' - Cross-device link"
but I'm getting above error.
You have a SANE VERSION of the mv command
paraphrasing a few bits from lbcoder from xda and darkxuser from androidforums
"failed on 'tombstones' - Cross-device link"
It means that you can't create a hard link on one device (filesystem) that refers to a file on a different filesystem.
This is an age-old unix thing. You can NOT move a file across a filesystem using most implementations of mv. mv is not made to copy data from device to device, it simply changes a file's location within a partition. Since /data and /sdcard are different partitions, it's failing.
Consider yourself fortunate that you have a SANE VERSION of the mv command that doesn't try anyway -- some old versions will actually TRY to do this, which will result in a hard link that points to NOTHING, and the original data being INACCESSIBLE.
The mv command does NOT MOVE THE DATA!!! It moves the HARDLINK TO
THE DATA.
If you want to move the file to a different filesystem, you need to use the "cp" command. Copy the file to create a SECOND COPY of it on a different filesystem, and then DELETE the OLD one with the "rm" command.
A simple move command:
#!/bin/bash
dd if="$1" of="$2"
rm -f "$1"
You will note that the "cp" command returns true or false depending on the successful completion of the copy, therefore the original will only be removed IF the file copied successfully.
OR
#!/bin/bash
cat data/tombstones > sdcard/tombstones
rm data/tombstones
These script can be copied into some place referenced by the PATH variable and set executable.
Different Interface
If you need a different interface from adb you may move files using the FileExplorer in DDMS View.
Side note:
You can move a file into a folder when:
You're root;
It is your app directory;
You've used chmod from adb or elsewhere to change permissions
Basically you don't have permission to access /data/tombstones in a production version .
It seems we have to 'root' the device first.
But I failed to root my Samsung S4 which is using Android 4.3

Categories

Resources