Search Unity

Android - Non main activity plugin not working: Class Not Found Exception

Discussion in 'Android' started by Augality, Dec 27, 2014.

  1. Augality

    Augality

    Joined:
    Aug 4, 2014
    Posts:
    14
    Hi everyone

    I'm struggling to make my plugin work for Android devices. I'm trying to make an Android plugin that recognizes iBeacons.
    I use a open source library for that. But when the app is build and run, it won't recognize it.
    Keep in mind this is NOT the main activity, because I already use a plugin that is set as main in the manifest.

    So, how did i make my plugin? I used eclipse and set the project as library so it would make a .jar file when it builds.
    In the 1st attached image you can see the project setup. Don't mind the closed projects.
    In the 2th one, you can see I ticked 'Is Library'.

    Afterwards, I placed the plugins (my .jar file and the one from proximitykit) in: Assets/Plugins/Android. This can be viewed in the 3th image I attached. In code I tried to start the activity. (.cs file in the .rar attachment)

    Last, I added the activity to the AndroidManifest as following:
    Code (CSharp):
    1. <activity android:name="com.kristofvdh.ibeacon.BeaconScanActivity" />
    When I build and run the application, the app won't recognize my class created in the plugin. (image 4)

    I have read that you could create a build with ant, but ant cannot find my proximitykit packages. (this image is inside the rar, because I can only attach 5 files)
    So if someone could please help me make this work, because I am a bit stuck.
    I tried allot of things, searched all over the internet, but cannot make my app work with multiple plugins (activities).

    Thanks in advance!
     

    Attached Files:

  2. Augality

    Augality

    Joined:
    Aug 4, 2014
    Posts:
    14
    Is there anyone that can help me, please? I'm still struggling. :s
     
  3. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,167
    I would assume something is wrong with the manifest.

    First of all, if you are building a plugin as a library, the recommended way is to copy the entire project folder into Plugins/Android/your_library_name/ (including built jar in bin/) - this ensures you get the manifest and resources merged correctly.

    Then, doublecheck your manifest. The one that you put in Plugins/Android completely overrides Unity manifest - is that what you expect?

    Please read this once again carefully: http://docs.unity3d.com/Manual/PluginsForAndroid.html
     
    JohnTube likes this.
  4. Augality

    Augality

    Joined:
    Aug 4, 2014
    Posts:
    14
    Hi Yury

    Thanks for the info. I looked into the manifest, but I don't think that was the problem. After some more research, I could make it work (or at least let the unity app find my plugin class)
    The problem was the way I created the .jar file. I fixed my ant build script to create the right .jar file.

    I the attachments you can find the ant build file I used.
    Now I got a new problem. Following error is shown in logcat: Exception: JNI: init'd AndroidJavaObject with null ptr! (Image in attachments)

    I'll read the plugins page again, maybe I missed something.
    I hope to find this problem as well. If someone has an idea, please let me know.

    Thanks!
     

    Attached Files:

    Last edited: Jan 14, 2015
  5. Augality

    Augality

    Joined:
    Aug 4, 2014
    Posts:
    14
    Ok, I found what the problem was.
    It was the static instance of that class that caused the exception.

    I removed it from the unity script and now it runs without errors. (maybe I have to use it again later, but for now it's fine)
    HOWEVER, it seems that the activity has an invisible layer in front of the unity activity, because my touch inputs won't work anymore.

    I'll just create a new thread for it. It'll be easier and faster to find or get an answer.
    Thanks.

    P.S.:
    Click here for the new thread.
     
    Last edited: Feb 2, 2015