unable to process assets while packaging cocos2d-x android - android

I just started working on cocos2d-x to build games. I have completed setup. I am getting below error when I run "HelloCpp" sample.
(skipping file '.gitignore' due to ANDROID_AAPT_IGNORE pattern '.*')
Unable to add 'C:\cocos2d-x-2.2.1\samples\Cpp\HelloCpp\proj.android\assets\fonts\Marker Felt.ttf': Zip add failed
ERROR: unable to process assets while packaging 'C:\cocos2d-x-2.2.1\samples\Cpp\HelloCpp\proj.android\bin\resources.ap_'
ERROR: packaging of 'C:\cocos2d-x-2.2.1\samples\Cpp\HelloCpp\proj.android\bin\resources.ap_' failed
Kindly help me to fix this issue.
Thanks.

This problem has multiple solutions and I tried each one of them, and the last one worked properly. I am giving you the exact steps I took to get it work for me.
1.Check if Cygwin has the neccessary packages, if not install them. The following packages are required -
autoconf, automake, binutils, gcc-core, gcc-g++, gcc4-core, gcc4-g++, gdb, pcre, pcre-devel, gawk, make
(I skipped gcc4-core and gcc4-g++)
2.Tried renaming Marker Felt.ttf to remove the space, however since it gets regenerated, I searched for the file in all of my C: drive and renamed it everywhere.
3.Then I ran Eclipse in Administrator mode.
4.I was getting the same error although only once this time. So I changed the permission of the Asset folder in the build_native.sh itself. Just add the following line at the end of your build_native.sh file.(Taken from here)
chmod 777 -R "$APP_ANDROID_ROOT"/assets
and voila, it worked. I am not sure which one of the step was not required so I put everything here. I am guessing that running eclipse in admin mode was not required, since I can work now in normal mode too. Just in case you get into same problem you can try running it in admin mode.

Related

Trying to build Android app but got clang error

I'm new to Android development. So want to start and just build and run Hello World app in my mobile. I've installed NDK, clang-12, Fyne and run
fyne package --os android --appID com.example.myapp
Got
go build -buildmode=c-shared -o /tmp/gomobile-work-791801243/lib/armeabi-v7a/libparts.so parts failed: exit status 2
# runtime/cgo
clang: error: no input files
The project's structure:
parts:
- go.mod
- Icon.png
- main.go
If I run manually from project root (parts)
go build -buildmode=c-shared -o /tmp/gomobile-work-791801243/lib/armeabi-v7a/libparts.so parts
It creates .so file without any error. Seems like it's just about relative path, but how can I fix it? Sorry for providing poor info, really don't know what may be useful. So please write in comments what info do you need and I'll provide it.
Are you running the command from inside the “parts” folder?
Perhaps you have GOOS or GOARCH set which could alter the build path?
You might have a broken development environment when trying to build for Android. Short of reinstalling it, I would recommend using fyne-cross with either docker or podman.
Just install fyne-cross with:
go install github.com/fyne-io/fyne-cross#latest
Followed in your application directory by:
fyne-cross android

repo about .git/HEAD: error: manifest missing or unreadable -- please run init

I was downloading android 4.4 source code using repo(in ubuntu). Last time I killed repo process by pressing the key combination: Ctrl+Z, and when I started it this time by using the command: "repo init" and "repo sync", I got the following errors:
error: in sync: [Errno 2] No such file or directory:
u'/home/ubuntu/workspace/packages/apps/VoiceDialer/.git/HEAD' error:
manifest missing or unreadable -- please run init
I've tried "run init", which displays no errors. But the problem remains after running "repo init". What should I do? Is there any way to tell repo to reproduce the ./git/HEAD file?
I solved the problem by deleting the VoiceDialer folder, then running "repo init" and "repo sync". With the .git folder in it, it may not "repo init" successfully.
I also get the problem. Here are the steps:
1. delete the folder
2. 'repo sync' the folder again.
Error is usually solved by starting your repo init from scratch. This includes deleting the folder it is downloading to. You will need to remake the directory that you deleted with
mkdir -p ~/mydirectory
at which point you will be ready to reinitialize the repo download from scratch.
If you are initializing a master repo for a build you will need to start from scratch, otherwise you will keep getting these errors.
All the answers involved deleting the whole directory. While this works, it seems like an overkill. The same result can be achieved by deleting the .repo dir that was created when running repo init at the location it was ran in.
That prevents re-downloading the whole remote repo again.
Note: If there is no such dir at the current location, it may be in one of the parent directories.
I solved this by going to /usr/bin/repo and changing the manifest pointer from 'manifest' to 'manifest.git'
Using an older version of git, 2.14 that's 3rd party for Centos 6.6

Phonegap error android sdk build.xml:950 : null returned: 1

I'm trying to launch phonegap android app in android sdk, but I am receiving an error:
[phonegap] detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] compiling Android...
[error] An error occurred while building the android project.Error executing "ant debug -f "/Users/me/Projects/one/platforms/android/build.xml"":
BUILD FAILED
/Applications/Android/adt-bundle-mac-x86_64-20131030/sdk/tools/ant/build.xml:932: The following error occurred while executing this line:
/Applications/Android/adt-bundle-mac-x86_64-20131030/sdk/tools/ant/build.xml:950: null returned: 1
I followed this guide http://docs.phonegap.com/en/2.2.0/guide_getting-started_android_index.md.html but it is not working.
What could have caused this?
You are most likely also getting the line
invalid resource directory name:
/YOUR/PROJECT/ROOT/PATH/bin/res/crunch
right before the error codes, so open up terminal and enter the following:
cd YOUR/PROJECT/ROOT/PATH
rm -fR $(find . -type d -name crunch|xargs)
I just had to cd into the platforms/android dir and run ant clean and it fixed this issue for me.
had the same issue. something that can help is to read ant log as recommend here
to do so run ant -logfile //antLogFile.txt release -f ./AppMain/build.xml
or in the folder itself. i.e : platforms\android run ant -logfile ./antLogFile.txt release
My issue was a file with Hebrew characters on its name..
Hi Sorry for the late answer
An alternative to other solutions possibly OS-X Specific but i was having the same issue and none of the solutions for me worked however the mention of assets made me go back and scour over my build logs and i noted this:
[aapt] /Users/rowdoggnz/Development/cordova/surveyapp/platforms/android/assets/www/lib/fa/Icon
[aapt] : error: Invalid filename. Unable to add.
This was the cause of my error which shared the same error code and line references as the original poster.
OS-X seems to generate ghost icon files for some reason which are not visible in finder due to being hidden, i used an app called "Invisiblix" to view my project folder and removed all of the 'Icon' files and my app would build fine.
I'm guessing the iOS build naturally ignores these Icon files however Ant doesn't.
Hope this helps someone.
If you have more than one project and you are using the same assets eg: images, ant will fail to build. You can use ant clean to remove the cache from other projects and avoid this issue as suggested in this post crunch/resource packaging with aapt in ant build uses cache from other projects
Nevertheless, In my case I just have one project with many images, some of them were called with the same name, but with different letter case. Ant's build process is case-insensitive, so those images were duplicated, being error cause.
My particular fix was to rename or eliminate one of the images to allow cordova build my project.
I was having this issue in OSX using Ionic framework. This was my fix:
I ran this on the command line in the project root folder:
find . -name Icon -exec rm {} \;
What the above does descend through the whole project to search for files name Icon. Upon finding them they are deleted.
After this I ran my build process and all was good again.
Make sure you have installed the prerequisites correctly.

AOSP and IntelliJ IDEA

Has anyone tried to work with AOSP using IntelliJ IDEA? I see in Android sources a specific folder (development/ide/intellij) but I cannot find any information how to use it in case of Android development (for Eclipse the information can be found here: http://source.android.com/source/using-eclipse.html) Can anyone provide similar instructions how to start developing Android in IDEA?
Also a good reading here: https://shuhaowu.com/blog/setting_up_intellij_with_aosp_development.html
If you get
Couldn't find idegen.jar. Please run make first.
You'll need to generate it first:
source build/envsetup.sh
cd development/tools/idegen
mm
croot
development/tools/idegen/idegen.sh
Be prepared that AOSP files indexing in IJ takes long time (more than 1 hour on my notebook with an SSD on board), a reason to use Eclipse, as I believe it doesn't need to build indexes so loads AOSP code much faster.
It's worth reducing android.iml file with removing AOSP parts you are not interested in. You can add them to development/tools/idegen/excluded-paths via a regular expression pattern, see README file there.
I added following lines to excluded-paths:
^cts
^developers
^development
^external
.*/tests/.*
^sdk
so my android.iml got quite moderate size and loads in about 1-2 minutes instead.
idegen has also intellij-gen.sh which can generate IJ project for given module.
As mentioned in the article above, you can tweak IJ to work faster (add more RAM, etc). Here goes my idea64.vmoptions just in case:
-server
-Xms2048m
-Xmx4096m
-XX:MaxPermSize=1024M
-XX:ReservedCodeCacheSize=1024M
-XX:+UseCodeCacheFlushing
-XX:+UseCompressedOops
-XX:+UseConcMarkSweepGC
-XX:+UseParNewGC
-XX:ParallelGCThreads=8
-XX:+AggressiveOpts
-XX:+CMSClassUnloadingEnabled
-XX:+CMSIncrementalMode
-XX:+CMSIncrementalPacing
-XX:CMSIncrementalDutyCycleMin=0
-XX:-TraceClassUnloading
-XX:+TieredCompilation
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
-Djsse.enableSNIExtension=false
You can google idea.vmoptions optimization, there are some posts about it (and where I took my IJ config from)
From AOSP root folder,
1) First build your target. That will generate whatever java files that need to be generated during aosp build.
2) Create a shadow dir of aosp dir using lndir.
Assuming your aosp dir is ~john/work/aosp/ics.
Then create ~/john/work/aosp/icsshadow
Cd to icsshadow and invoke "lndir ../ics". That will create symlinks to everything under ics.
3) Now you use icsshadow for all the stuff your IDE needs/generates. If you use ics folder, the aosp build some times fails if the IDE generates any build artifacts.
4) cd to icsshadow directory.
Invoke development/tools/idegen/idegen.sh
Wait until it is done.
5) If you want to use IntelliJ, open android.ipr from icsshadow folder. If you want to use Eclipse, Please check Using Eclipse to edit/browse AOSP code.
Official instructions can be found by going to development/tools/idegen path and checking the README file. It's a good idea to read it yourself. This is the content for IntelliJ:
If you're using IntelliJ...
If this is your first time using IDEGen...
IDEA needs a lot of memory. Add "-Xms748m -Xmx748m" to your VM options
in "IDEA_HOME/bin/idea.vmoptions" on Linux or
"IntelliJ IDEA.app/Contents/Info.plist" on OS X.
Create a JDK configuration named "1.6 (No Libraries)" by adding a new
JDK like you normally would and then removing all of the jar entries
under the "Classpath" tab. This will ensure that you only get access to
Android's core libraries and not those from your desktop VM.
From the project's root directory...
Repeat these steps after each sync...
1) make (to produce generated .java source)
2) development/tools/idegen/idegen.sh
3) Open android.ipr in IntelliJ. If you already have the project open,
hit the sync button in IntelliJ, and it will automatically detect the
updated configuration.
If you get unexpected compilation errors from IntelliJ, try running
"Build -> Rebuild Project". Sometimes IntelliJ gets confused after the
project changes significantly.
The following error message might pop up when following the instructions.
Couldn't find idegen.jar. Please run make first.
You can fix the error message by reading here: https://www.protechtraining.com/blog/post/860?ncr=1
Run the below command from the Android source root directory.
make idegen -j4 && development/tools/idegen/idegen.sh
Then launch IntelliJ idea, and select the .ipr file generated. Then on the next screen select the .ipr based project property.
Works for me and better than using the android studio, because there is an annoying background scan all the time with the android studio.

"Conversion to Dalvik format failed with error 1" -- on export only

I know this is a repeat question but I've read and tried every solution on this site and I'm still getting the error; also, I'm getting it ONLY when I export my signed apk from Eclipse. I'm able to build and run the unsigned apk.
I have:
Deleted (and later restored) all libraries from the build path
Cleaned and rebuilt all my projects
Restarted Eclipse with -clean option
Re-create the app project from scratch
I know error 1 means I have duplicate symbols but I've checked, clean and rebuilt my build path a million times and I still get the error, only when I export.
If I had duplicate symbols, wouldn't I get an error 1 for my unsigned apk too?
If I really do have duplicate symbols, how can I get Eclipse to tell me what they are? All I get from the export wizard is a one-line error dialog. :(
I don't get any errors when I manually sign the apk, but when I install it on a phone I get a simple error: "Application not installed." :(:(
My project structure is as follows:
One Android library project with 99% of my code. It has one copy of the required jar files in the build path.
One Android app project with two classes. It references the library project via the Android tab, NOT the Java build path. There are no additional sources, projects or libraries referenced in the build path except for Android 2.1. I even re-created this project from scratch (I didn't re-created the library project because it's much bigger).
Everything was working a few days ago! Any suggestions are much appreciated!
Thanks in advance...
EDIT-UPDATE: The error goes away when I disable Proguard. Very strange.
This is an issue with Proguard in the Windows developer tools - edit Android SDK\tools\proguard\bin\Proguard.bat
Replace:
call %java_exe% -jar "%PROGUARD_HOME%"\lib\proguard.jar %*
with:
call %java_exe% -jar "%PROGUARD_HOME%"\lib\proguard.jar %1 %2 %3 %4 %5 %6 %7 %8 %9
Keep a reference to this solution because next time you update the SDK tools it'll probably be reintroduced (has been present in last few releases).
Upgrade your Proguard to its latest version i.e., 4.7...
Dowload the zip from http://sourceforge.net/projects/proguard/files/latest/download?source=files .... then copy the "lib" and "bin" folders from the zip to your sdk/tools/proguard/ to replace the default or say old "bin" and "lib" .... try exporting your project once again...
Go to project and unselect Build Automatically. Then Clean the project and Build all. Worked for me to export signed application package
This was driving me insane too. I tried everything, changed all my external libraries and so on but nothing worked. I tried a newer version of proguard without success.
Turns out I was using a library called "GridLayout" to support older devices. After I renamed the class "GridLayout" to "CustomGridLayout" it worked fine. Seems like you can't have duplicate class names.
Here was the key that worked for me
http://android.foxykeep.com/dev/fix-the-conversion-to-dalvik-format-failed-with-error-1-with-adt-14
Supposedly fixed in ADT-15, the workaround is
1) For each X_src element,right click on it and then Build Path > Remove from build path.
2) A popup will open. Make sure that “Also unlink the folder from the project” is checked and then accept it.
You can still debug into library code but you need to manage your breakpoints in those projects and then step through the code in the class file tabs.
I tried a few of the above solutions, and had no luck. Then, I closed Eclipse, and re-opened it, and was able to export successfully. If I try again however, it wouldn't work.
So, I think maybe I only get one successful export per "open" of Eclipse. Not an ideal solution by any means, but when all else fails give it a shot. It worked for me.
The accepted answer to this question (from 2011) did not work for me. However, the correct answer to this question is posted here:
Android export give a "Conversion to Dalvik format failed error1"
Unselect Build Automatically works for me. Tanks anjaneya;
0)Unselect Build Automatically
1) Clean the project
2) Build project.
3) Export Signed Application in Android Tools options.

Categories

Resources