Error while running dx or d8 tool for Android - android

I am trying to build Android apps manually from the command line.
But, whenever I am running dx.bat command which is located inside the Android SDK build-tools directory, I am always getting an error. Whichever option I give, I always get the same error. While running dx --help, I got this error :
-Djava.ext.dirs=E:\.android\SDK\build-tools\29.0.2\lib is not supported. Use -classpath instead.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
When I had Android Studio, I didn't get any such problems. What mistake am I doing and how to get the dx.bat file to work right?

I had solved this issue by editing the dx.bat file.
As mentioned in the error
-Djava.ext.dirs=E:\.android\SDK\build-tools\29.0.2\lib is not supported. Use -classpath instead.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
I had just changed this line of the dx.bat file (last line) :
call "%java_exe%" %javaOpts% -Djava.ext.dirs="%frameworkdir%" -jar "%jarpath%" %params%
to this :
call "%java_exe%" %javaOpts% -classpath "%frameworkdir%" -jar "%jarpath%" %params%

Related

How to create a dex with D8.bat

I used to create dex file with dx.bat like this :
"c:\SDKs\android\build-tools\32.0.0\dx.bat" --dex
--output=C:\Dev\MagicFoundation\Alcinoe\Tools\AddRJavaToClassesDex\tmp\classes.dex
C:\Dev\MagicFoundation\Alcinoe\Tools\AddRJavaToClassesDex\tmp\obj.zip
How to do the same with d8.bat?
Creating DEX file using d8 can be achieved using:
d8 --output <output-folder> <input-files>
In your case, the following is an equivalent:
c:\SDKs\android\build-tools\32.0.0\d8.bat --output C:\Dev\MagicFoundation\Alcinoe\Tools\AddRJavaToClassesDex\tmp C:\Dev\MagicFoundation\Alcinoe\Tools\AddRJavaToClassesDex\tmp\obj.zip
To anyone who is using d8.bat with OpenJDK-11, if you encounter the error when running d8.bat:
-Djava.ext.dirs=${PathToAndroidSDK}\build-tools${BuildToolVersion}\lib is not supported. Use -classpath instead.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
You can edit d8.bat with a text editor, replacing the code -Djava.ext.dirs="%frameworkdir%" in last line to -classpath "%frameworkdir%" to fix the error.

-Djava.ext.dirs=[...]/Sdk/tools/lib:[...]/Sdk/tools/lib/x86_64 is not supported when starting monkeyrunner on linux

I want to run monkeyrunner but if I run mypath/Sdk/tools/bin/monkeyrunner I get:
-Djava.ext.dirs=mypath/Sdk/tools/lib:/mypath/Sdk/tools/lib/x86_64 is not supported. Use -classpath instead.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
I found some questions like this but for MacOS and Windows but none for linux.
Other questions suggest to install java 8. For me java -version showed that I was using corretto 11, so I installed corretto 8 as well (via .deb).
With find . -name '*corretto*' 2>/dev/null I found the executables as ./usr/lib/jvm/java-*-amazon-corretto/jre/bin/java. After setting
export JAVA_HOME='/usr/lib/jvm/java-1.8.0-amazon-corretto/jre'
export PATH=$JAVA_HOME/bin:$PATH
java -version shows corretto 11 and monkeyrunner can start up.
To fix the script I add those two lines before the call to java in the last line:
export JAVA_HOME='/usr/lib/jvm/java-1.8.0-amazon-corretto/jre'
export PATH=$JAVA_HOME/bin:$PATH
exec java -Xmx128M $os_opts $java_debug -Djava.ext.dirs="$frameworkdir:$swtpath" -Djava.library.path="$libdir" -Dcom.android.monkeyrunner.bindir="$progdir" -jar "$jarpath" "$#"

`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.

How to use Javah in Ubuntu14.04 for HelloNDK?

I am using Ubuntu14.04, Eclipse Luna.
I am referring Hello World Example given link
http://www.ntu.edu.sg/home/ehchua/programming/android/Android_NDK.html
My project name is HelloNDK.
My project path is /home/androiddev/workspace_luna/HelloNDK
In AndroidManifest.xml
I can see package which I use is named as: com.delta.hellondk
Android.jar which automatically added in project which is under Android 5.0.1 & its location shown as
/home/androiddev/Applications/Android_sdk/sdk/platforms/android-21/android.jar
When I use javah command, I got error.
I use following line in terminal.
javah -jni -classpath /home/androiddev/workspace_luna/HelloNDK/bin/classes/;/home/androiddev/Applications/Android_sdk/sdk/platforms/android-21/android.jar -o HelloJNI.h com.delta.hellondk
&
javah -jni -classpath /home/androiddev/workspace_luna/HelloNDK/bin/classes/JNIActivity.class;/home/androiddev/Applications/Android_sdk/sdk/platforms/android-21/android.jar -o HelloJNI.h com.delta.hellondk
when I use following command, I got error as follows:
Error: No classes were specified on the command line. Try -help.
bash: /home/androiddev/Applications/Android_sdk/sdk/platforms/android-21/android.jar: cannot execute binary file: Exec format error
Now I search lots of keywords in google, stackoverflow regarding how to generate HelloJNI.h automatically.
But i failed.
Please guide me!
I know its repeate question should be get negative vote, should be 'On Hold'. But then also i doesn’t get any clue so i asked without hesitate.

Application giving "Conversion to Dalvik format failed with error 1" error while trying to run

I have developed an android application.But when i try to run the code its shows error message
Description Resource Path Location Type
---------------------------------------------------------------------------------
Conversion to Dalvik VMSApplication Unknown Android Packaging Problem
format failed with
error 1
Has someone faced this problem before...
Thanks in advance
--
[2011-06-24 16:34:45 - VMSApplication] Dx at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:242)
[2011-06-24 16:34:45 - VMSApplication] Dx at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
[2011-06-24 16:34:46 - VMSApplication] Dx 1 error; aborting
[2011-06-24 16:34:46 - VMSApplication] Conversion to Dalvik format failed with error 1
You don't say what version of the android SDK you are running or what platform. You might try this solution for Windows 7 Solution:
Confirmed the problem is caused by ProGuard command line in the file
[Android SDK Installation Directory]\tools\proguard\bin\proguard.bat
Edit the following line will solve the problem:
call %java_exe% -jar "%PROGUARD_HOME%"\lib\proguard.jar %*
to
call %java_exe% -jar "%PROGUARD_HOME%"\lib\proguard.jar %1 %2 %3 %4 %5 %6 %7 %8 %9
One solution could be to clean and restart the eclipse,this may help.Also check out these links link1 and link2
I got that error because I was trying to build when connected to emulator

Categories

Resources