Asset access error in APK made by using shell script - android

I wrote the shell script to build APK to automate build process. It's like below.
rm -rf obj
rm -rf gen
rm -rf bin
rm -f build.xml
rm -f local.properties
rm -f proguard-project.txt
ndk-build
android update project --path ./
ant release
jarsigner -verbose -keystore path/keystore -storepass password -signedjar bin/myApp-release-signed.apk bin/myApp-release-unsigned.apk alias
Currently, I got the APK successfully. But I found sometimes app is crashed when it try to access special asset like texture image. LogCat shows the log like below.
04-10 12:46:25.080: E/szipinf(2255): Error reading asset data
04-10 12:46:25.080: E/szipinf(2255): Unable to access asset data: -1
Eclipse can build APK well. I tried to find the way to fox APK's issue. But I cannot find.
Currently, I'm using android-12 and ndk-r6b. Also I'm working on Machintosh. Is there any special guide to fix such a thing?

Related

Upload generated .apk into Diawi using script

Is it possible to avoid manually uploading the .apk file into Diawi by using some scripts?
I saw that there is a plugin for Jenkins that uploads the .apk after CI and I was wondering if it is possible to do the same locally by using the command line.
After browsing in the Diawi documentation I found some guidance here. But I had issues with the HTTP 2 version and I had to force curl to use HTTP 1.1 instead. You can open the terminal of the Android Studio a just write the scripts. With the gradlew assembleRelease a .apk file will be generated, and after that, the curl command will upload it to your Diawi profile.
This is the command for Mac users:
./gradlew assembleRelease && curl -v --http1.1 https://upload.diawi.com/ -F token='<your_DIAWI_token>' -F file=#/<path_to_your_apk>/myapp-release.apk -F find_by_udid=0 -F callback_emails='<your_mail>'
This is for Windows users:
gradlew assembleRelease && curl -v --http1.1 https://upload.diawi.com/ -F token="<your_DIAWI_token>" -F file=#/<path_to_your_apk>/myapp-release.apk -F find_by_udid=0 -F callback_emails="<your_mail>"

Do I have to zipalign cordova release?

I've built a signed apk with cordova build --release android, should I zipalign it or did cordova already do all the job?
I know this is an old question, but figured I'd pitch the answer:
Cordova let's you hook on the "after_build" event, in which you can run a .bat file which will handle the zipalign.
Example (config.xml):
<hook type="after_build" src="zipalign_release.bat" />
The "src" is relative to project root (ie: same place config.xml resides).
My .bat:
if exist platforms\android\app\build\outputs\apk\release (
cd platforms\android\app\build\outputs\apk\release
zipalign -f -v 4 app-release.apk app-release-zipaligned.apk
) else (
echo Debug build.
)
no, you should zipalign it using the command prompt zipalign -v 4 app-release-unsigned.apk app-release.apk

zipalign: command not found - Ubuntu

I am trying to zipalign an "input.apk" file on an Ubuntu 14.04 LTS system using the command line as I do not have access to the source code just yet. If I'm not mistaken I should be able to do this with the following command
zipalign [-f] [-v] 4 intput.apk output.apk
but I am getting the following output
zipalign: command not found
I have made sure that the zipalign file is in my ...sdk/tools directory which I had to copy over from my ...build-tools/android-4.4W folder because it was originally missing. When I input this line as suggested in another question
./zipalign [-f] [-v] 4 intput.apk output.apk
I get the following output
Zip alignment utility
Copyright (C) 2009 The Android Open Source Project
Usage: zipalign [-f] [-v] <align> infile.zip outfile.zip
zipalign -c [-v] <align> infile.zip
<align>: alignment in bytes, e.g. '4' provides 32-bit alignment
-c: check alignment only (does not modify file)
-f: overwrite existing outfile.zip
-v: verbose output
Does this mean that I need a .zip file instead of my .apk to zipalign?
When a usage message contains an argument in brackets, the brackets mean that that argument is optional and can be left out of the final command; the brackets are not themselves part of the command syntax.
In your case, correct usage might look like:
./zipalign -v 4 intput.apk output.apk
In terminal,
cd /opt/android-sdk/build-tools/21.1.2
sudo ln -sf zipalign /usr/bin/
zipalign -v 4 platforms/android/ant-build/MainActivity-release-unsigned.apk platforms/android/ant-build/YOUR_APP.apk
Open terminal (CTRL + t)
cd YOUR_PATH/android-sdk-linux/build-tools/XX.X.X
sudo cp zipalign /usr/bin/
Open the folder where is located your apk in the terminal.
Execute zipalign -v 4 YOUR_APK.apk YOUR_APK.apk
I had the same issue. This is how i solved it, all you need is here.
1. Get zipalign path by getting sdk path on android studio. which is /Users/s****/Library/Android/sdk for me.
2. Paste the path on your terminal and cd to "build-tools/28.0.3/zipalign" now command will be/Users/s****/Library/Android/sdk/build-tools/28.0.3/zipalign
3. zip the apk on the same command line by adding -v 4 app-release-unsigned.apk my.apkto the command, now command will be
/Users/s****/Library/Android/sdk/build-tools/28.0.3/zipalign -v 4 app-release-unsigned.apk my.apk
4. Done.

Android: Rename Package in Eclipse

Is there a way to excecute the Eclipse command "Android Tools -> Rename Application Package" as a script from the shell?
I want to compile my Android application several times with different options (e.g. free and paid version) without doing some things manually.
It is important to do this automatically. All solutions like libraries won't help because several things have to be done by hand.
Yes, it is possible. You have to manually call aapt tool to package the compiled project, then call aapt again to add the classes, sign it with jarsigner and align it with zipalign. Normally, the Eclipse ADT plugin does the chain of build steps for you.
Example calls of the steps would be following.
Packaging the app with different package name:
aapt package -f -M ./AndroidManifest.xml -S res/ \
-I android.jar -F renamed_project.apk.unaligned \
--rename-manifest-package "com.example.some_new_package" -v
Then add the classes:
aapt add -f renamed_project.apk.unaligned classes.dex -v
Sign it:
jarsigner -verbose -sigalg MD5withRSA -digestalg SHA1 \
-keystore "some_keystore_file" \
renamed_project.apk.unaligned "key_name"
Align it:
zipalign -v 4 renamed_project.apk.unaligned renamed_project.apk
Some more information can be found for example here.
Also you can do it more easily with Ant. Here you can find some more information.

Titanium CLI not accepting the .keystore file provided

I am trying to make android build, target set to build for dist-playstore from Titanium CLI. I am using this command
titanium build -p android -b -d /Users/ajeetpratap005/Documents/Titanium_Studio_Workspace/androidTest
-f -L androidTest -A /Users/ajeetpratap005/android-sdks
-K /Users/ajeetpratap005/android-test.keystore
-T dist-playstore -O /Users/ajeetpratap005/Documents/Titanium_Studio_Workspace/androidTest/dist
It builds successfully but I am not able to get my build in the output folder. when I checked the build which is getting generated in the build/android/bin folder, it is signed with the default keystore file which is present in the
<titanium mobile SDK location>/3.0.0.G.A/android/dev_keystore
How do I make titanium CLI to take my .keystore file and dump the production build to the output folder mention in the command..
Please refer to this document
https://wiki.appcelerator.org/display/guides/Packaging+for+the+Android+Market
There are instructions on the android developer site for generating the certificate key file here: http://developer.android.com/guide/publishing/app-signing.html#cert
See this video for more clarity http://vimeo.com/10278960

Categories

Resources