dx command error even when path is set - android

I want to use dx tool. So I use the following command in terminal
dx --dex --output=classes.dex sample.jar
and I got this error
No such file or directory
I know i should set environment variable "path" and add /build-tools/x.y.z/dx to it. But even set the path doesn't resolve the error. I should mention that I can run it from /build-tools/x.y.z/ by running the command
./dx
but i need to access dx from any directory, for my project purpose. I use ubuntu 14.04 64 bit. How can I fix it?

Related

ANDROID_SDK_ROOT when setting up cocos2dx 3.17.2

I'm trying to set up cocos 2dx on my mac. When I type in python setup.py it prompts for NDK_ROOT and there is no issue (the root is "/Applications/android-ndk-r20/"). But when I put in the SDK_ROOT ("/Applications/") I get the following error:
Error: "/Applications/" is not a valid path of ANDROID_SDK_ROOT. Ignoring it.
I tried moving SDK into its own directory (so the path is /Applications/SDK) but that didn't work either.
Any ideas?

Ar toolkit nftBook with android studio

How to solve artoolkit nftBook issues in android studio
When I run the command ndk-build in android studio terminal for nft book it shows the error like:
clang++.exe: error: linker command failed with exit code 1 (use -v to
see invocation) make: *** [obj/local/armeabi/libnftBookNative.so]
Error 1
How can I solve this?
You should not run it in the android studio terminal but in the Git-Bash.
Read the documentation more closely :).
You look like you are working from Windows so you need to use Git-Bash for compilation.
See: http://artoolkit.org/community/forums/viewtopic.php?f=26&t=17092
===========
EDIT:
Make sure you have these environment variables set:
- Set ANDROID_HOME to indicate the path to root folder of the downloaded Android SDK.
Set ANDROID_NDK_ROOT to indicate the path to root folder (most likely, “ndk-bundle”) of the downloaded NDK. The ANDROID_HOME environment variable can be used to help define NDK.
ANDROID_NDK_ROOT=$ANDROID_HOME/ndk-bundle
Set NDK to the same path as ANDROID_NDK_ROOT. NDK=$ANDROID_NDK_ROOT
Set PATH to include a path to the ndk-build[.cmd] script file, that is, the path to the root folder of the NDK. The NDK environment variable can be used to help define the added path.
Now start gitBash and navigate to your ARToolKit5_ROOT directory.
cd android
./build.sh
if successful
./build_native_examples.sh

How can locate aapt from the terminal

I have been running the command aapt list -a on an APK file but i keep having the error:
appt command not found.
I have check the Android-SDKs built-tools and the aapt file exist in the location.
Please, what do i need to do to fix that?
You need to set path.
Go to system properties -->Environment variables -->New/Edit "PATH"
Add C:\\AppData\Local\Android\android-sdk\platform-tools
Refer How to Add set path

Dalvik VM Invocation issue

I am trying to create a simple JAR file like here and execute it in the shell. i am stuck on this line
dx --dex --output=foo.jar Foo.class
when i execute this line in CMD . I am always getting an error like this
trouble processing:
class name (com/delvix2/Foo) does not match path (C:/somepathhere/classes/com/delvix2/Foo.class)
...while parsing C:/somepathhere/classes/com/delvix2/Foo.class
...while processing C:/somepathhere/classes/com/delvix2/Foo.class
1 warning
no classfiles specified
How can I fix this issue?
This works for me.
dx --dex --output="full path to dex file\file.dex" "c:\.....path to folder which contains the class file only"
First path : full path to dex file including the name of the dex file you want
Second path : Path to a folder which contains "ONLY" your .class file.
(Just give the path up to the folder, don't give the class file name)
It looks like dx expects that the relative path of the class that you give it will match it's package. Try this instead:
cd c:/somepathhere/classes
dx --dex --output=foo.jar com/delvix2/Foo.class
Use the --no-strict option:
dx --dex --no-strict --output=foo.jar Foo.class
It must be in your case
dx --dex --output=C:\classes.dex C:\temp\Foo.jar
and then you must use
aapt add C:\temp\Foo.jar C:\classes.dex
I hope it will be work
I tried all this, and did not work. There's something that worked for me, and it was to put your classes in \sdk-path\platforms-tools\. For example,
C:\sdk-path\platforms-tools\dx --dex --output=class.dex com\mypack\app\myclass.class
And myclass.class lives in,
C:\sdk-path\platforms-tools\com\mypack\app\myclass.class
This is crappy, but the only thing that worked.

aapt not working with absolute path

I have a kind of strange issue. In my bash script or Makefile, using aapt with absolute path does not work but if I am in the local directory it does.
If I do the following, it does not work:
aapt add $OUT/device.jar $OUT/classes.dex
The command does run and print this output:
'/homes/rsevile/CS307/bin/Device/classes.dex'...
But when trying to load the jar, the class that I am trying to load end up being not found.
The following does work though:
cd $OUT
aapt add device.jar classes.dex
Printing:
'classes.dex'...
This is the whole code being executed in the script (which works):
javac -d $(OUT)/classes -classpath ./layoutlib.jar src/com/device/client/*.java
jar cf $(OUT)/device.jar $(OUT)/classes $(OUT)/layoutlib
dx --dex --no-strict --output=$OUT/classes.dex $OUT/device.jar
cd $OUT
aapt add device.jar classes.dex
cd $ROOT
adb push $OUT/device.jar $ANDROID_OUT_DIR
I am confused why my class ends up being not found when using an absolute path with aapt.
Could anyone please explain to me why it is not working and how I could fix it to use a proper absolute path please?
Thank you.
I realized that aapt actually keeps the absolute path, there is no way around it.
I fixed the problem by reusing jar and using the -C option that lets me specify a directory.

Categories

Resources