[TERMINAL] Android 5.0+ am force-stop error ! - Android Q&A, Help & Troubleshooting

Hi everyone !
When i write "am force-stop packagename" on terminal it gives this error. PLEASE HELP ME !

Try this:
ps | grep com.ps | grep nextapp.fx | awk '{print $2}' | xargs killpackage.name | awk '{print $2}' | xargs kill

Related

Two versions of the same app

Is it possible to install two versions of the same app without overwriting the previous one??
i have tried to decompile the app and change the app name in package field of manif
est.xml, i was successful in installing the apps but the one with unedited manifest.xml works whereas the other force closes
This is possible, but you will need to adjust the folders containing the smali files (after using apktool), as well as (not sure about this bit) changing the class declaration names in each smali file.
It's complex, but it is possible to do and you're on the right tracks with the package name
is there any automated tool to do all that?
keyboardcowboy said:
is there any automated tool to do all that?
Click to expand...
Click to collapse
Unlikely
10 char
I have seen Brut's modified Google maps, it can be installed beside original app...How did he do it?
keyboardcowboy said:
is there any automated tool to do all that?
Click to expand...
Click to collapse
Someone could make a script. I'll post my solution to give that person a head start.
Code:
apktool d -f base_MYAPP.apk base_MYAPP
mv base_MYAPP/smali/com/MYCOMPANY/MYAPP base_MYAPP/smali/com/MYCOMPANY/NEW_MYAPP
find base_MYAPP/smali/com/MYCOMPANY/NEW_MYAPP -name "*.smali" -print | xargs sed -i -e 's/MYAPP/NEW_MYAPP/g'
sed -i -e 's/MYAPP/NEW_MYAPP/g' base_MYAPP/AndroidManifest.xml
sed -i -e 's/APP NAME/APP NAME NEW/g' base_MYAPP/res/values/strings.xml
rm -f base_MYAPP/res/values/strings.xml-e base_MYAPP/AndroidManifest.xml-e
find base_MYAPP/smali/com/MYCOMPANY/NEW_MYAPP -name "*.smali-e" -print | xargs rm -f
apktool b base_MYAPP NEW_MYAPP-unaligned.apk
jarsigner -keystore my.keystore -storepass pass1 -keypass pass2 NEW_MYAPP-unaligned.apk alias
zipalign -f -v 4 NEW_MYAPP-unaligned.apk NEW_MYAPP.apk
Something like that. I need to go home. =)
awesome
Try something like this:
Code:
#!/bin/bash
##### Constants
APK_NAME="My App"
PACKAGE="My_App"
PACKAGE_PATH=com/my_company/
KEYSTORE="my.keystore"
KEYSTORE_PASS="keystore_pass"
ALIAS="alias_name"
ALIAS_PASS="alias_pass"
##### Functions
function copy_apk
{
# Parameters
base_file=$1
new_package=$2
new_apk_name=$3
input_dir=base/
file_modification_date=$(stat -f "%Sm" -t "%Y%m%d" $input_dir/$base_file)
file_modification_time=$(stat -f "%Sm" -t "%H%M%S" $input_dir/$base_file)
output_dir=$file_modification_date/
# Variables
file_name=$(echo "$base_file" | cut -d'.' -f1)
file_extension=$(echo "$base_file" | cut -d'.' -f2)
new_file_name_unaligned="${file_name}-unaligned.${file_extension}"
new_file_name_aligned="${file_name}_${file_modification_date}_${file_modification_time}.${file_extension}"
work_directory=$input_dir$file_name/
smali_directory=$work_directory/smali/$PACKAGE_PATH/
# Function Body
mkdir -p $input_dir
mkdir -p $output_dir
apktool d -f $input_dir$base_file $work_directory
mv $smali_directory/$PACKAGE $smali_directory/$new_package
find $smali_directory/ -name "*.smali" -print | xargs sed -i -e "s/$PACKAGE/$new_package/g"
find $smali_directory/ -name "*.smali-e" -print | xargs rm -f
find $work_directory/ -name "*.xml" -print | xargs sed -i -e "s/$PACKAGE/$new_package/g"
sed -i -e "s/$APK_NAME/$new_apk_name/g" $work_directory/res/values/strings.xml
find $work_directory/ -name "*.xml-e" -print | xargs rm -f
apktool b $work_directory $input_dir/$new_file_name_unaligned
jarsigner -keystore $KEYSTORE -storepass $KEYSTORE_PASS -keypass $ALIAS_PASS $input_dir/$new_file_name_unaligned $ALIAS
zipalign -f 4 "$input_dir/$new_file_name_unaligned" "$output_dir/$new_file_name_aligned"
}
function apk_version
{
# Parameters
base_file=$1
package_extension=$2
# Variables
new_package="${PACKAGE}_${package_extension}"
new_apk_name="${APK_NAME} $package_extension"
# Function Body
$(copy_apk "$base_file" "$new_package" "$new_apk_name")
}
##### Main
$(apk_version my_app_sandbox.apk Sandbox)
$(apk_version my_app_release.apk Release)
sgeos said:
Try something like this:
Code:
#!/bin/bash
##### Constants
APK_NAME="My App"
PACKAGE="My_App"
PACKAGE_PATH=com/my_company/
KEYSTORE="my.keystore"
KEYSTORE_PASS="keystore_pass"
ALIAS="alias_name"
ALIAS_PASS="alias_pass"
##### Functions
function copy_apk
{
# Parameters
base_file=$1
new_package=$2
new_apk_name=$3
input_dir=base/
file_modification_date=$(stat -f "%Sm" -t "%Y%m%d" $input_dir/$base_file)
file_modification_time=$(stat -f "%Sm" -t "%H%M%S" $input_dir/$base_file)
output_dir=$file_modification_date/
# Variables
file_name=$(echo "$base_file" | cut -d'.' -f1)
file_extension=$(echo "$base_file" | cut -d'.' -f2)
new_file_name_unaligned="${file_name}-unaligned.${file_extension}"
new_file_name_aligned="${file_name}_${file_modification_date}_${file_modification_time}.${file_extension}"
work_directory=$input_dir$file_name/
smali_directory=$work_directory/smali/$PACKAGE_PATH/
# Function Body
mkdir -p $input_dir
mkdir -p $output_dir
apktool d -f $input_dir$base_file $work_directory
mv $smali_directory/$PACKAGE $smali_directory/$new_package
find $smali_directory/ -name "*.smali" -print | xargs sed -i -e "s/$PACKAGE/$new_package/g"
find $smali_directory/ -name "*.smali-e" -print | xargs rm -f
find $work_directory/ -name "*.xml" -print | xargs sed -i -e "s/$PACKAGE/$new_package/g"
sed -i -e "s/$APK_NAME/$new_apk_name/g" $work_directory/res/values/strings.xml
find $work_directory/ -name "*.xml-e" -print | xargs rm -f
apktool b $work_directory $input_dir/$new_file_name_unaligned
jarsigner -keystore $KEYSTORE -storepass $KEYSTORE_PASS -keypass $ALIAS_PASS $input_dir/$new_file_name_unaligned $ALIAS
zipalign -f 4 "$input_dir/$new_file_name_unaligned" "$output_dir/$new_file_name_aligned"
}
function apk_version
{
# Parameters
base_file=$1
package_extension=$2
# Variables
new_package="${PACKAGE}_${package_extension}"
new_apk_name="${APK_NAME} $package_extension"
# Function Body
$(copy_apk "$base_file" "$new_package" "$new_apk_name")
}
##### Main
$(apk_version my_app_sandbox.apk Sandbox)
$(apk_version my_app_release.apk Release)
Click to expand...
Click to collapse
this is fun, but I am not sure how to runt he script on my phone.

[Q] How to flash boot.img in shell? (from phone's sdcard)

some kernel app can download and flash boot.img, restarts, how can I do that in terminal? (without the need of adb or Recovery... save hell lots of time)
I'm afraid thats impossible.
kurotsugi said:
I'm afraid thats impossible.
Click to expand...
Click to collapse
so this are dark magic?
Code:
#!/sbin/bb/busybox ash
# lkflash - flash latest leanKernel
#
# author - [email protected]
#
BB="/sbin/bb/busybox"
STABLE="http://imoseyon.host4droid.com/latest"
EXP180="http://imoseyon.host4droid.com/exp/latest180"
EXP230="http://imoseyon.host4droid.com/exp/latest230"
CUR=`$BB uname -a | $BB awk -F'-' '{ print \$3 }'`
while [ 1 ]; do
echo
echo "leanKernel flasher"
echo "------------------"
echo "1) latest stable (recommended)"
echo "2) latest experimental 180mhz-1.65ghz (notrim)"
echo "3) latest experimental 230mhz-1.65ghz (notrim)"
echo "4) check/display versions"
echo "9) latest stable franco (warning: no md5 check)"
echo
echo "FLASH AT YOUR OWN RISK. I'm not responsible for my mistakes or yours. ;)"
echo
echo -n "Please enter a number between 1 and 4 (or press enter to exit): "
read option
case $option in
1)
$BB wget -q -O /sdcard/lk $STABLE
echo; echo -n "Downloading stable "
break
;;
2)
$BB wget -q -O /sdcard/lk $EXP180
echo; echo -n "Downloading experimental 180mhz (notrim) "
break
;;
3)
$BB wget -q -O /sdcard/lk $EXP230
echo; echo -n "Downloading experimental 230mhz (notrim) "
break
;;
4)
echo "Please wait..."
vstable=`$BB wget -q -O - $STABLE | $BB awk '{ print \$3 }'`
v180=`$BB wget -q -O - $EXP180 | $BB awk '{ print \$3 }'`
v230=`$BB wget -q -O - $EXP230 | $BB awk '{ print \$3 }'`
echo; echo ">>> Current version: $CUR, Latest stable: $vstable, Exp: $v180 $v230"
sleep 2
;;
9)
$BB wget -q -O /sdcard/fboot.img http://minooch.com/franciscofranco/Galaxy%20Nexus/nightlies/appfiles/boot.img
$BB dd if=/sdcard/fboot.img of=/dev/block/platform/omap/omap_hsmmc.0/by-name/boot 2> /dev/null
echo "Latest Franco Kernel flashed. Reboot when you're ready."
exit
;;
*)
echo "BYE"
exit
;;
esac
done
[ ! -s "/sdcard/lk" ] && exit
MD5=`$BB awk '{ print \$2 }' /sdcard/lk`
VER=`$BB awk '{ print \$3 }' /sdcard/lk`
if [ "$CUR" == "$VER" ]; then
echo
echo "Aborted. You're already running $CUR."
exit
fi
echo "v$VER. Please wait..."
$BB wget -q -O /sdcard/lkboot.img `$BB awk '{ print \$1 }' /sdcard/lk`
[ ! -s "/sdcard/lkboot.img" ] && exit
SUM=`$BB md5sum /sdcard/lkboot.img | $BB awk '{ print \$1 }'`
echo
if [ "$MD5" == "$SUM" ]; then
echo "Download finished. Checksum verified. Flashing kernel to boot partition..."
$BB dd if=/sdcard/lkboot.img of=/dev/block/platform/omap/omap_hsmmc.0/by-name/boot 2> /dev/null
echo; echo "leanKernel $VER flashed! Reboot when you're ready to run new kernel."
else
echo "md5sum check failed - please try again."
fi

A little sysinfo script for CLI

EDIT: I've updated the script with a bit more info.
All you need is the additional package "bc".
Code:
#!/bin/bash
cpuUsageM=$(top -bn 1 | awk '{print $9}' | tail -n +8 | awk '{s+=$1} END {print s}')
cpuFreqM=$(echo "scale=0; " `cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq` "/1000" | bc)
cpuTempM=$(echo "scale=1; " `cat /sys/class/thermal/thermal_zone0/temp` "/1000" | bc)
gpuTempM=$(/opt/vc/bin/vcgencmd measure_temp)
gpuTempM=${gpuTempM//\'C/}
gpuTempM=${gpuTempM//temp\=/}
memTotalM=$(cat /proc/meminfo | grep MemTotal | awk '{print $2}')
memTotal1=$memTotalM
memTotalM=$(echo "scale=1; $memTotal1 / 1024" | bc)
memUsageM=$(cat /proc/meminfo | grep MemFree | awk '{print $2}')
memUsageM=$(echo "scale=1; ($memTotal1 - $memUsageM) / 1024" | bc | sed 's/^\./0./')
memUsageP=$(echo "scale=1; (100/$memTotalM) * $memUsageM" | bc | sed 's/^\./0./')
rootTotalM=$(df -m / | grep / | awk '{print $2}')
rootTotalM=$(echo "scale=1; $rootTotalM / 1024" | bc)
rootUsageM=$(df -m / | grep / | awk '{print $3}')
rootUsageM=$(echo "scale=1; $rootUsageM / 1024" | bc | sed 's/^\./0./')
rootUsageP=$(echo "scale=1; (100/$rootTotalM) * $rootUsageM" | bc | sed 's/^\./0./')
echo "CPU Usage: $cpuUsageM%"
echo "CPU Freq: "$cpuFreqM"MHz"
echo "CPU Temp: $cpuTempM°C"
echo ""
echo "GPU Temp: $gpuTempM°C"
echo ""
echo "MEM Usage: "$memUsageM"MB/"$memTotalM"MB ($memUsageP%)"
echo "Root Usage: "$rootUsageM"GB/"$rootTotalM"GB ($rootUsageP%)"
The output is as follows:
Code:
~$ ./sysinfo
CPU Usage: 70.1%
CPU Freq: 800MHz
CPU Temp: 57.8°C
GPU Temp: 58.4°C
MEM Usage: 96.5MB/375.4MB (19.3%)
Root Usage: 0.9GB/7.2GB (12.4%)
That is actually insanely useful. Wish I saw this a little earlier, it would of saved a lot of time.
Thanks. This script just what I was looking for
Cheers i will try and get this to output via php for a little site i'm making for my pi.
thx for sharing
Perfect

[Q] Leaving getevent without “-c count”

Hi,
for catching events I found:
http://forum.xda-developers.com/showthread.php?t=2233865
Now I want to build a shell were I can look for devices and then catch them and bind them to a action...
It's my first time I tried to write a shell script...
The script works if I don't have any devices witch sends continuously there daters:
Code:
#!/system/bin/sh
[...]
device1="/dev/input/event4"
device2="/dev/input/event0"
while :; do
getevent -q -t -c 2 | grep -e "$device1" -e "$device2" | while IFS=' ' read -r ev_t_brckt ev_time ev_path ev_type ev_code ev_value _; do #-r _ a; do
Mapping "${ev_path/:}" "$ev_code" "$ev_value" "$device1" "$device2"
done
Result="$?"
if [[ "$Result" == "11" ]] then
input keyevent 85 #KEYCODE_MEDIA_PLAY_PAUSE
fi
done
..mapping looks like:
Code:
Mapping() { # "${ev_path/:}" "$ev_code" "$ev_value" "$deviceX1" "$deviceX2" (...)
if [[ "$1" == "$4" && "$2" == "0139" && "$3" == "00000001" ]] then
return 11 #Play/Pause
fi
# (…) and so on
}
is there any way to write
Code:
getevent -q -t -c 2 | grep -e "$device1" -e "$device2" | while IFS=' ' read -r ev_t_brckt ev_time ev_path ev_type ev_code ev_value _; do #-r _ a; do
to
Code:
getevent -q -t | grep -e "$device1" -e "$device2" | while IFS=' ' read -r ev_t_brckt ev_time ev_path ev_type ev_code ev_value _; do #-r _ a; do
Mapping "${ev_path/:}" "$ev_code" "$ev_value" "$device1" "$device2"
if [ -n "$?" ]; then
>>>> exit / break /what ever
fi
done
I tried it with “exit”, “break” and “return” (and “kill $PID”) but getevent didn't want to exit :'(
any ideas?
(pleas be clement with my grammar.. it's not my native language )
kind regards, Veit

Run bash script app

I' m trying to run a bash script.
I have a script and that script download 3 other scripts, and then, run them.
The first script, is the script where downloading 3 other scripts and running them.
The second script, is an example of the 3 other scripts.
So, which is the easiest way to do that ?
Is there any application where can do that ?
I use these scripts on android tv boxes.
The tv boxes are not rooted.
Also, i have an error with "wget: bad address"
Bash:
#!/bin/bash
wget http://domain.com/files/script_1.sh -O /sdcard/scripts/script_1.sh
sleep 1;
wget http://domain.com/files/script_2.sh -O /sdcard/scripts/script_2.sh
sleep 1;
wget http://domain.com/files/script_3.sh -O /sdcard/scripts/script_3.sh
sleep 1;
sh ./sdcard/scripts/script_1.sh
sleep 1;
sh ./sdcard/scripts/script_2.sh
sleep 1;
sh ./sdcard/scripts/script_3.sh
notify-send "Finish"
exit
Bash:
#!/bin/bash
wget https://domain.com/files/name.txt -O /sdcard/scripts/1.txt
cat 1.txt | cut -c10- | awk -F "/a/" '{print $1}' | awk -F "/word" '{print $1}' | awk 'NR == 2' > 1_.txt
a=$(cat 1_.txt) && sed -i "[email protected]\(.*/a/\).*\(/word/.*m\)@\1$a\[email protected]" /sdcard/scripts/file/filename1
sleep 2 ;
wget https://domain.com/files/name.txt -O /sdcard/scripts/2.txt
cat 2.txt | cut -c10- | awk -F "/a/" '{print $1}' | awk -F "/word" '{print $1}' | awk 'NR == 2' > 2_.txt
b=$(cat 2_.txt) && sed -i "[email protected]\(.*/a/\).*\(/word/.*m\)@\1$b\[email protected]" /sdcard/scripts/file/filename2
sleep 2 ;
find /sdcard/scripts/file/ -name "*.m" -printf '%T+ %p\n' | sort -r | xargs cat > /sdcard/scripts/file/filename.new
sleep 1 ;
sed -i '1i word' /sdcard/scripts/file/filename.new
sed -i '2i word' /sdcard/scripts/file/filename.new
sed -i '3i word' /sdcard/scripts/file/filename.new
sed -i '4i word' /sdcard/scripts/file/filename.new
domain.com is a web hosting site, so your http:// link is wrong - it needs to be your actual website
wget http://domain.com/files/script_1.sh -O /sdcard/scripts/script_1.sh
DSA said:
domain.com is a web hosting site, so your http:// link is wrong - it needs to be your actual website
wget http://domain.com/files/script_1.sh -O /sdcard/scripts/script_1.sh
Click to expand...
Click to collapse
Sorry, i forgot to say that the "domain.com" is an example. I use correct domain in my script. Just i hide it in post, because i wouldn't to share it.
The script in linux works fine.
May be the WGET what is implemented in your Android OS is faulty.
Here a workaround was shown.
jwoegerbauer said:
May be the WGET what is implemented in your Android OS is faulty.
Here a workaround was shown.
Click to expand...
Click to collapse
Didn't work. Same error
"wget: bad address"

Categories

Resources