FlatBuffer unable to generate .bin file - android

I am using FlatBuffer 1.8 release (windows flatc)
Here are few commands which i have tried in cmd windows.
C:\>C:\Flat\flatc.exe flatbuffer -b -j "C:\Akash\FlatBuffer\app\src\main\res\raw\sample_schema.fbs" "C:\Akash\FlatBuffer\app\src\main\res\raw\sample_json.json"
one more using flatbuffer jar file
C:\>C:\Akash\FlatBuffer\app\libs>flatbuffers-java-1.3.0-SNAPSHOT.jar flatc C:\Akash\FlatBuffer\app\src\main\res\raw\job_schema.fbs C:\Akash\FlatBuffer\app\src\main\res\raw\job.json
which gives me following error
sample_schema.fbs & sample_json.json is available on this link
What am I missing here?

Your command includes the word flatbuffer, which does not fit the specification of the command:
flatc.exe [OPTION]... FILE... [-- FILE...]
To fix the command, remove that word:
C:>C:\Flat\flatc.exe -b -j "C:\Akash\FlatBuffer\app\src\main\res\raw\sample_schema.fbs" "C:\Akash\FlatBuffer\app\src\main\res\raw\sample_json.json"
With this example, three files should be created: Friend.java, People.java, PeopleList.java, and sample_json.bin.

Related

How to build OpenCv with extra contrib modules

I am trying to build OpenCV to include OpenCV contrib modules which is in a repository. I am following the instructions in this link, but i could not understand the cmd commands which is i mentioned in the section titled "cmd commands" as follows.
cmd commands:
$ cd <opencv_build_directory>
$ cmake -DOPENCV_EXTRA_MODULES_PATH=<opencv_contrib>/modules
<opencv_source_directory>
$ make -j5
here are my attempts to get the cmd commands as mentioned above running:
1-concerning the opencv_build_directory: i just created it by myself and named it 'build' as shown in the image in the section titled "OpenCV3.0.0 source"
2-concerning the opencv_source_directory: i think it should be "OpenCV-android-sdk" as shown in the image section titled "OpenCV3.0.0 source"
3- for the cmd command '$ cd ' i set it as follows:
c:\xxxx\libs\OpenCV-3.0.0-android-sdk-1\OpenCV-android-sdk\build>
4- for the cmd command '$ cmake -DOPENCV_EXTRA_MODULES_PATH=/modules' iset it as follows:
cmake -DOPENCV_EXTRA_MODULES_PATH=opencv_contrib-master/modules OpenCV-
android-sdk
the entire command i type in the cmd is:
c:\xxxx\libs\OpenCV-3.0.0-android-sdk-1\OpenCV-android-
sdk\build>cmake -DOPENCV_EXTRA_MODULES_PATH=opencv_contrib-
master/modules OpenCV-android-sdk
but after running it, i get:
CMake Error: The source directory "C:/xxxx/libs/OpenCV-3.0.0-
android-sdk-1/OpenCV-android-sdk/build/OpenCV-android-sdk" does not
exist.
Specify --help for usage, or press the help button on the CMake GUI.
please help me to build the path correctly as stated in the linke mentioned
note:
I am trying to install opencv contrib modules on android through android Studio
OpenCV3.0.0 source
OpenCV-contrib source:

Running apktool in a bash script

I am trying to write a bash script that decompiles several .apk files using apktool. Each apk file is located in a subdirectory of the sample folder.
#!bin/bash
for item in $(ls samples);
do
for apk in $(ls "samples/$item");
do
echo ./apktool/apktool d "./samples/$item$apk"
$(./apktool/apktool d "./samples/$item$apk")
done
done
When I run the script I get the following output:
./apktool/apktool d ./samples/ADRD/53dc.apk*
Input file (./samples/ADRD/53dc.apk*) was not found or was not readable.
The input file error message is the standard for when apktool cannot find a file. However, if I run the following command in the terminal the apktool will work correctly.
./apktool/apktool d ./samples/ADRD/53dc.apk*
I have changed the permissions of all the files located in the samples folder to rw for all users. I also have tried using sudo with the shell script, but this causes the script to hang. However, when I use sudo with the apktool in the command line it also hangs. Therefore, I am not sure if using sudo with apktool is doable.
Any help is appreciated, thanks.
So it looks like this ls gives you an output with an asterisk * appended at the end of the apk filename, because the file is executable.
for apk in $(ls "samples/$item");
This is not the default behaviour of ls, you are getting this probably because you have aliased ls to ls -F or similar. To bypass the alias, rewrite the line this way:
for apk in $(\ls "samples/$item");
Notice the \ I added there.
BTW, is it normal that an apk file is executable? Perhaps you can remove the executable bit:
find samples -name '*.apk' -exec chmod -x {} \;
Also, possibly your script can be replaced with this one liner:
find samples -name '*.apk' -exec ./apktool/apktool d {} \;
Mind you, this is not exactly the same thing, because it may go deeper than two directories. If you need to limit the depth, that's possible too, see man find

Generate R.java Using AAPT

I am trying to generate apk file using command prompt by following below blog.
Generate APK using command prompt
I successfully generated key, but when i am trying to generate R.java it is giving following error
Command i used to generate R.java:-
E:\ADT\adt-bundle-windows-x86_64-20140702\sdk\build-tools\19.0.0>aapt com.concep
t.build -v -f -m -S E:\AppBuilder\res -J E:\AppBuilder\gen -M E:\AppBuilder\Andr
oidManifest.xml -I E:\ADT\adt-bundle-windows-x86_64-20140702\sdk\platforms\andro
id-19\android.jar
Error:-
**Crunching PNG Files in source dir: E:\AppBuilder\res
To destination dir: (null)**
Please tell me what wrong i am doing .
OR
Can Please help me how to generate apk using command prompt.

how to generate apk file using a command line?

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.

convert odex file to dex file

I would like to covert odex file to dex file. I already pulled framework folder from system. I tried the following command,
java -jar baksmali-2.1.2.jar -d system/framework -x temp.odex
but error was produced - error message is like below.
Error occurred while loading boot class path files. Aborting. org.jf.util.ExceptionWithContext: Cannot locate boot class path file /system/framework/core.jar
at org.jf.dexlib2.analysis.ClassPath.loadClassPathEntry(ClassPath.java:277)
at org.jf.dexlib2.analysis.ClassPath.fromClassPath(ClassPath.java:182)
at org.jf.baksmali.baksmali.disassembleDexFile(baksmali.java:67)
at org.jf.baksmali.main.run(main.java:113)
at org.jf.baksmali.main.main(main.java:322)
I could not find "core.jar" in my android system framework folder.
As of 2017-06-09 baksmali has changed. It works like this.
java -jar baksmali-2.2.0.jar d SamsungInCallUI.odex -o SamsungInCallUI
Then assemble the dex file.
java -jar smali-2.2.0.jar ass SamsungInCallUI -o SamsungInCallUI.dex
Try this instead:
java -jar baksmali-2.1.2.jar -c boot.oat -d system/framework/arm/boot.oat -x temp.odex
The specific path to your boot.oat might be different.
Also note that baksmali doesn't yet support deodexing the N preview images.
This worked for me adb pull /system/framework/arm/boot.oat /tmp/framework/boot.oat Placing the apk and the odex file baksmali.jar -x -c boot.oat -d /tmp/framework APKname.odex -o APKname
I'm not sure that I've understood correctly your question (kindly correct me if I'm wrong), but if you are trying to convert an odex to dex, I've already replied to a similar question here: https://reverseengineering.stackexchange.com/questions/12393/reverse-engineering-android-vendor-system-apps/12406#12406
Anyway, to my knowledge you have two chooice:
Follow this guide: http://www.naldotech.com/how-to-deodex-applications-on-android-5-0-lollipop/
Or use oat2dex as pointed out by the user who commented my answer on RE stackexchange.
Good luck
This is an extension of #kakopappa's answer.
Get the latest version of baksmali and smali jar from here and put them in a folder and add this method to your .bash_profile file if you are a mac/linux user.
Get baksmali and smali jar in your computer and assign it to these variables from terminal.
BAKSMALI_JAR_PATH = ""
SMALI_JAR_PATH=""
Note : After editing the value should look something like
BAKSMALI_JAR_PATH = "/Users/rabbit/tools/baksmali-2.2.7.jar"
SMALI_JAR_PATH = "/Users/rabbit/tools/smali-2.2.7.jar"
Copy paste this script in your terminal and restart your terminal. This is a shortcut function which would get added to .bash_profile and you would get it handy.
echo "BAKSMALI_JAR_PATH="$BAKSMALI_JAR_PATH >> ~/.bash_profile
echo "SMALI_JAR_PATH="$SMALI_JAR_PATH >> ~/.bash_profile
echo >>
function odextodex() {
odex_file_name=$1
deassembled_file=${odex_file_name%.odex}
java -jar $BAKSMALI_JAR_PATH d $1 -o $deassembled_file
java -jar $SMALI_JAR_PATH ass $deassembled_file -o $deassembled_file.dex
rm -rf $deassembled_file
}
After doing this type odextodex filename.odex - you should see filename.jar file in your current directory.

Categories

Resources