Invalid syntax zipfile(apkAbsPath) in line 202 ninjadroid.py - android

I cloned ninjadroid from https://github.com/rovellipaolo/NinjaDroid recently and followed the instructions for decompiling apk files. As instructed I have installed android sdk and python, but when I tried running the command in my command prompt (python ninjadroid.py -t myPackage.apk), it throws the below error
File "ninjadroid.py", line 202
with ZipFile(apkAbsPath) as z:

Mmm... that's strange.
Is 'myPackage.apk' an existing file (in your computer)? Is it a real APK package? From the error, I would say you are trying to reverse a non-APK file.
Unfortunately the "is-APK" check in the current, available version is a lazy check - done pretty badly. I completely reimplemented it in the new version I am working on.
UPDATE
With the newest NinjaDroid version (i.e. 2.0):
$ python ninjadroid.py this_is_a_non_existing_file
>> NinjaDroid: [ERROR] The target file (i.e. 'this_is_a_non_existing_file') must be an existing, readable file!
$ touch this_is_an_existing_file_but_not_an_apk_package.txt
$ python ninjadroid.py this_is_an_existing_file_but_not_an_apk_package.txt
>> NinjaDroid: [ERROR] The target file (i.e. 'this_is_an_existing_file_but_not_an_apk_package.txt') must be an APK package!
$ python ninjadroid.py test/data/Example.apk
{
"app_name": "Example",
...
}

Related

Android chromium full browser apk build issues

I trying to build chromium android apk with this instruction
But on GN configuration step I have following problem after arguments file editing and saving
ERROR at //build/config/android/internal_rules.gni:1966:13: Script returned non-zero exit code.
exec_script("//build/android/gyp/find.py",
^----------
Current dir: /home/artem/chromium/src/out/Default/
Command: python -- /home/artem/chromium/src/build/android/gyp/find.py ../../third_party/android_tools/sdk/extras/google/google_play_services/libproject/google-play-services_lib/res
Returned 1.
stderr:
../../third_party/android_tools/sdk/extras/google/google_play_services/libproject/google-play-services_lib/res does not exist
See //build/config/android/rules.gni:634:3: whence it was called.
process_resources(process_resources_target_name) {
^-------------------------------------------------
See //third_party/android_tools/BUILD.gn:120:1: whence it was called.
android_resources("google_play_services_default_resources") {
^------------------------------------------------------------
See //base/BUILD.gn:1074:7: which caused the file to be included.
"//third_party/android_tools:cpu_features",
^-----------------------------------------
Then I try manually download google play services with command from this issue thread:
sudo ./build/android/play_services/update.py download
And get this warning:
Your version of the Google Play services library is not up to date. You might run into issues building or running the app. Please run `./build/android/play_services/update.py download` to retry downloading it.
After that I try to build full browser apk
ninja -C out/Default chrome_public_apk
and get error:
ninja: Entering directory `out/Default'
ninja: fatal: chdir to 'out/Default' - No such file or directory
Is there the way to fix this issue and build working apk file?
This works for me:
Run this command at chromium folder:
git rebase-update
gclient sync
Download google play services:
sudo ./build/android/play_services/update.py download
Configure GN: gn args opt/Full
Add this line to file: target_os="android"
Build apk with command: ninja -C opt/Full chrome_public_apk

NDK GCC : Could not determine GCC version

I'm trying to execute an Android sample that uses JNI to call C code from a Android Java Activity.
( Hello-jni) using Android Studio in ubuntu 15.04
I get the following error while building my project :
Error:Execution failed for task ':app:
compileHello-jniArm64- v8aDebugAllSharedLibraryHello-jniMainC'.
> No tool chain is available to build for platform 'arm64-v8a':
- Tool chain 'ndk-gcc' (GNU GCC): Could not determine GCC version:
failed to execute aarch64-linux-android-gcc -dM -E -.
Running gradle with the --info flag to determine the command being run:
gradlew :app:compileHello-jniArm64- v8aDebugAllSharedLibraryHello-jniMainC --info
In the output you should see a command containing aarch64-linux-android-gcc -dM -E - with a full path. Check that you do actually have this binary at the path shown (it should have been included in the android ndk).
Assuming you do, try running the command yourself. It will read from stdin and print a bunch of constants to stdout (gradle is trying to parse the version from this), but you want to see stderr:
echo '' | ./aarch64-linux-android-gcc -dM -E - 1>/dev/null
If the command fails, an error should be shown which can hint at the problem. In my case it was trying to include a folder 4.9.x but I had a folder named 4.9. Most likely there will be a different problem with your setup.

`gomobile build` and `gomobile install` throws "gomobile: EOF"

I'm trying to build an android application using gomobile but the commands gomobile install and gomobile build fail with gomobile: EOF . Before this error I was getting this error:
# golang.org/x/mobile/gl
In file included from /root/go/src/golang.org/x/mobile/gl/gl.go:17:0:
work.h:6:23: fatal error: GLES2/gl2.h: No such file or directory
compilation terminated. but it was fixed with yum install make gcc mesa-libGLES-devel mesa-libEGL-devel.
The application is mostly a networking application. Here are the imports. Do only certain packages work with gomobile or all of them?
"golang.org/x/mobile/app"
"golang.org/x/net/websocket"
"os/exec"
"flag"
"fmt"
log "github.com/golang/glog"
"io/ioutil"
"net"
"net/http"
"net/url"
"strconv"
OS: Fedora 22.
More info: I'm able to build https://github.com/golang/mobile/blob/master/example/network/main.go so I can only assume the issue is specific to my application.
It failed because AndroidManifest.xml was empty.

Install Calabash-Android causes error on OS X Mavericks

I need some help with trying to install Calabash-Android. After installing rvm, home-brew, when I install Calabash i get a strange error:
sudo gem install calabash-android
Building native extensions. This could take a while...
ERROR: Error installing calabash-android:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
checking for main() in -lc... yes
creating Makefile
make "DESTDIR="
compiling gherkin_lexer_ar.c
ragel/i18n/ar.c.rl:440:1: warning: control may reach end of non-void function [- Wreturn-type]
}
^
ext/gherkin_lexer_ar/gherkin_lexer_ar.c:864:18: warning: unused variable 'lexer_en_main' [-Wunused-const-variable]
static const int lexer_en_main = 1;
^
2 warnings generated.
linking shared-object gherkin_lexer_ar.bundle
clang: error: unknown argument: '-multiply_definedsuppress' [-Wunused-command-line- argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
make: *** [gherkin_lexer_ar.bundle] Error 1
Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/gherkin-2.12.2 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/gems/gherkin- 2.12.2/ext/gherkin_lexer_ar/gem_make.out
doronkatz#Dorons-MacBook-Air ~ $ mkdir ~/android
doronkatz#Dorons-MacBook-Air ~ $ mkdir ~/android
mkdir: /Users/doronkatz/android: File exists
doronkatz#Dorons-MacBook-Air ~ $ sudo gem install calabash-android
Password:
Building native extensions. This could take a while...
ERROR: Error installing calabash-android:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
checking for main() in -lc... yes
creating Makefile
make "DESTDIR="
compiling gherkin_lexer_ar.c
ragel/i18n/ar.c.rl:440:1: warning: control may reach end of non-void function [-Wreturn-type]
}
^
ext/gherkin_lexer_ar/gherkin_lexer_ar.c:864:18: warning: unused variable 'lexer_en_main' [-Wunused-const-variable]
static const int lexer_en_main = 1;
^
2 warnings generated.
linking shared-object gherkin_lexer_ar.bundle
clang: error: unknown argument: '-multiply_definedsuppress' [-Wunused-command-line- argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
make: *** [gherkin_lexer_ar.bundle] Error 1
Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/gherkin-2.12.2 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/gems/gherkin- 2.12.2/ext/gherkin_lexer_ar/gem_make.out
Not sure what the error means, I have installed Xcode tools for mavericks as well. Any thoughts out there?
I had the same problem and I just found out a solution for this.
I found one related problem here:
http://techespanto.wordpress.com/2013/03/29/upgrade-ruby-version-on-mac-osx/
and it suggested I had to upgrade the ruby version on my machine. The first two commands in that link are not working, so I leave you here what I did:
Install the command line tools for mac with:
xcode-select --install
Install homebrew in your mac with:
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
Install rvm with:
\curl -L https://get.rvm.io | bash -s stable --rails --autolibs=enable
List the latest ruby versions with:
rvm list known
Install the latest ruby version with:
rvm install ruby-<version>
(for me it was ruby-2.1-head)
And that's all. Hope it works for you as well!
You can also try the solution from https://stackoverflow.com/a/22787223/1165581
I looked at the calabash-ios google group for you and I think I have the solution for your
Try installing it like this
sudo ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install calabash-cucumber
If that fails you can try to downgrade xcode from 5.1 to one of the previous(Preferences->Locations).
And the reference link

How to download google source code for android

As you know, there is a list of several hundred projects in https://android.googlesource.com/. I'd like to download them all in windows machine. According to Google's document,
To install, initialize, and configure Repo:
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
To clone the entire platform, install repo, and run:
mkdir mydroid
cd mydroid
repo init -u https://android.googlesource.com/platform/manifest
repo sync
In my machine, however, I cannot "repo init" in Git Bash because it says it does not have python. I have python installed but git bash does not recognize it. Note that I set the python directory to the system path too. If anybody can give a tip, I would appreciate it. Thanks
UPDATE: I believe it's problem with new version of Git Bash for Windows. System path is not applied to Git Bash at all - I could easily test if system path worked with command prompt. Anyway, I tried this instead and it actually ran with error of course.
/c/python27/python.exe ../bin/repo init -u https://android.googlesource.com/platform/manifest
The error message is
$ /c/python27/python.exe ../bin/repo init -u https://android.googlesource.com/platform/manifest
Traceback (most recent call last):
File "../bin/repo", line 91, in <module>
import readline
ImportError: No module named readline
OK. I passed this error by installing pyreadline in windows:
easy_install pyreadline
If you got an error, you must install setuptools from
http://pypi.python.org/pypi/setuptools#files
And finally ran the command again to get this:
$ repo init -u https://android.googlesource.com/platform/manifest
fatal: unable to start d:\mywork\dev\GoogleAndroid\working_dir\.repo\repo/main.py
fatal: [Errno 8] Exec format error
With one click, download the latest code as .tar.gz file, from here
https://android.googlesource.com/platform/frameworks/base/+archive/master.tar.gz, the android could be found under core folder
Edit
Alternative here:
http://grepcode.com/project/repository.grepcode.com/java/ext/com.google.android/android/
Just select the version then a download options within.
If you consider, as an example, this other program "sympy" which also needs git bash and python, it is only a matter to add python to your PATH prior to launching the git bash session.
Install Python from:
http://python.org/download/
by downloading the "Python 2.7 Windows installer" (or Python 2.6 or 2.5) and running it.
Add python directory to your system environment path variable
(My Computer -> Advanced -> Environment Variables -> Path -> Edit).
Note that the repo script itself must be in the path, as mentioned in the Version Control page of android:
Repo is a repository management tool that we built on top of Git. Repo unifies the many Git repositories when necessary, does the uploads to our revision control system, and automates parts of the Android development workflow.
Repo is not meant to replace Git, only to make it easier to work with Git in the context of Android.
The repo command is an executable Python script that you can put anywhere in your path.
This answer explains how to fix this error:
fatal: unable to start c:\path\.repo\repo/main.py
fatal: [Errno 8] Exec format error
Summary: I finally used the python packaged by Cygwin.
Details: Below is the full story.
The tip from the repo bug tracking is to add '/c/app/Python27/python ':
line 136 in v1.20
REPO_MAIN = '/c/app/Python27/python ' + S_repo + '/main.py'
line 735 in v1.20 (beginning of function main)
wrapper_path = '/c/app/Python27/python ' + os.path.abspath(__file__)
But we get the error TypeError: coercing to Unicode: need string or buffer, NoneType found
Therefore I reverted these changes above and performed the other changes below (on version 1.20):
line 136, replaced single slash by double back-slash:
REPO_MAIN = S_repo + '\\main.py'
line 766, added python absolute path as first element of me:
me = ['C:\\app\\Python27\\python.exe', repo_main,
'--repo-dir=%s' % rel_repo_dir,
'--wrapper-version=%s' % ver_str,
'--wrapper-path=%s' % wrapper_path,
'--']
line 776, replaced os.execv(repo_main, me) by
os.execv('C:\\app\\Python27\\python.exe', me)
However we get still an error:
$ Traceback (most recent call last):
File "c:\path\.repo\repo\main.py", line 39, in <module>
from subcmds.version import Version
File "c:\path\.repo\repo\subcmds\__init__.py", line 36, in <module>
['%s' % name])
File "c:\path\.repo\repo\subcmds\forall.py", line 17, in <module>
import fcntl
ImportError: No module named fcntl
The Python v2.7 fcntl documentation says fcntl is available for platform Unix only.
I finally reverted again all changes in repo script and installed Cygwin including its python and git packages: it succeeded as a charm.
But, as the symlinks simulated by Cygwin are not recognized by the MSysGit, we have to use the Cygwin git. And GUIs on top of git are not fully compliant with Cygwin git...
(see also my other post)
Edit:
Cygwin can use native NTFS symlinks (just set CYGWIN=winsymlinks:native and be Admin). Therefore MSysGit can be used and any other GUI based on it :-)

Categories

Resources