- Home /
java.lang.ClassNotFoundException while running Android activity
After long fight with building project i stuck on launching android activity
logcat output:
I/Unity (20479): Welcome on Android border
I/Unity (20479): AndroidJavaException: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/testapp/androidplugin/app/SplashScreen;
I/Unity (20479): java.lang.NoClassDefFoundError: Failed resolution of: Lcom/testapp/androidplugin/app/SplashScreen;
I/Unity (20479): at com.testapp.androidplugin.app.UnityBinder.foo(UnityBinder.java:16)
I/Unity (20479): at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
I/Unity (20479): at com.unity3d.player.UnityPlayer.a(Unknown Source)
I/Unity (20479): at com.unity3d.player.UnityPlayer$b.run(Unknown Source)
I/Unity (20479): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.testapp.androidplugin.app.SplashScreen" on path: DexPathList[[zip file "/mnt/asec/com.testapp.androidplugin.app-2/base.apk"],nativeLibraryDirectories=[/mnt/asec/com.testapp.androidplugin.app-2/lib/arm, /system/lib, /vendor/lib, sy
stem/vendor/lib, system/vendor/lib/egl, system/lib/hw]]
I/Unity (20479): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
I/Unity (20479): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
I/Unity (20479): at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
First line is from Java class, so something happen...
UnityBinder.class
public static void foo(Activity activity) {
Log.i("Unity", "Welcome on Android border");
Intent myIntent = new Intent(activity, SplashScreen.class);
activity.startActivity(myIntent);
}
both classes are in the same package, I event tried with providing full path to package, but same result
if (GUI.Button(new Rect(200, 200, 400, 400), "Start"))
{
var androidJC = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
var jo = androidJC.GetStatic<AndroidJavaObject>("currentActivity");
var jc = new AndroidJavaClass("com.testapp.androidplugin.app.UnityBinder");
jc.CallStatic("foo", jo);
}
SplashScreen is extended by AppCompatActivity
I used Java decompiler to look at files structure, and SplashScreen class exists there In Plugins -> Android directory I have appcompat-v7-23.1.1.aar, design-23.1.1.aar, classes (which is from my unpacked *.aar android module), rest and assets folder.
Answer by nasha · Oct 25, 2016 at 06:34 PM
I think it requires some library on the Java library side, which also needs to be put explicitly in the unity Android plugin folder, alongside the [library] .jar ( or aar) file. It worked for me.
Could you kindly mention which library that would be. Appreciate your response. Thank you.
Hi, Please list the libraries that you pasted inside the android plugin folder. I would really appreciate if you can help me in this issue.
Answer by mm49307 · Oct 28, 2017 at 04:03 PM
You should extend android.app.Activity, rather than AppCompatActivity. bacause gradle does NOT produce a fat-jar, so that AppCompatActivity would be available in your aar/jar file. (It is only available in your gradle dependency, thus you can build your plugin inside Android Studio.)
Your answer
![](https://koobas.hobune.stream/wayback/20220612054307im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Android build crashes on start up. 2 Answers
CommandInvokationFailure: Gradle build failed. unity 2019.4.22 1 Answer
Is it possible to register android application in AndroidManifest.xml? 0 Answers
Using CustomUnityPlayerActivity, which inherits from UnityPlayerActivity, will cause problems. 0 Answers