Search Unity

.jar files are not built into apk file for weird reason

Discussion in 'Android' started by thetnswe, Aug 21, 2018.

  1. thetnswe

    thetnswe

    Joined:
    Aug 23, 2010
    Posts:
    46
    I've been using Unity android with jar plugins files for more than 5 years and never had that kind of weird error before. Please someone help me.

    I've jar files which are put into Plugins->Android folder and the mainfest use custom activity which is defined in jar plugin file.

    When building into the device, it crash with class not found exception.

    Caused by: java.lang.ClassNotFoundException: Didn't find class "com.JoyDash.PlayRivals.PlayRivalsActivity" on path: DexPathList[[zip file "/data/app/com.JoyDash.TestShan-2/base.apk"],nativeLibraryDirectories=[/data/app/com.JoyDash.TestShan-2/lib/arm, /data/app/com.JoyDash.TestShan-2/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]

    Attached the project file for reproduce. I've been using the jar file for another my 10+ projects and never found that problem before. Now I created a new project and try to use that jar and it's causing that problem..

    Tested on Unity 2017 and 2018 and both failed to package the jar files into apk.
    Please download test project file below 7MB since upload a file doesn't allow that size.
    https://tinyurl.com/ya2u25qw
     
  2. TheHighGround

    TheHighGround

    Joined:
    Nov 19, 2017
    Posts:
    68
    Make sure the spelling is correct when doing

    Code (CSharp):
    1. using(var android = new AndroidJavaObject("com.my.Class")
    Something might have changed, I would start there.
     
  3. thetnswe

    thetnswe

    Joined:
    Aug 23, 2010
    Posts:
    46
    Yes.. the spelling is correct.
     
  4. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,732
    Select the .jar file in Editor and look into plugin importer settings, maybe those wrong.
     
  5. thetnswe

    thetnswe

    Joined:
    Aug 23, 2010
    Posts:
    46
    All the settings are correct. The problem is solved when I re-import old android support libraries 25.3.1 .I was using the same plugin .jar file with the latest support libraries on some projects and they were fine. It happened only on newly created projects. Don't know what happened and still don't know how to solve it yet.
     
  6. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,732
    Wait, using different version of the same jar makes it work?
    If so, then better unpack the non-working jar and see if the class in question is present there.
     
  7. thetnswe

    thetnswe

    Joined:
    Aug 23, 2010
    Posts:
    46
    No No. what I meant is using different version of android support libraries (Old libraries 25.3.1) works. plugins jar file is the same and the class is in there. I attached the non-working project which crashes. Please check it out here.
    https://tinyurl.com/ya2u25qw