Unity: Failed to build apk - android

So I've tried everything I could find. It keeps showing the below. I tried replacing the tool folder (C:/Users/(My user name)/AppData/Local/Android/Sdk with a lower version. I tried replacing the entire sdk. I tried uninstalling then re-installing android studios. I really don't know what else to do. Kinda disappointing that I finally finished making an original minigame but can't build it. I've been struggling with this for the past 12 hours sigh. Thanks for your time!
Error building Player: CommandInvokationFailure: Failed to build apk. See the Console for details.
C:/Program Files/Java/jdk-9.0.1\bin\java.exe -Xmx2048M -Dcom.android.sdkmanager.toolsdir="C:/Users/dlma1/AppData/Local/Android/Sdk\tools" -Dfile.encoding=UTF8 -jar "D:\Programming\Unity\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\sdktools.jar" -
stderr[
Exception in thread "main" java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at SDKMain.main(SDKMain.java:129)
Caused by: java.lang.NoClassDefFoundError: sun/misc/BASE64Encoder
at com.android.sdklib.internal.build.SignedJarBuilder.<init>(SignedJarBuilder.java:177)
at com.android.sdklib.build.ApkBuilder.init(ApkBuilder.java:446)
at com.android.sdklib.build.ApkBuilder.<init>(ApkBuilder.java:422)
at com.android.sdklib.build.ApkBuilder.<init>(ApkBuilder.java:362)
at UnityApkBuilder.<init>(UnityApkBuilder.java:212)
at UnityApkBuilder.main(UnityApkBuilder.java:34)
... 5 more
Caused by: java.lang.ClassNotFoundException: sun.misc.BASE64Encoder
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:466)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:563)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496)
... 11 more
]
stdout[
]

According to this answer it appears that...
Java 9 removed the sun/misc/BASE64Encoder class.
A workaround is to downgrade to Java 8.

Related

Unit Tests work correctly when running but not when debugging in Android Studio 4.1

I upgraded android studio and I get this weird behaviour
when I run my unit tests they run and complete correctly (I introduced some errors to make sure it was so)
but when I put a breakpoint and use debug tests in java the jvm crashes with this error:
"C:\Program Files\Android\Android Studio4\jre\bin\java.exe" - agentlib:jdwp=transport=dt_socket,address=127.0.0.1:64493,suspend=y,server=n -ea -javaagent:C:\Users\imavrelos\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlinx\kotlinx-coroutines-core-jvm\1.3.9\4be434f5e86c1998a273e7f19a7286440894f0b0\kotlinx-coroutines-core-jvm-1.3.9.jar -Didea.test.cyclic.buffer.size=1048576 -javaagent:C:\Users\imavrelos\AppData\Local\Google\AndroidStudio4.1\groovyHotSwap\gragent.jar -javaagent:C:\Users\imavrelos\AppData\Local\Google\AndroidStudio4.1\captureAgent\debugger-agent.jar -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Android\Android Studio4\lib\idea_rt.jar" com.intellij.rt.execution.CommandLineWrapper C:\Users\imavrelos\AppData\Local\Temp\idea_classpath1657759720 com.intellij.rt.junit.JUnitStarter -ideVersion5 #w#C:\Users\imavrelos\AppData\Local\Temp\idea_working_dirs_junit.tmp #C:\Users\imavrelos\AppData\Local\Temp\idea_junit.tmp -socket64492
Connected to the target VM, address: '127.0.0.1:64493', transport: 'socket'
java.lang.NoClassDefFoundError: kotlin/collections/AbstractMutableMap
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:757)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
at java.lang.ClassLoader.loadClass(ClassLoader.java:419)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:352)
at kotlinx.coroutines.debug.internal.DebugProbesImpl.<clinit>(DebugProbesImpl.kt:30)
at kotlinx.coroutines.debug.AgentPremain.<clinit>(AgentPremain.kt:26)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:386)
at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401)
Caused by: java.lang.ClassNotFoundException: kotlin.collections.AbstractMutableMap
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:419)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:352)
... 20 more
FATAL ERROR in native method: processing of -javaagent failed
Disconnected from the target VM, address: '127.0.0.1:64493', transport: 'socket'
Process finished with exit code 1
Exception in thread "main"
has anyone got this error? any suggestions on how to fix it?
I fixed it by editing the current Run/Debug Configuration and choosing JAR Manifest in the Shorten command line option.
A similar error can also be caused by using kotlinx-coroutines-core, but it seems to depend on the IDEA version or library.
In my case, debug stopped working after updating IDEA Ultimate to version 2021.2
I fixed this error by editing the current Run/Debug Configuration and disabling the "Shorten command line" option. Before it was set to "classpath file" which seems to bring up the above error in some cases.
I wrote a unit test for a library. When running with usual Ctrl + Shift + F10 it executed, but when tried to debug the test, it didn't run with the error: 'Exception in thread "main" java.lang.NoClassDefFoundError: kotlin/collections/AbstractMutableMap'.
Then I moved the unit test to instrumentation test.
If you are facing this issue in a web-based Gradle project and you are not utilizing kotlin in your project, In that case following steps could help you out:
Check checkbox for 'disable coroutine agent'
File > Settings > Build, Execution, Deployment > Debugger > Data Views
Kotlin > Disable coroutine agent

Xamarin error: Connection to the layout renderer failed

Today when I install Xamarin to Visual Studio 2015 it write to me this:
java.lang.NoClassDefFoundError: com/android/utils/ILogger
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: com.android.utils.ILogger
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 7 more
Error: A JNI error has occurred, please check your installation and try again
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=350m; support was removed in 8.0
Exception in thread "main"
I don't know why. I have JDK 1.8 and VS2015 How can I fix it?
Thank you for every answer.

Android Studio Doesn't Start on Ubuntu

I started using Android Studio after a couple of days, Suddenly Android Studio didn't start . When I started it through terminal i.e "Studio" Command. Got the Following Error.
Java HotSpot(TM) Server VM warning: ignoring option MaxPermSize=350m; support was removed in 8.0
Start Failed: Internal Error. Please report to https://https://code.google.com/p/android/issues
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.ide.Bootstrap.main(Bootstrap.java:39)
at com.intellij.idea.Main.main(Main.java:103)
Caused by: java.lang.UnsatisfiedLinkError: /usr/lib/jvm/jdk1.8.0_91/jre/lib/i386/libawt_xawt.so: libXrender.so.1: cannot open shared object file: No such file or directory
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824)
at java.lang.Runtime.load0(Runtime.java:809)
at java.lang.System.load(System.java:1086)
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1845)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at java.awt.Toolkit$3.run(Toolkit.java:1636)
at java.awt.Toolkit$3.run(Toolkit.java:1634)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.Toolkit.loadLibraries(Toolkit.java:1633)
at java.awt.Toolkit.<clinit>(Toolkit.java:1668)
at java.awt.Cursor.<clinit>(Cursor.java:195)
at javax.swing.text.html.HTMLEditorKit.<clinit>(HTMLEditorKit.java:623)
at com.intellij.util.ui.UIUtil.<clinit>(UIUtil.java:97)
at com.intellij.ide.plugins.PluginManager.start(PluginManager.java:71)
... 6 more
Also, an UI exception occurred on attempt to show above message:
java.lang.NoClassDefFoundError: Could not initialize class java.awt.Toolkit
at java.awt.Component.<clinit>(Component.java:593)
at com.intellij.idea.Main.showMessage(Main.java:336)
at com.intellij.idea.Main.showMessage(Main.java:312)
at com.intellij.idea.Main.showMessage(Main.java:291)
at com.intellij.idea.Main.main(Main.java:106)
I have re-installed java 7 and java 8 both . Also Reinstalled Android Studio. But still there was no help.
I had installed octave before, was that a problem?
To resolve the problem you should install JDK 64bit. From the comments, you have installed 32-bit JDK
I was having the same issue. I killed the app and reopened. It fixed the issue for me.

when installing Android Studio in ubuntu 15,run studio.sh,but it report "cannot open shared object file"

I install an Android develop environment in ubuntu15,after installing JDK,and SDK tools,run studio.sh,it reports some error info:
Java HotSpot(TM) Server VM warning: ignoring option MaxPermSize=350m; support was removed in 8.0
Start Failed: Internal Error. Please report to https://code.google.com/p/android/issues
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.ide.Bootstrap.main(Bootstrap.java:39)
at com.intellij.idea.Main.main(Main.java:92)
Caused by: java.lang.UnsatisfiedLinkError: /home/xhk/java/jdk1.8.0_60/jre/lib/i386/libawt_xawt.so: libXtst.so.6:
cannot open shared object file: No such file or directory
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1938)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1821)
at java.lang.Runtime.load0(Runtime.java:809)
at java.lang.System.load(System.java:1086)
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1938)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1842)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at java.awt.Toolkit$3.run(Toolkit.java:1636)
at java.awt.Toolkit$3.run(Toolkit.java:1634)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.Toolkit.loadLibraries(Toolkit.java:1633)
at java.awt.Toolkit.<clinit>(Toolkit.java:1668)
at java.awt.Cursor.<clinit>(Cursor.java:195)
at javax.swing.text.html.HTMLEditorKit.<clinit>(HTMLEditorKit.java:623)
at com.intellij.util.ui.UIUtil.<clinit>(UIUtil.java:96)
at com.intellij.ide.plugins.PluginManager.start(PluginManager.java:72)
... 6 more
Also, an UI exception occurred on attempt to show above message:
java.lang.NoClassDefFoundError: Could not initialize class java.awt.Toolkit
at java.awt.Component.<clinit>(Component.java:593)
at com.intellij.idea.Main.showMessage(Main.java:248)
at com.intellij.idea.Main.showMessage(Main.java:234)
at com.intellij.idea.Main.showMessage(Main.java:224)
at com.intellij.idea.Main.main(Main.java:95)
but libawt_xawt.so, libXtst.so.6 have existed,PATH has been set
$ locate libawt_xawt.so
/home/xhk/java/jdk1.8.0_60/jre/lib/i386/libawt_xawt.so
$ locate libXtst.so.6
/usr/lib/x86_64-linux-gnu/libXtst.so.6
/usr/lib/x86_64-linux-gnu/libXtst.so.6.1.0
$ echo$PATH/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/xhk/java/jdk1.8.0_60/bin:/home/xhk/java/jdk1.8.0_60/jre/bin:/home/xhk/android/android-sdk-linux:/home/xhk/android/android-sdk-linux/tools:/home/xhk/android/android-sdk-linux/platform-tools
How can i fix it? o.0
You seem to have installed the 32 bit version of the java SDK as indicated by this line:
/home/xhk/java/jdk1.8.0_60/jre/lib/i386/libawt_xawt.so
But your system is a 64 bit system as indicated by these lines
/usr/lib/x86_64-linux-gnu/libXtst.so.6
/usr/lib/x86_64-linux-gnu/libXtst.so.6.1.0
There are two solutions. The first is to install the 64 bit version of the java jdk. The second is to install the 32 bit version of the libXtst
sudo apt-get install libxtst6:i386
I would prefer the first option

Intellij idea force close - Start failed error

When I'm using Intellij idea the IDE close without any error ! and when I open it again it returns this error:
Internal error. Please report to http://youtrack.jetbrains.com
com.intellij.ide.plugins.PluginManager$StartupAbortedException: java.lang.ClassNotFoundException: com.intellij.idea.MainImpl
at com.intellij.ide.plugins.PluginManager$2.run(PluginManager.java:93)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: com.intellij.idea.MainImpl
at com.intellij.util.lang.UrlClassLoader.findClass(UrlClassLoader.java:148)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:259)
at com.intellij.ide.plugins.PluginManager$2.run(PluginManager.java:86)
... 1 more
How can I resolve this? I'm using Ubuntu 14.0.4
I am using Intellij in Ubuntu too with no errors.
It's hard to say what is happening just by the information provided but I would suggest you to:
1 - Update your Ubuntu with the latest packages
2 - Download the latest version of the IDE, unpack it and try again

Categories

Resources