I'm trying to sign an APK with SignApk, but I keep getting this error:
Error: Unable to access jarfile signapk.jar
I have appended my JDK directory as well as my SignAPK directory to my system path variable. The java command works fine through the command-line, but I can't seem to get the -jar option to work correctly for signing APKs.
My SignApk folder is located on my C:\ drive, so it looks like this:
Here is what I am trying to do through the command-line:
Please ignore the blank space in between the variables as I was trying to cover up my details. The syntax that I am using is:
java -jar signapk.jar certificate.pem key.pk8 myapk.apk myapk-signed.apk
I have tried the commands from the SignApk directory as well as the bin directory inside of that directory. Can anyone help me troubleshoot how to resolve this issue? Thanks
As you might notice, there is no signapk.jar file there, there is only signapk without extension.
Download different SignApk from here:
http://www.mediafire.com/download/h5fob1afzt1p4ss/SignApk.rar
Password: SanketN8
just download Signapk.zip and unzip wherever you wish, paste your apk inside the signapk folder.
open cmd / terminal , change directory to signapk
java -jar signapk.jar testkey.x509.pem testkey.pk8 test.apk test-signed.apk
copy and replace with you existing file name (test.apk) and output file (test-signed.apk )
signapk.zip - https://drive.google.com/open?id=0ByAytNiwJoUaQ3NvVzlPX0xGUFU
image
In case one encounters this message when signing a LineageOS build:
Get rid of ./build/tools/releasetools/ prepended to (old) commands used for signing.
See https://wiki.lineageos.org/signing_builds#:~:text=For%20LineageOS%20versions-,older%20than,-18.1%20you%20will
Related
I have many APK (Android package) files in a folder and I want to extract the manifest files from each of them. I am using Android apktool to convert them and since there are many APK files I want to convert them in a loop, not one by one.
apktool d hello.apk ./hello is the command for extracting manifest files from hello.apk and produces the output folder named hello.
I tried the command in the command prompt using for loop in the current directory in which all APK files are stored:
for \r %v in (*.apk) do apktool d "%v" "./%v".
I want the output folder of same name for each APK file, i.e. if APK is hello.apk the output folder should be hello. The above command is producing an error: cannot generate the output folder. How can I extract manifest files from all such APK files at once from a loop?
Maybe you forgot -o parameter?
That command works fine for me:
for /r %v in (*.apk) do apktool.jar d "%v" -o "./%~Nv"
I'm trying apk tool, following the instruction I have create a folder with
Where
-myapp.apk is a sample app that I want to decompile
My bat Decompile.bat is
#echo off
pushd "%~dp0"
apktool if myapp.apk
apktool if framework-res.apk
apktool d myapp.apk
pause
When I start the bat the prompt autoclose after the first lines execution
#echo off
apktool if myapp.apk
apktool if framework-res.apk
the execution of these line is correctly but jump the latet line for some reason
If I try to use apktool from prompt works, so the problem is my bat file but I don't know how to fix it
You need to see how apktool.bat is referencing java. I downloaded the source from github and this is what's listed:
#echo off
set PATH=%CD%;%PATH%;
java -jar "%~dp0\apktool.jar" %1 %2 %3 %4 %5 %6 %7 %8 %9
If that's the case then it's assuming that java is in the PATH variable or in the current directory. Maybe add an echo for the path and see why it cannot find it. Alternatively, set the JAVA_HOME environment variable and put the full path to java inside of apktool.bat.
please tell me how to build apk files of a project without the use of ECLIPSE ide. i found some infos about using a batch file but i don't know how to remake it.
echo on
SET PREV_PATH=%CD%
cd /d %0\..
REM Clear bin folder
rmdir "bin" /S /Q
rmdir "gen" /S /Q
mkdir "bin" || goto EXIT
mkdir "gen" || goto EXIT
REM Set your application name
SET APP_NAME=SecureSms
REM Define minimal Android revision
SET ANDROID_REV=android-8
REM Define aapt add command
SET ANDROID_AAPT_ADD="%ANDROID-SDK%\platforms\%ANDROID_REV%\tools\aapt.exe" add
REM Define aapt pack and generate resources command
SET ANDROID_AAPT_PACK="%ANDROID-SDK%\platforms\%ANDROID_REV%\tools\aapt.exe" package -v -f -I "%ANDROID-SDK%\platforms\%ANDROID_REV%\android.jar"
REM Define class file generator command
SET ANDROID_DX="%ANDROID-SDK%\platform-tools\dx.bat" --dex
REM Define Java compiler command
SET JAVAC="%JAVABIN%\javac.exe" -classpath "%ANDROID-SDK%\platforms\%ANDROID_REV%\android.jar"
SET JAVAC_BUILD=%JAVAC% -sourcepath "src;gen" -d "bin"
REM Generate R class and pack resources and assets into resources.ap_ file
call %ANDROID_AAPT_PACK% -M "AndroidManifest.xml" -A "assets" -S "res" -m -J "gen" -F "bin\resources.ap_" || goto EXIT
REM Compile sources. All *.class files will be put into the bin folder
call %JAVAC_BUILD% src\org\secure\sms\*.java || goto EXIT
REM Generate dex files with compiled Java classes
call %ANDROID_DX% --output="%CD%\bin\classes.dex" %CD%\bin || goto EXIT
REM Recources file need to be copied. This is needed for signing.
copy "%CD%\bin\resources.ap_" "%CD%\bin\%APP_NAME%.ap_" || goto EXIT
REM Add generated classes.dex file into application package
call %ANDROID_AAPT_ADD% "%CD%\bin\%APP_NAME%.ap_" "%CD%\bin\classes.dex" || goto EXIT
REM Create signed Android application from *.ap_ file. Output and Input files must be different.
call "%JAVABIN%\jarsigner" -keystore "%CD%\keystore\my-release-key.keystore" -storepass "password" -keypass "password" -signedjar "%CD%\bin\%APP_NAME%.apk" "%CD%\bin\%APP_NAME%.ap_" "alias_name" || goto EXIT
REM Delete temp file
del "bin\%APP_NAME%.ap_"
:EXIT
cd "%PREV_PATH%"
ENDLOCAL
exit /b %ERRORLEVEL%
i got this codes from a site. (http://www.apriorit.com/our-company/dev-blog/233-how-to-build-apk-file-from-command-line)
i downloaded the source code sample and opened the batch file in there but it didn't generate it's apk file. usually the apk file is located at its bin\ right? but when i opened the folder, the file is not in there. please help me how to use this one. i'd appreciate you help.
You’ll have to have Apache ant for this one:
ant debug
This will build and sign the necessary .apk files.
For more info, please see this: http://codeseekah.com/2012/02/09/command-line-android-development-basics/
EDIT:
ant is not a part of standard Android SDK setup. You'll have to install it.
Download the latest ant zip file from The Apache Ant Project.
Extract the zip file to a folder, say c:\ant\
Add c:\ant to your path environment variable
Once these are done, you'll be able to run ant from the command line
The apk by default is located under bin and this is correct, but when you distribute source code it's better to not add any apk because a "fresh" compiled apk is always a better solution.
if you have a file called build.xml in the root of your project just do
ant debug
otherwise you need to update your project with the minimum informations required for the building phase with
android update project -t android-10 -p .
in this case android-10 is a target for your apk/app/api and you can customize this option for your targeted device.
After this you get your build.xml and everything is in place for generating an apk.
ant debug install
is actually viable if you create project with (note that you should specify the virtual device with "adb -s" command while installing if you're running multiple devices)
android create project -n <project_name>
-t <target_version> -p <path> -k <package> -a <activity>
and use this command to run on the avd (if you've started one)
adb -e shell "am start -a android.intent.action.MAIN -n com.your.package/.YourActivity"
(change -e option to -d if you're running on devices)
reference
better use "AVD Manager.exe" to start a virtual device if you don't know those command or parameters, as there're quite a lot.
One of the best example I found on Internet for creating Android APK is https://geosoft.no/development/android.html.Also you can use assembleDebug command in root directory (make sure setting gradle as environment variable), if you are using Gradle.
I have a mono android project. I can use monodevelop to build the apk of my project. But I want to write a build file (like we do using ANT) with targets that can generate the .apk file.
Please point me to the right direction.
I have figured out the we need to use mandroid.exe to generate .apk from the .dll.
the log shows that there is a target called _Manddroid that monodevelop's build tool runs. This target in turn runs following command
C:\Program Files\MSBuild\Novell\mandroid.exe -v --nosign --sdk-dir="C:\Android\android-sdk" --builddir="C:\Users\Sikha\Documents\Projects\helloShikha\helloShikha\obj\Debug\android" --framework-dir="C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v2.2" --framework-dir="C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0" -S="C:\Users\Sikha\Documents\Projects\helloShikha\helloShikha\obj\Debug\res" --package="helloShikha.helloShikha" --nolink --abi="armeabi" --java-sdk-dir="C:\Program Files\Java\jdk1.6.0_30" --debug --sdk-platform="8" "C:\Users\Sikha\Documents\Projects\helloShikha\helloShikha\bin\Debug\helloShikha.dll" "C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v2.2\Mono.Android.dll" "C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\mscorlib.dll" "C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Core.dll" "C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.dll" "C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Xml.dll"
When I try to copy paste the above command on cmd nothing happens. Any Idea what I am missing here?
I used following command and it generated the .apk file for me.
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe myproject.csproj /t:Package
I tried using .sln file but was receiving an error : target Package does not exist in the project.
I opened the myproject.csproj file and figured out that this file imports Novell.MomoDroid.CSharp.Targets which in turn imports the Novell.MonoDroid.Common.Targets
The target "Package" is present in the file Novell.MonoDroid.Common.Targets.
Why do you want to write alternative targets? The Mono for Android project files are MSBuild-based, and MSBuild is Microsoft's equivalent of ant. This means the csproj files are already fully extensible and customizable, and can be built using the commandline MSBuild tool:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe YourSolution.sln
i am tryig to execute a sample python program through monkey runner command prompt and it is throwing an error
Can't open specified script file
Usage: monkeyrunner [options] SCRIPT_FILE
-s MonkeyServer IP Address.
-p MonkeyServer TCP Port.
-v MonkeyServer Logging level (ALL, FINEST, FINER, FINE, CONFIG, INFO,
WARNING, SEVERE, OFF)
Exception in thread "main" java.lang.NullPointerException
so any one can guide me how to resolve this one
scriptfile should be a full path file name
try below
monkeyrunner c:\test_script\first.py
try using something like
...\tools>monkeyrunner -v ALL first.py
where first.py was my sample python script which I copied into tools folder of android SDK (the place where monkeyrunner.bat is located)
Under all unix/linux families OS the sha bang syntax can be used.
Edit the first line of your script with the results of the following command:
which monkeyrunner
for example, if monkeyrunner (usually provided with android sdk) has been installed under /usr/local/bin/sdk write:
#!/usr/local/bin/sdk/tools/monkeyrunner
or even use "env"
#!/usr/bin/env monkeyrunner
then set you script file as executable
chmod +x <script>
You can now launch your script from the shell.
It looks not make sense to switch working directory to Android SDK folder but just for obtain some relative references path for itself. It means you have to specify the full path for your script file and the PNG image files you want to save or compare to.
A better way is modify few lines in the "monkeyrunner.bat" under your SDK folder as below. This will use your current path as working directory, so, no necessary to use full path file name.
rem don't modify the caller's environment
setlocal
rem Set up prog to be the path of this script, including following symlinks,
rem and set up progdir to be the fully-qualified pathname of its directory.
set prog=%~f0
rem Change current directory and drive to where the script is, to avoid
rem issues with directories containing whitespaces.
rem cd /d %~dp0
rem Check we have a valid Java.exe in the path.
set java_exe=
call %~sdp0\lib\find_java.bat
if not defined java_exe goto :EOF
set jarfile=monkeyrunner.jar
set frameworkdir=
set libdir=
if exist %frameworkdir%%jarfile% goto JarFileOk
set frameworkdir=%~sdp0\lib\
if exist %frameworkdir%%jarfile% goto JarFileOk
set frameworkdir=%~sdp0\..\framework\
:JarFileOk
set jarpath=%frameworkdir%%jarfile%
if not defined ANDROID_SWT goto QueryArch
set swt_path=%ANDROID_SWT%
goto SwtDone
:QueryArch
for /f %%a in ('%java_exe% -jar %frameworkdir%archquery.jar') do set swt_path=%frameworkdir%%%a
:SwtDone
if exist %swt_path% goto SetPath
echo SWT folder '%swt_path%' does not exist.
echo Please set ANDROID_SWT to point to the folder containing swt.jar for your platform.
exit /B
:SetPath
call %java_exe% -Xmx512m -Djava.ext.dirs=%frameworkdir%;%swt_path% -Dcom.android.monkeyrunner.bindir=%frameworkdir%\..\..\platform-tools\ -jar %jarpath% %*
I met the same things as you did, I resolved by using "monkeyrunner" command under tools, and your script file should be a full path name. It looks like the directory “tools” is the main directory of MonnkeyRunner. I am depressed that I can't run my script files by pydev IDE directly.
monkeyrunner.bat cygpath -w $(pwd)/monkey.py