So, the app works great in the Editor and on iOS, but no camera on Android. Here are my versions:
Unity: 5.3.4f1
Vuforia SDK: v6.2.10
Android SDK: 25.0.3
JDK: 8u144
Device: HTC Sense 6.0 with Android 4.4.4
AndroidManifest.xml settings for SDK and camera:
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="23" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-permission android:name="android.permission.CAMERA" />
Unity Project Settings:
Graphics APIs: OpenGLES2 & OpenGLES3
Min API Level: Android 4.1 (API Level 16)
Mono2x, ARMv7, External Install, External SDCard
No stripping level.
Here is an error I'm seeing on start from LogCat. I have not found this to be coming from any of our custom Android/Unity plugin calls.
08-14 16:36:35.822: I/Unity(20506): AndroidJavaException: java.lang.NoSuchMethodError: no static method with name='forName' signature='(Ljava/lang/String;)Ljava/lang/Object;' in class Ljava/lang/Class;
08-14 16:36:35.822: I/Unity(20506): java.lang.NoSuchMethodError: no static method with name='forName' signature='(Ljava/lang/String;)Ljava/lang/Object;' in class Ljava/lang/Class;
08-14 16:36:35.822: I/Unity(20506): at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
08-14 16:36:35.822: I/Unity(20506): at com.unity3d.player.UnityPlayer.a(Unknown Source)
08-14 16:36:35.822: I/Unity(20506): at com.unity3d.player.UnityPlayer$b.run(Unknown Source)
08-14 16:36:35.822: I/Unity(20506): at UnityEngine.AndroidJNISafe.CheckException () [0x00000] in <filename unknown>:0
08-14 16:36:35.822: I/Unity(20506): at UnityEngine.AndroidJNISafe.GetStaticMethodID (IntPtr clazz, System.String name, System.String sig) [0x00000] in <filename unknown>:0
08-14 16:36:35.822: I/Unity(20506): at UnityEngine._AndroidJNIHelper.GetMethodID (IntPtr jclass, System.String methodName, System.String signature, Boolean isStatic) [0x00000] in <filename unknown>:0
08-14 16:36:35.822: I/Unity(20506): at UnityEngine.AndroidJNIHelper.GetMethodID (IntPtr javaClass, System.String methodName, System.String signature, Boolean isStatic) [0x00000] in <f
Then right after the error, Vuforia says is has initialized, but the CameraDevice.Instance.IsActive() is false.
I made a copy of the project and built with Unity 5.5.2 to see if it was our Unity version with Vuforia 6.2, but same thing, no camera.
Is this a permissions thing? I've completely deleted the app and reinstalled and received zero prompts for permissions that was added in Android 6.0 (API level 23).
Any help?
The sample app runs great and our manifest is pretty much a match. I was finally able to fix the problem in our app and its working great now. It was a combination of several issues, that once we fixed one, another one would appeared. I'm adding as much info here as possible, even though unrelated to Vuforia, might be helpful for others, as this took several days to figure out and fix.
task removeBuildConfig(dependsOn: "compileReleaseSources") {
doFirst {
file("$buildDir/intermediates/classes/release/pathToFile/BuildConfig.class").delete()
}
}
dependencies {
provided fileTree(dir: 'libs', include: ['*.jar'])
}
In the end, once all of these were fixed, the original "java.lang.NoSuchMethodError: no static method with name..." error was related to incorrectly calling our android plugins from Unity. You need to make sure you use the full class namespace path:
new AndroidJavaObject("com.company.app.AndroidClassName");
I hope that this helps someone else. ;)