1. Are you ready for the Galaxy S20? Here is everything we know so far!

AndroidManifest.xml not being unique in an app

Discussion in 'Android Devices' started by Joshua Martinez, Jun 14, 2017.

  1. Joshua Martinez

    Thread Starter

    I understand every application must have an AndroidManifest.xml file in its root directory that provides essential information about the app to the Android system, which the system must have before it can run any of the app's code.

    When one writes a plug-in for other applications (such as Unity3D) to do something on an Android device, they usually end up having to place the 2 files called AndroidManifest.xml and classes.jar in Assets/Plugins/Android/libs of their Unity app, but what if you already have similar files in your "libs" folder?

    For example, what if your Unity project already has "classes.jar" and "AndroidManifest.xml" due to other plug-ins being used in the app?

    What do you do in this situation?
     



    1. Download the Forums for Android™ app!


      Download

       
  2. AQSAANUM

    AQSAANUM Member

    Well... I am sorry I am also a new learner of android studio, I wanna ask you a question that why and how we write plugins ? Can you guide me ?
     
    Joshua Martinez likes this.
  3. Joshua Martinez

    Thread Starter

    I am new too, trying to learn just about enough to write a little plug-in for Unity3D to set the auto-focus on Android camera...

    I found the following links useful:
    https://docs.unity3d.com/Manual/AndroidJARPlugins.html

    https://www.thepolyglotdeveloper.com/2014/06/creating-an-android-java-plugin-for-unity3d/

    My goal is to achieve the suggestion in this post:
    https://stackoverflow.com/questions/19076316/how-to-ask-webcam-to-auto-focus-with-unity3d
     
  4. AQSAANUM

    AQSAANUM Member

    Okey You have written "but what if you already have similar files in your "libs" folder"
    You mean that the files with same names in your libs folder already, right ?
    If these are already there, try to re name your .jar and .xml file

    I am just giving you idea on my programming mental base, just check it out, if it works, other wise we will think more on it :)
     
    #4 AQSAANUM, Jun 14, 2017
    Last edited: Jun 14, 2017
    Joshua Martinez likes this.
  5. Joshua Martinez

    Thread Starter

    Actually, I just found something interesting in the link below...

    Basically it says: Unity takes the main Android Manifest; finds all the Android Manifests of your plug-ins; merges them into the main Manifest using Google’s manifmerger class; and finally modifies this one main Manifest, automatically adding permissions, configuration options, features used, and other information to the Manifest.

    https://docs.unity3d.com/Manual/android-manifest.html

    I am just not sure if this all happens every time a new Manifest is added or whether we should 'trigger' this process...
     
    Deleted User likes this.
  6. AQSAANUM

    AQSAANUM Member

    Just try it and share the result :)
     
    Joshua Martinez likes this.
  7. Joshua Martinez

    Thread Starter

    It breaks my app...
    When I run the following in Terminal:
    $ adb logcat -s Unity
    I see these error messages:
    Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.unityplugin" . . .
     
  8. Joshua Martinez

    Thread Starter

    The app runs now and the error messages are gone from the logcat.

    My C# code (Unity3D script) is basically this:

    Code (Text):
    1.  
    2. public class OcrAndroidFocus : MonoBehaviour
    3. {
    4.     /// Must be called after you have created your WebcamTexture.
    5.     public static void Focus()
    6.     {
    7.         #if UNITY_ANDROID && !UNITY_EDITOR
    8.         AndroidJavaObject androidJavaObject = new AndroidJavaObject("com.example.unityplugin.PlugInClass");
    9.         androidJavaObject.CallStatic("EnableAutofocus");
    10.         #endif
    11.     }
    12. }
    13.  
    which is called right after my WebCamTexture creation:

    Code (Text):
    1.  
    2. public void StartWebcam()
    3. {
    4.     if (!_isRunning)
    5.     {
    6.         _webCamTexture = new WebCamTexture();
    7.         OcrAndroidFocus.Focus();  // Call the JAR file...
    8.         gameObject.GetComponent<RawImage>().texture = _webCamTexture;
    9.         _webCamTexture.Play();
    10.         _isRunning = true;
    11.  
    12.         // Call only once on every webcam layout page.
    13.         // _ocrScanner.ScanOcr();
    14.  
    15.         // Call the ScanOcr method every 2 seconds.
    16.         StartCoroutine( ScanOcrAtIntervals(2f) );
    17.     }
    18. }
    19.  
    and of course the Java code in Android Studio:

    Code (Text):
    1.  
    2. package com.example.unityplugin;
    3.  
    4. import java.util.List;
    5. import android.hardware.Camera;
    6.  
    7. public class PlugInClass
    8. {
    9.     public static void EnableAutofocus()
    10.     {
    11.         Camera camera = Camera.open();
    12.         Camera.Parameters parameters = camera.getParameters();
    13.  
    14.         List<String> focusModes = parameters.getSupportedFocusModes();
    15.  
    16.         if ( focusModes.contains(Camera.Parameters.FOCUS_MODE_AUTO) )
    17.         {
    18.             parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO);
    19.             System.out.println("camera focus set");
    20.         }
    21.  
    22.         camera.setParameters(parameters);
    23.     }
    24. }
    25.  
    However, I do not see any improvement in focus, so I am guessing the camera does not focus because of this...

    My next try will be switching the auto-focus with the following:

    FOCUS_MODE_CONTINUOUS_VIDEO
    FOCUS_MODE_CONTINUOUS_PICTURE
     

Samsung Galaxy Tab S2 Forum

The Samsung Galaxy Tab S2 release date was September 2015. Features and Specs include a 8.0" inch screen, 8MP camera, 3GB RAM, Exynos 5433 processor, and 4000mAh battery.

September 2015
Release Date
0
Reviews
Loading...
Similar Threads - AndroidManifest xml being
  1. chiques
    Replies:
    3
    Views:
    635
  2. AdiA
    Replies:
    4
    Views:
    730
  3. QuantumGnosis
    Replies:
    2
    Views:
    828
  4. ozth89
    Replies:
    3
    Views:
    3,639
  5. brentc
    Replies:
    1
    Views:
    1,766
  6. FlipperTime
    Replies:
    0
    Views:
    1,199
  7. FlipperTime
    Replies:
    0
    Views:
    1,187
  8. batboy
    Replies:
    7
    Views:
    5,563
  9. Thomas Thorton
    Replies:
    0
    Views:
    1,769
  10. Mohamed13
    Replies:
    0
    Views:
    1,700

Share This Page

Loading...