[Q] Signing in debug mode - General Questions and Answers

I'm trying to use command line tools to develop an Android app. I'm calling aapt as follows:
"C:\Program Files (x86)\Android\android-sdk\platform-tools\aapt.exe" package -f --debug-mode -M C:\MyProjects\MyAndroidProject\AndroidManifest.xml -S C:\MyProjects\MyAndroidProject\res -I "C:\Program Files (x86)\Android\android-sdk\platforms\android-9\android.jar" -F C:\MyProjects\MyAndroidProject\bin\MyActivity-debug-unaligned.apk
I assume that, because I've specified --debug-mode, aapt will attach a debug certificate, making my app runnable on an emulator. But I keep getting the message
Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES]
How can I diagnose the problem?

Related

[Resolved] [Q] Setting Up ADB/USB Drivers for Android Devices in Ubuntu maverick 10.10?

OK so I tried these instruciton for Lucid on Maverick. I would post the link but I can't cuz I'm a newbie.
Download the latest Android SDK from Google: Android SDK
Extract the TGZ file to your home/user directory
NOTE: User would be your username
On your phone, click Settings > Applications > Development and make sure USB Debugging is on.
Login as root and create this file: /etc/udev/rules.d/##-android.rules
NOTE: In the above file replace ## with the number 50 if you are running Gusty/Hardy/Dapper (50-android.rules) or with the number 70 if you are running Karmic Koala/Lucid Lynx(70-android.rules)
Or simply type in terminal sudo gedit /etc/udev/rules.d/##-android.rules then enter your password
The file should read:
For Gusty/Hardy: SUBSYSTEM==”usb”, SYSFS{idVendor}==”0bb4″, MODE=”0666″
For Dapper: SUBSYSTEM==”usb_device”, SYSFS{idVendor}==”0bb4″, MODE=”0666″
For Karmic Koala: SUBSYSTEM==”usb”, SYSFS{idVendor}==”0bb4″, MODE=”0666″
For Lucid: SUBSYSTEM==”usb”, SYSFS{idVendor}==”0bb4″, MODE=”0666″
NOTE: In the above lines the code ”0bb4″ refers to a HTC device. If your phone is from a different manufacturer, replace the code with the appropriate from the table below.
Execute: sudo chmod a+rx /etc/udev/rules.d/70-android.rules
Reboot
To run ADB you need to add an environment variable to your bashrc file:
Open a terminal window and type: sudo gedit .bashrc
Add the following line at the end: export PATH=${PATH}:~/home/user/android-sdk-linux_86/tools
Save and close
You should be ready to go, type adb devices in a terminal window with your phone plugged in.
If you see a serial number pop up that means you are done. Should look something like this:
List of devices attached
HT99PHF02521 device
If for some reasons when running adb devices gives you a “no permissions” error, try typing the following in terminal
adb kill-server
adb start-server
USB Vendor IDs
MANUFACTURER USB VENDOR ID
Acer 0502
Dell 413c
Foxconn 0489
Garmin-Asus 091E
HTC 0bb4
Huawei 12d1
Kyocera 0482
LG 1004
Motorola 22b8
Nvidia 0955
Pantech 10A9
Samsung 04e8
Sharp 04dd
Sony Ericsson 0fce
ZTE 19D2
Common ADB Commands
- Lists which devices are currently attached to your computer
adb devices
- Drops you into a basic linux command shell on your phone with no parameters, or lets you run commands directly
adb shell
- Lets you install an Android application on your phone
adb install
- Remounts your system in write mode – this lets you alter system files on your phone using ADB
adb remount
- Rets you upload files to your phones filesystem
adb push
- Lets you download files off your phones filesystem
adb pull
- Starts dumping debugging information from your handset to the console – useful for debugging your apps
adb logcat
Now, as for the credits, I took TheUnlockr “How To” for Windows as a base for this guide.
Click to expand...
Click to collapse
But it doesn't work in maverick. Please help. Because I really want to overlock my phone.
Also keep in mind I'm fairly new to Linux so be easy on the newbie.
Thanks guys.
49 views and no responds? Please help I'm desperate here.
So did post this in the wrong section? This silent treatment is killing me. lol
in terminal type:
$ sudo -i
$ gedit .bashrc
insert the same line at the end: export PATH=${PATH}:~/home/user/android-sdk-linux_86/tools
$ exit
$ sudo -i
$ adb kill-server
$ adb start-server
$ adb devices
benholiio said:
in terminal type:
$ sudo -i
$ gedit .bashrc
insert the same line at the end: export PATH=${PATH}:~/home/user/android-sdk-linux_86/tools
$ exit
$ sudo -i
$ adb kill-server
$ adb start-server
$ adb devices
Click to expand...
Click to collapse
Dude this is for adb, not for recognizing the USB...
My phone is HTC Desire and I am still figuring out why it doesnt work on 10.10 with all the rules...
hungrysquid said:
Dude this is for adb, not for recognizing the USB...
My phone is HTC Desire and I am still figuring out why it doesnt work on 10.10 with all the rules...
Click to expand...
Click to collapse
I'm assuming thisisspeedy got to the same stage i did: USB connects, i can access files through maverick, however adb won't detect the device to allow push/pull/shell.
simply elevating to root & editing the bash script on maverick solves the problem.
I have my Galaxy S connected to Maverick via USB, and i can run all ADB functions.
It should work for HTC using the correct code. If you have a problem with Ubuntu detecting your device on USB when you've set USB to mount on Android, PM me and I'll see if i can help.
Could someone post a link for the Lucid dirs? Thanks.
Sent from my T-Mobile G2 using XDA App
Thanks for everyone responses.
I figured it out thanks to this.
[QUOTEThe Android Debug Bridge (adb) is a tool lets you manage the state of an emulator instance or Android-powered device.
I was trying to run it for the first time on my ubuntu 9.10 box and I kept getting this error:
desktop:~/dev/Android/android-sdk-linux/tools$ adb
No command 'adb' found, did you mean:
Command 'cdb' from package 'tinycdb' (main)
Command 'gdb' from package 'gdb' (main)
Command 'aub' from package 'aub' (universe)
Command 'dab' from package 'bsdgames' (universe)
Command 'mdb' from package 'mono-debugger' (universe)
Command 'arb' from package 'arb' (multiverse)
Command 'tdb' from package 'tads2-dev' (multiverse)
Command 'pdb' from package 'python' (main)
Command 'jdb' from package 'openjdk-6-jdk' (main)
Command 'jdb' from package 'sun-java6-jdk' (multiverse)
Command 'ab' from package 'apache2-utils' (main)
adb: command not found
What was I doing wrong?
A quick google search shows me the error of my ways.. I haven't added my Android SDK tools directory to my system path!
It should go something like this...
open a terminal window and type:
$ echo $PATH
---(should return the directories associated with $PATH)
$ export PATH=$PATH:/home/YOUR-USERNAME/sdk/tools
---(replace with path to your tools directory, you may need to add 'sudo' to the beginning of this cmd)
$ echo $PATH
---(you should now see your tools directory added to the end of the $PATH variable)
$ adb devices
---(now adb should do something, if nothing else at least error, no devices)
And now I get:
List of devices attached
emulator-5554 device
Sweet Success!
p.s. Adding to the system path in Windows is along the lines of :
right-click '(My) Computer'
Select 'Properties'
Go to 'Advanced' or whatever tab you find 'Environment Variables'
Select 'Path' then 'Edit' and add your new path in.][/QUOTE]
adb trouble
Hi i am runing on Ubuntu Maverick with device Huawei U8110 on Celestial Teapot 4 ROM
java jdk ver6
installed Android SDK and tools in the home folder
i edit the rules file 99-android.rules to SUBSYSTEM=="usb", ATTRS{idVendor}=="12d1", SYMLINK+="android_adb", MODE="0666" GROUP="plugdev"
saved and added the file permisions
restart the udev
Connected the Phone put the debug mode on
kill the adb then started
And Then Run The comand
[email protected]:/home/android-sdk-linux_x86/platform-tools# ./adb devices
List of devices attached
There is nothing in the list....?
HELP!? Please......
I use it for Marveric.
vim /etc/udev/rules.d/70-android.rules
# IS01
SUBSYSTEM=="usb",ATTRS{idVendor}=="04dd",ATTRS{idProduct}=="04dd",MODE="0666",OWNER="root"
# GalaxyS
SUBSYSTEM=="usb",ATTRS{idVendor}=="04e8",ATTRS{idProduct}=="681c",MODE="0666",OWNER="root"
# bravo
SUBSYSTEM=="usb", ATTRS{idVendor}=="0bb4", MODE="0666"
add like a above. then
/etc/init.d/udev restart
Good luck!
thisisspeedy said:
I figured it out thanks to this.
[QUOTEThe Android Debug Bridge (adb) is a tool lets you manage the state of an emulator instance or Android-powered device.
I was trying to run it for the first time on my ubuntu 9.10 box and I kept getting this error:
desktop:~/dev/Android/android-sdk-linux/tools$ adb
No command 'adb' found, did you mean:
Command 'cdb' from package 'tinycdb' (main)
Command 'gdb' from package 'gdb' (main)
Command 'aub' from package 'aub' (universe)
Command 'dab' from package 'bsdgames' (universe)
Command 'mdb' from package 'mono-debugger' (universe)
Command 'arb' from package 'arb' (multiverse)
Command 'tdb' from package 'tads2-dev' (multiverse)
Command 'pdb' from package 'python' (main)
Command 'jdb' from package 'openjdk-6-jdk' (main)
Command 'jdb' from package 'sun-java6-jdk' (multiverse)
Command 'ab' from package 'apache2-utils' (main)
adb: command not found
What was I doing wrong?
A quick google search shows me the error of my ways.. I haven't added my Android SDK tools directory to my system path!
It should go something like this...
open a terminal window and type:
$ echo $PATH
---(should return the directories associated with $PATH)
$ export PATH=$PATH:/home/YOUR-USERNAME/sdk/tools
---(replace with path to your tools directory, you may need to add 'sudo' to the beginning of this cmd)
$ echo $PATH
---(you should now see your tools directory added to the end of the $PATH variable)
$ adb devices
---(now adb should do something, if nothing else at least error, no devices)
And now I get:
List of devices attached
emulator-5554 device
Sweet Success!
p.s. Adding to the system path in Windows is along the lines of :
right-click '(My) Computer'
Select 'Properties'
Go to 'Advanced' or whatever tab you find 'Environment Variables'
Select 'Path' then 'Edit' and add your new path in.]
Click to expand...
Click to collapse
============================================================
THANK YOU!! (I did hit 'THANKS' as well)...
You pointed me in the right direction with Ubuntu 10.04.
The only change was with SDK..the 'adb' has moved to $ ~/platform-tools/
By the way folks, when you install SDK, it would be wise to do all the updates, otherwise the platform-tools folder won't be an option....:cyclops:
"The order has been restored.."

[Q] Help using Android command line dev tools

I'm trying to deconstruct the Android app development process by creating and installing a sample app entirely from the command line (without even using Ant). I've composed a script which seems to work until the very last command, at which point I get the message
134 KB/s (10496 bytes in 0.076s)
pkg: /data/local/tmp/MyActivity-debug.apk
Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES]
Please don't be put off by the fact that my script is a Windows .bat script. I'm just calling code from the SDK's tools and platform-tools directories. Anyway, here's the script. If find what I'm missing that's giving me the NO_CERTIFICATES error, please reply...
call "c:\program files (x86)\Android\android-sdk\tools\android" create project --target 10 --name MyAndroidProject --path c:\MyProjects\MyAndroidProject --activity MyActivity --package com.allmycode.samples
cd \MyProjects\MyAndroidProject
mkdir C:\MyProjects\MyAndroidProject\res
mkdir C:\MyProjects\MyAndroidProject\libs
mkdir C:\MyProjects\MyAndroidProject\bin
mkdir C:\MyProjects\MyAndroidProject\gen
mkdir C:\MyProjects\MyAndroidProject\bin\classes
"C:\Program Files (x86)\Android\android-sdk\platform-tools\aapt.exe" package -f -m -M C:\MyProjects\MyAndroidProject\AndroidManifest.xml -S C:\MyProjects\MyAndroidProject\res -I "C:\Program Files (x86)\Android\android-sdk\platforms\android-9\android.jar" -J C:\MyProjects\MyAndroidProject\gen
"c:\program files\java\jdk1.7.0\bin\javac" -d C:\MyProjects\MyAndroidProject\bin\classes -classpath C:\MyProjects\MyAndroidProject\bin\classes;C:\MyProjects\MyAndroidProject;c:\ant\lib\ant-launcher.jar;"C:\Program Files (x86)\Java\jre6\lib\ext\QTJava.zip";C:\ant\lib\ant-antlr.jar;C:\ant\lib\ant-apache-bcel.jar;C:\ant\lib\ant-apache-bsf.jar;C:\ant\lib\ant-apache-log4j.jar;C:\ant\lib\ant-apache-oro.jar;C:\ant\lib\ant-apache-regexp.jar;C:\ant\lib\ant-apache-resolver.jar;C:\ant\lib\ant-apache-xalan2.jar;C:\ant\lib\ant-commons-logging.jar;C:\ant\lib\ant-commons-net.jar;C:\ant\lib\ant-jai.jar;C:\ant\lib\ant-javamail.jar;C:\ant\lib\ant-jdepend.jar;C:\ant\lib\ant-jmf.jar;C:\ant\lib\ant-jsch.jar;C:\ant\lib\ant-junit.jar;C:\ant\lib\ant-junit4.jar;C:\ant\lib\ant-netrexx.jar;C:\ant\lib\ant-swing.jar;C:\ant\lib\ant-testutil.jar;C:\ant\lib\ant.jar;"C:\Program Files\Java\jdk1.7.0\lib\tools.jar" -sourcepath C:\MyProjects\MyAndroidProject\src;C:\MyProjects\MyAndroidProject\gen -target 1.5 -bootclasspath "C:\Program Files (x86)\Android\android-sdk\platforms\android-9\android.jar" -encoding UTF-8 -g -source 1.5 c:\MyProjects\MyAndroidProject\src\com\allmycode\samples\*.java
call "C:\Program Files (x86)\Android\android-sdk\platform-tools\dx.bat" --dex --output=C:\MyProjects\MyAndroidProject\bin\classes.dex C:\MyProjects\MyAndroidProject\bin\classes
"C:\Program Files (x86)\Android\android-sdk\platform-tools\aapt.exe" package -f --debug-mode -M C:\MyProjects\MyAndroidProject\AndroidManifest.xml -S C:\MyProjects\MyAndroidProject\res -I "C:\Program Files (x86)\Android\android-sdk\platforms\android-9\android.jar" -F C:\MyProjects\MyAndroidProject\bin\MyActivity-debug-unaligned.apk
"C:\Program Files (x86)\Android\android-sdk\tools\zipalign.exe" -f 4 C:\MyProjects\MyAndroidProject\bin\MyActivity-debug-unaligned.apk C:\MyProjects\MyAndroidProject\bin\MyActivity-debug.apk
start "Launch an emulator" "C:\Program Files (x86)\Android\android-sdk/tools/emulator.exe" -avd Gingerbread
timeout /T 60
"C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe" install -r C:\MyProjects\MyAndroidProject\bin\MyActivity-debug.apk
You need to sign your apk
Hey, I believe all you need to do is sign your .apk with a certificate.
Here is a link about creating a certificate if you dont already have one. I tried to include a link but it wont let me. (sorry im a new user)
Once you have acquired a certificate, you can then use the JDK utitility called jarsigner. The terminal command should be something like this...
jarsigner -verbose -keystore my-release-key.keystore final.apk alias_name
Click to expand...
Click to collapse
Hope this helps ya out.

[APP][DEV][GUIDE] Using the Android Java Internal/Hidden API classes

Using Java Reflection with Eclipse ADT to Access Internal/Hidden API classes.
Purpose
We present a way to access all the Internal and Hidden Java packages/classes
in the AOS. To do this we need to both repackage the Android.jar and hack the
Eclipse ADT plugin, to allow using these internal packages.
Posting
==================================================
Do NOT post general questions/requests on how to
do this or that, they will not be answered here.
DO post if you have additional tricks, hacks or
information that can help/benefit this tutorial.
==================================================
Background
There are two reasons one cannot use internal packages. One reason is that, if
you're using Eclipse as your development platform, those packages are
internally blocked in the Eclipse ADT plugin. Second reason is that the normal
development android.jar runtime does not contain those *.class files that
belong to the internal packages.
"There is no easy way to use com.android.internal package (internal API) or
anything marked with @hide attribute (hidden API) without using reflection.
That’s because android.jar file does not contain classes from internal and
hidden API and because of this nobody can reference those classes in compile
time."
Thus we need to first restore the "original" android.jar which will allow us
to use internal and hidden APIs. But the runtime equivalent of Android SDK’s
android.jar file is framework.jar. This file is located in the
/system/framework/ directory of your device. We will extract and use this for
our pleasure.
The general procedure:
A) Grab the "full" framwork.jar from your device
B) extract the class files
C) add them to "full" android.jar ??
D) Hack the Eclipse ADT plugin jar.
Finally, NOTHING would have been possible without the excellent step-by-step
instructions on the devmaze-blog by senior Android developer Ievgenii Nazaruk
(aka. "inazaruk"). THANK YOU Ievgenii!​References
http://stackoverflow.com/questions/...d-sdk-with-hidden-and-internal-apis-available
http://stackoverflow.com/questions/...-state-permission-for-apps-ran-on-gingerbread
http://code.google.com/p/smali/wiki/DeodexInstructions
http://code.google.com/p/adt-addons/
​
The General Procedure
NOTE: All this was performed on Windows Vista with Cygwin.(1) Grab BOOTCLASSPATH from init.rc
Find the line in your init.rc file that reads something like:
Code:
[SIZE=2]export BOOTCLASSPATH /system/framework/core.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/core-junit.jar[/SIZE]
Extract and reformat the path to:
Code:
[SIZE=2]core.jar:bouncycastle.jar:ext.jar:framework.jar:android.policy.jar:services.jar:core-junit.jar[/SIZE]
(2) Grab the "framework" from your device
Create a working directory somewhere, let's call it "_framework":
Code:
[SIZE=2]mkdir ./_framework[/SIZE]
[SIZE=2]cd _framework[/SIZE]
Grab all the framework files from your device:
Code:
[SIZE=2]adb pull /system/framework .[/SIZE]
Rename directory if needed.
NOTE-1: From now on I'll assume you know where you are!
NOTE-2: Most GB 2.3.4+ devices uses .odex'ed files,
with name pairs like: <package>.jar and <package>.odex.
These need to be converted.
(3) Use baksmali with (1)
You can also use baksmali with the switch: -d <framwork-dir>.
The general command is something like below, but in windows there may be "wrappers"
that allow you to just type "baksmali" without the "java -jar" prefix and without
the ".jar" post fix. Anyway here is the command I used:
Code:
[SIZE=2]java -Xmx1024m -jar ./../../baksmali.jar -a 10 -c :core.jar:bouncycastle.jar:ext.jar:framework.jar:android.policy.jar:services.jar:core-junit.jar -x framework.odex[/SIZE]
==> This results in all files put in the "out" sub-directory.
This directory contain 3 sub-directories (for GB 2.3.4):
Code:
[I]android [/I](Hidden APIs)
[I]com [/I](Internal APIs)
[I]javax [/I](Hidden APIs)
NOTE: If you are using Google's own API's, you will probably also need to add
those packages to the path above. (Eg. Email.jar, etc etc ?)
(4) Then use smali to create a dex file from "out" directory
Code:
java -jar smali.jar out
==> creates out.dex from "out" directory.
(5) Run dex2jar on out.dex
Code:
[SIZE=2]./dex2jar.bat out.dex[/SIZE]
==> creates out_dex2jar.jar
(This .jar contain close to 4900 files at 12 MB!)
(6) Rename "out_dex2jar.jar" to "framework-classes.zip"
Code:
[SIZE=2]mv out_dex2jar.jar framework-classes.zip
unzip framework-classes.zip[/SIZE]
(7) Find and copy your Android SDK's android.jar file
Go to: /path/to/android-sdk-windows/platforms/android-X/android.jar
where X is the API level of interest. This obviously have to match the
API level of the files you extracted from your device in: /system/framework .
This .jar file contain more than 5300 files when expanded, but missing all
the internal packages. Our job is to add them back in.
Let's first make a copy that we can use to expand and add files from (6):
Code:
cp android.jar custom-android.zip
unzip custom-android.zip
(8) Add all *.class files from (6) in to (7)
Copy and replace all existing *.class files from framework-classes.zip into
custom-android.zip:
Code:
[SIZE=2]cp -R /path/to/framework-classes/* /path/to/custom-android/.[/SIZE]
The root content of that directory should then look something like this:
Code:
[SIZE=2]android[/SIZE]
[SIZE=2]assets[/SIZE]
[SIZE=2]com[/SIZE]
[SIZE=2]dalvik[/SIZE]
[SIZE=2]java[/SIZE]
[SIZE=2]javax[/SIZE]
[SIZE=2]junit[/SIZE]
[SIZE=2]META-INF[/SIZE]
[SIZE=2]org[/SIZE]
[SIZE=2]res[/SIZE]
[SIZE=2]AndroidManifest.xml[/SIZE]
[SIZE=2]resources.arsc[/SIZE]
(9) Rename directory and create your new "classy-android.jar"
We rename it so not confuse with the original:
Code:
mv custom-android classy-android
zip classy-android
mv classy-android.zip classy-android.jar
IMPORTANT:
Make absolutely sure that the folder structure of your zip archive
is exactly the same as what you intended. To check, unzip the file
and see if it is what you (and eventually Eclipse) would expect.
(For example, if you use 7zip to zip a directory file called "test",
into "test.zip", you may end-up extracting it to ./test/test/... )
(10) Enabling & Restricting Access to classy-android.jar
Instead of just replacing the android.jar with classy-android.jar, we choose
to create a customized Android platform. This way you can enable the Internal
and Hidden API's for those projects requiring them, while other standard
projects doesn't have access to those.
(a) Go to: /path/to/android-sdk-windows/platforms/
and copy the relevant directory (for example):
Code:
cp -R android-10 android-10-internals
(b) Replace android.jar with your classy-android.jar:
Code:
cp classy-android.jar android.jar
("cp" overwrites!)
(c) Edit the build.prop file:
Edit/replace the following lines:
Code:
[SIZE=2]ro.build.version.sdk=10 ==> ro.build.version.sdk=[COLOR=Black][B]-10[/B][/COLOR][/SIZE]
[SIZE=2]ro.build.version.release=2.3.3 ==> ro.build.version.release=2.3.internal[/SIZE]
(11) Customizing the Eclipse ADT
In order to be able to use com.android.internal packages in the Eclipse ADT,
you have to disable the internal protection mechanism of the plugin, that
prevent you to use these libraries. You can see this by right-clicking on your
project package and navigate to:
Code:
[SIZE=2]==> Properties ==> Java Build Path ==> Libraries (tab) [/SIZE]
[SIZE=2]--> Android 2.x.x --> android.jar [/SIZE]
[SIZE=2]--> "Access rules: 1 rule defined": [B][COLOR=Red](X)[/COLOR][/B] [B]Forbidden: com/android/internal/**[/B][/SIZE]
This can not be removed (bug?), even though the interface allows changing, it
never persists after closing the Properties window. So we have to hack it!
The way to do it, is to hexedit the correct java class file and change the
name from "internal" to "internax". First let's find the correct file. The
plugin file is located in the ./eclipse/plugins/ directory, and its name is
something like:
Code:
com.android.ide.eclipse.adt_18.0.0.v201203301601-306762.jar
(a) make a backup copy of this (with the exact name preserved) in another directory.
(b) make a another copy of this in another directory.
(c) unzip (b) in that directory
Code:
[SIZE=2]cp com.android.ide.eclipse.adt_18.0.0.v201203301601-306762.jar hacked_adt.zip[/SIZE]
[SIZE=2]unzip hacked_adt.zip[/SIZE]
[SIZE=2]cd hacked_adt[/SIZE]
This is a huge directory system, so forget poking around in it,
just go to the correct sub-directory:
Code:
[SIZE=2]cd ./com/android/ide/eclipse/adt/internal/project/[/SIZE]
Then find the correct file and the approximate string location within that file:
Code:
[SIZE=2]strings.exe -f -4 -t x ./*.class |grep "android\/internal"[/SIZE]
It happens to be in "AndroidClasspathContainerInitializer.class". Now, use a
hexeditor to find and change the string "com/android/internal/**"
to "com/android/internax/**". That will do it!
Now zip-up your hacked jar directory and copy it over the old one.
(Remember that "cp" overwrites without warning!)
Code:
[SIZE=2]zip hacked_adt[/SIZE]
[SIZE=2]cp hacked_adt.zip /path/to/eclipse/plugins/com.android.ide.eclipse.adt_18.0.0.v201203301601-306762.jar[/SIZE]
You Are Done!
Enjoy your newly hacked Eclipse! ​Errors
If you get any errors;
1. make sure you have zipped up everything properly as warned before.
2. make sure you have included Google API packages in your BOOTCLASSPATH in step (3).
3. Try to "clean-up" the Java by: "Right-Click" ==> Source ==> "Clean Up...".
4. Google them
5. Ignore them
6. Give up. Not! But I can't help you!
If it still doesn't work, try to download inazaruk's pre-compiled set of internal android.jar's from here.
(For android 7,8,10,15.)
​
WIP! <here be dragons2>
For a project using internal package imports, see my thread:
"[TOOL][APP][WIP] Native AT Command Injector"
<here be more dragons>
Following the instructions in posts 1-2 above, may not always work. It is not known to me at this time, why it shouldn't. One theory is that it can have something to do with how Eclipse and Android.jar is packaging their files and the resulting sizes.
This was mentioned in this Stackoverflow post:
"Jar files: why does extracting then compression a jar file create a file of a different size to the original?"
Then reading the man pages for "jar" we can inform ourselves with:
Code:
[SIZE=2] c Creates a new archive file named jarfile (if f is specified) or to
standard output (if f and jarfile are omitted). Add to it the
files and directories specified by inputfiles.
u Updates an existing file jarfile (when f is specified) by adding
to it files and directories specified by inputfiles.
x Extracts files and directories from jarfile (if f is specified) or
standard input (if f and jarfile are omitted). If inputfiles is
specified, only those specified files and directories are
extracted. Otherwise, all files and directories are extracted.
t Lists the table of contents from jarfile (if f is specified) or
standard input (if f and jarfile are omitted). If inputfiles is
specified, only those specified files and directories are listed.
Otherwise, all files and directories are listed.
i Generate index information for the specified jarfile and its
dependent jar files.
[/SIZE]
More info is provided here:
The JAR Overview @
http://java.sun.com/javase/6/docs/technotes/guides/jar/jarGuide.html
The JAR File Specification @
http://java.sun.com/javase/6/docs/technotes/guides/jar/jar.html
The JARIndex Spec @
http://java.sun.com/javase/6/docs/technotes/guides/jar/jar.html
JAR Tutorial @
http://java.sun.com/docs/books/tutorial/jar/
pack200 Reference Page @
http://java.sun.com/javase/6/docs/technotes/tools/share/pack200.html
Another theory is that it may have something to do with what seem to be, that Google have revoked the the use of MODIFY_PHONE_STATE since Android 2.3, and that this influences the Eclipse behavior, when using and modifying older android.jar's. This was mentioned here and here.
Any help would be very much appreciated!
< bump >
Hi, thanks for the info, I made it using linux and worked really nice, these were the lines that I used, hope be useful.
This is my Android folder at home
Code:
Android/
├── eclipse
├── ndk
├── platforms-internals
├── sdk
└── tools
Start an avd running the desired API to modify in this case API-17
Code:
$ emulator -avd avd_api_17 -no-window &
Get the framework
Code:
$ cd ~/Android/
$ mkdir _framework
$ cd _framework
$ adb -s emulator-5554 pull /system/framework .
Grab BOOTCLASSPATH
Code:
$ adb -s emulator-5554 shell cat init.rc | grep BOOTCLASSPATH > bootclasspath
I didn't have the tools used in this tutorial, so I included the steps for getting them
Decompile with baskmali
Code:
$ cd ~/Android/tools
$ wget https://smali.googlecode.com/files/baksmali-1.4.2.jar
$ cd ~/Android/_framework
$ java -Xmx1024m -jar ../tools/baksmali-1.4.2.jar -a 17 -c core.jar:core-junit.jar:bouncycastle.jar:ext.jar:framework.jar:telephony-common.jar:mms-common.jar:android.policy.jar:services.jar:apache-xml.jar -x framework.odex
The parameter -a for baksmali refers to the API we are working with.
Generate out.dex with smali
Code:
$ cd ~/Android/tools
$ wget https://smali.googlecode.com/files/smali-1.4.2.jar
$ cd ~/Android/_framework
$ java -jar ../tools/smali-1.4.2.jar out
Get internal and hidden classes using dex2jar
Code:
$ cd ~/Android
$ wget https://dex2jar.googlecode.com/files/dex2jar-0.0.9.15.zip
$ unzip dex2jar-0.0.9.15.zip
$ rm dex2jar-0.0.9.15.zip
$ cd _framework/
$ ../tools/dex2jar-0.0.9.15/d2j-dex2jar.sh out.dex
$ unzip out-dex2jar.jar -d framework-classes
Add these classes to plataform's default android.jar
Code:
$ cd ~/Android
$ unzip sdk/platforms/android-17/android.jar -d custom-android
$ cp -r _framework/framework-classes/* custom-android/
$ rm -r _framework
$ cd custom-android
$ zip -r ../custom-android.jar *
$ cd ..
$ rm -r custom-android
Create new extended platform
Code:
$ cd ~/Android
$ cp -r sdk/platforms/android-17 platforms-internals/android-17-internals
$ mv custom-android.jar platforms-internals/android-17-internals/android.jar
$ vi platforms-internals/android-17-internals/build.prop
ro.build.version.release=4.2.2
ro.build.version.release=4.2.2.internal
$ ln -s ~/Android/platforms-internals/android-17-internals ~/Android/sdk/platforms/android-17-internals
I use a symlink for keep it a little organized
Hack ADT
Code:
$ cd ~/Android
$ unzip eclipse/plugins/com.android.ide.eclipse.adt_22.0.4.v201307151829--741630.jar -d hacked_adt
Go to right folder
Code:
$ cd hacked_adt/com/android/ide/eclipse/adt/internal/project/
Find file where is our desired string
Code:
$ strings -f -a -t x * | grep "android\/internal"
Edit with an hex editor
Code:
$ bless AndroidClasspathContainerInitializer.class &
Here we change the l for the x.
Replace original file making a backup
Code:
$ cd ~/Android
$ cp eclipse/plugins/com.android.ide.eclipse.adt_22.0.4.v201307151829--741630.jar eclipse/plugins/com.android.ide.eclipse.adt_22.0.4.v201307151829--741630.jar.original
$ cd hacked_adt/
$ zip -r ../eclipse/plugins/com.android.ide.eclipse.adt_22.0.4.v201307151829--741630.jar *
$ cd ..
$ rm -r hacked_adt
This worked for me... thanks E:V:A
I got just one error related to a dropbox class, but i think this is not important... hope that
lenieto3 said:
...Start an avd running the desired API to modify in this case API-17... This worked for me... I got just one error related to a dropbox class, but i think this is not important...
Click to expand...
Click to collapse
Thanks and sorry for late reply. I'm very happy to hear these instructions still works with API-17! Could you also upload your hacked JAR somewhere so that people can save some time when experimenting?
I was just here to check-in and try to bump this thread to see if it is still useful to anyone.
E:V:A said:
Thanks and sorry for late reply. I'm very happy to hear these instructions still works with API-17! Could you also upload your hacked JAR somewhere so that people can save some time when experimenting?
I was just here to check-in and try to bump this thread to see if it is still useful to anyone.
Click to expand...
Click to collapse
ive got access to ActivityManager's hidden methods.
I want to use the removeTask method, but it keeps saying that I dont have the REMOVE_TASKS permissions even though I added it to the manifest (and turned off lint).
Permission Denial: removeTask() from pid=9963, uid=10179 requires android.permission.REMOVE_TASKS
Does someone know if there are any automated tools to do/performs steps 1-9?
I'd like to see a tool to automatically pull (from phone), extract and create a compatible android.jar.
@Mohammad_Adib: Sorry, this is the wrong thread for those type of questions.
see this link stackoverflow.com|questions|30656933|android-system-framework-jar-files

[GUIDE] SManager - How to use Commands

Hi,
I want to learn some of the commands for use in SManager (Script Manager) for ANDROID.
https://sites.google.com/site/devwom/script-manager
Does anyone know a suitable thread with guide or commands for SManager? I tried searching the web and XDA but did not find anything myself.
Specifically I want to know the cmd line to start an app.
EDIT 1:
Spent a good few hours trying to google a solution but drawn a blank.......Maybe Shell Scripts for Linux are not same as for Android...?
I would like to be able to run a script that does the following:
Checks if a directory exists on the sdcard
then executes a command (renaming of 2 directories)
then starts a program
EDIT 2:
well a few emails with the author of SManager and I was able to write my first script to check if the app is running and then if not, to rename folders and start the other version of the app. (I have Navigon Europe as well as Navigon Australia and was looking for a solution to allow both to co exist on my One-X at the same time. As both apps share the same directory structure the issue was that starting one version would overwrite the critical files of the other).
Now with my script installed as a widget I can toggle between each version without problem.
Here is some useful information on shell language for others (credits to the author of SManager Devwom):
http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html
Here are some critical bits of info received during my emails with him:
Thanks a lot for your interest in SManager.
The requested commands is a mix between linux commands and android os commands.
To get info about each command you can search in google and select the preferred page.
But the commands available in each Android device depends on running rom.
To get all available commands in your device, simply execute a ls (lower case LS) in system directories, that is:
ls /system/bin
ls /system/sbin
ls /system/xbin
ls /system/usr/bin
ls /system/usr/sbin
ls /system/usr/xbin
These are the most common directories where binaries resides in android devices.
May be you also can have commands at:
ls /bin
ls /sbin
ls /usr/bin
ls /usr/sbin
usually android rooted roms have the well known busybox, to get a list all comands inside it simply execute
busybox
to get all installed packages (and running names) from your device you can execute:
pm list packages
to get info about running process
ps
or
ps aux
or
ps -aux
depending on ps version installed
If conditions are based on test bash command this command is a bit confused, because usually it is named as [, and other times it is built-in inside shell
read "test man page" to get a full list of test command flags.
To check if an app is running:
if [ -n "$(ps|grep os.tools.scriptmanager)" ] ; then
echo SManager is running
fi
To check if app is NOT running:
if [ -z "$(ps|grep os.tools.scriptmanager)" ] ; then
echo SManager is NOT running
fi
To check if a file exist:
if [ -e /sdcard/file ] ; then
echo /sdcard/file exists
fi
To check if a file exist and it is a directory:
if [ -d /sdcard/file ] ; then
echo /sdcard/file exists and is directory
fi
To rename a directory simply use mv command:
I hope you can build your script with this info.
Start app it is very easy but getting correct info to start app is a bit confused.
starting app uses "am command"
To get correct info to start app you should execute:
logcat |grep Starting
in a terminal on device
then go to launcher and launch desired app
then go back to the terminal and you will see a line with info about how to fill am command.
For example if you execute SManager
in
logcat|grep Starting
output you will see
I/ActivityManager(* 275): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=os.tools.scriptmanager/.launcherActivity } from pid 377
so to start scriptmanager you need the following command
am start -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -n os.tools.scriptmanager/.launcherActivity
I do not know how to stop apps from command line, I usually use killall command:
killall os.tools.scriptmanager
if you do not have killall command you can use grep and awk or cut commands
kill "$(ps|grep os.tools.scriptmanager|grep -v grep|awk '{print $2;}')"
or
kill "$(ps|grep os.tools.scriptmanager|grep -v grep|cut -f5 -d" ")"
may you need adjust -f5 flag
To execute script as shortcut install SMWidgets.
Scripts usually ends with last line , ie, not special action is required, it will exit with the last executed command return code
Also you can add
exit 0
or preferred exit value, but 0 usually means OK
To end script in the middle use
exit value
where value usually it is not 0
Also it is better use mv command instead rename command.
rename command it is not linux standard, but mv command is in all linux shells.
Android shell programing it is not equals to linux shell programming but this was one of my first scripting documents many years ago and it can be used as a guide. http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html
Best regards,
Devwom
Thanks, this is valuable information! It's a shame this thread didn't get more replies
I've been looking to change my wallpaper by script, but so far I haven't been succesful. With your guide, I guess I'm a step closer to my goals!
Hi.
Perhaps developer of smanager or any expert is reading...
I would like to write a script for 2 purposes. Both handle with samba share running on my ubuntu.
1st situation.: I would like to move my media, download and documents files from android to the desired folder on my Ubuntu, which is shared by samba in my LAN.
The goal is to start this script with just touching a widget.
2nd situation: I would like to copy files from my samba shared folder in ubuntu to a specific folder on sdcard in android. All files in folder on sdcard should be deleted before copying. Again just by touching a widget.
Shared folder on samba are with password and rw.
Till now I am doing it manually with esexplorer...
I would like to do it with script.
Sent from my Incredible S using xda app-developers app

[SOLVED] [HELP] Can't install bsdiff4 and use .bin Payload Dumper

Yo hello, i installed a custom rom for my motorola one (deen), and i need to root it again with magisk. But the rom has a .bin file instead of normal boot.img stuff. So i got this Payload dumper, but it doesn't want to work. Everytime i try to install the dependencies it says
C:\Users\nego ney\Downloads\payload_dumper-master\payload_dumper-master>python3 -m pip install -r requirements.txt
Requirement already satisfied: protobuf==3.6.0 in c:\users\nego ney\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from -r requirements.txt (line 1)) (3.6.0)
Requirement already satisfied: six==1.11.0 in c:\users\nego ney\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from -r requirements.txt (line 2)) (1.11.0)
Collecting bsdiff4>=1.1.5
Using cached bsdiff4-1.2.1.tar.gz (11 kB)
Requirement already satisfied: setuptools in c:\program files\windowsapps\pythonsoftwarefoundation.python.3.9_3.9.1520.0_x64__qbz5n2kfra8p0\lib\site-packages (from protobuf==3.6.0->-r requirements.txt (line 1)) (56.0.0)
Using legacy 'setup.py install' for bsdiff4, since package 'wheel' is not installed.
Installing collected packages: bsdiff4
Running setup.py install for bsdiff4 ... error
ERROR: Command errored out with exit status 1:
command: 'C:\Users\nego ney\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\nego ney\\AppData\\Local\\Temp\\pip-install-mp5zoj50\\bsdiff4_b64f4fb7c8d44c99a8989c37191075a4\\setup.py'"'"'; __file__='"'"'C:\\Users\\nego ney\\AppData\\Local\\Temp\\pip-install-mp5zoj50\\bsdiff4_b64f4fb7c8d44c99a8989c37191075a4\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\nego ney\AppData\Local\Temp\pip-record-tk6s6_pk\install-record.txt' --single-version-externally-managed --user --prefix= --compile --install-headers 'C:\Users\nego ney\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Include\bsdiff4'
cwd: C:\Users\nego ney\AppData\Local\Temp\pip-install-mp5zoj50\bsdiff4_b64f4fb7c8d44c99a8989c37191075a4\
Complete output (19 lines):
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.9
creating build\lib.win-amd64-3.9\bsdiff4
copying bsdiff4\cli.py -> build\lib.win-amd64-3.9\bsdiff4
copying bsdiff4\format.py -> build\lib.win-amd64-3.9\bsdiff4
copying bsdiff4\test_all.py -> build\lib.win-amd64-3.9\bsdiff4
copying bsdiff4\__init__.py -> build\lib.win-amd64-3.9\bsdiff4
running build_ext
building 'bsdiff4.core' extension
creating build\temp.win-amd64-3.9
creating build\temp.win-amd64-3.9\Release
creating build\temp.win-amd64-3.9\Release\bsdiff4
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1520.0_x64__qbz5n2kfra8p0\include -IC:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1520.0_x64__qbz5n2kfra8p0\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\ATLMFC\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include -IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um /Tcbsdiff4/core.c /Fobuild\temp.win-amd64-3.9\Release\bsdiff4/core.obj
core.c
C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1520.0_x64__qbz5n2kfra8p0\include\pyconfig.h(59): fatal error C1083: Nao ‚ poss¡vel abrir arquivo incluir: 'io.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.29.30037\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\Users\nego ney\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\nego ney\\AppData\\Local\\Temp\\pip-install-mp5zoj50\\bsdiff4_b64f4fb7c8d44c99a8989c37191075a4\\setup.py'"'"'; __file__='"'"'C:\\Users\\nego ney\\AppData\\Local\\Temp\\pip-install-mp5zoj50\\bsdiff4_b64f4fb7c8d44c99a8989c37191075a4\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\nego ney\AppData\Local\Temp\pip-record-tk6s6_pk\install-record.txt' --single-version-externally-managed --user --prefix= --compile --install-headers 'C:\Users\nego ney\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Include\bsdiff4' Check the logs for full command output
"
"
And i could not find any tutorial solving that, please help me bois
help reeeeeee
please answer me i beg
bump
Solved, i used it on a vm running clean python + vs instalations, sorry for useless thread
iHatePayloadDumper said:
Solved, i used it on a vm running clean python + vs instalations, sorry for useless thread
Click to expand...
Click to collapse
hey, how did u solved that problem? im stuck here too
Larry112 said:
hey, how did u solved that problem? im stuck here too
Click to expand...
Click to collapse
Had the same issue. Downgrading protobuf to 3.19.3 fixed it for me

Categories

Resources