List
JNI DETECTED ERROR IN APPLICATION: jmethodID was NULL on Certain Android devices
Posted Date: 2025-06-11 12:32     Edited Date: 2025-06-17 8:50     Writer: info

1. SDK Version: 6.2.0
2. Development Environment: Unity-Android (Unity 6000.0.48f1)
3. Tracker/Scanner: Image Fusion Tracker in Extended Mode
4. License Type: Pro-One Time Fee 
5. Target Device: Samsung Galaxy A15, Android 14

Hard crash of the Unity Main thread immediately after asking for camera permission. The same build does not crash on some other Android devices (tested Redmi Note 9 Pro, Android 10).                                                                      

java_vm_ext.cc:591] JNI DETECTED ERROR IN APPLICATION: jmethodID was NULL
java_vm_ext.cc:591]     in call to CallVoidMethodV
java_vm_ext.cc:591]     from boolean com.unity3d.player.UnityPlayerForActivityOrService.nativeRender()
...
runtime.cc:691] Aborting thread:
runtime.cc:691] "UnityMain" prio=5 tid=5 Native
runtime.cc:691]   | group="" sCount=0 ucsCount=0 flags=0 obj=0x12c655c8 self=0xb400007923d83400
runtime.cc:691]   | sysTid=23639 nice=0 cgrp=top-app sched=0/0 handle=0x792c6cccb0
2025-06-11 14:08:56.938 23481-23639 e.terreborromeo         it.dotdotdot.expguide.terreborromeo  A  runtime.cc:691]   | state=R schedstat=( 3573431745 333554129 4349 ) utm=278 stm=78 core=6 HZ=100
runtime.cc:691]   | stack=0x792c5c9000-0x792c5cb000 stackSize=1039KB
runtime.cc:691]   | held mutexes= "abort lock" "mutator lock"(shared held)

Here is the stack trace:

[libc.so] abort 0x0000007a01f3e184
[libart.so] art::Runtime::Abort(const char *) 0x000000796158cae4
[libbase.so] $_0::__invoke(const char *) 0x0000007a04cb57d4
[libbase.so] android::base::LogMessage::~LogMessage() 0x0000007a04cb4d5c
[libart.so] art::JavaVMExt::JniAbort(const char *, const char *) 0x0000007961209710
[libart.so] art::(anonymous namespace)::ScopedCheck::AbortF(char const*, ...) (.__uniq.99033978352804627313491551960229047428) 0x00000079610ecc10
[libart.so] art::(anonymous namespace)::ScopedCheck::CheckMethodID(_jmethodID*) (.__uniq.99033978352804627313491551960229047428) 0x00000079611fa9a0
[libart.so] art::(anonymous namespace)::ScopedCheck::Check(art::ScopedObjectAccess&, bool, char const*, art::(anonymous namespace)::JniValueType*) (.__uniq.99033978352804627313491551960229047428) 0x00000079611a4404
[libart.so] art::(anonymous namespace)::CheckJNI::CheckCallArgs(art::ScopedObjectAccess&, art::(anonymous namespace)::ScopedCheck&, _JNIEnv*, _jobject*, _jclass*, _jmethodID*, art::InvokeType, art::(anonymous namespace)::VarArgs const*) (.__uniq.99033978352804627313491551960229047428) 0x00000079611f9ff4
[libart.so] art::(anonymous namespace)::CheckJNI::CallMethodV(char const*, _JNIEnv*, _jobject*, _jclass*, _jmethodID*, std::__va_list, art::Primitive::Type, art::InvokeType) (.__uniq.99033978352804627313491551960229047428) 0x00000079611f9010
[libart.so] art::(anonymous namespace)::CheckJNI::CallVoidMethodV(_JNIEnv*, _jobject*, _jmethodID*, std::__va_list) (.__uniq.99033978352804627313491551960229047428.llvm.362250457533049209) 0x000000796136984c
[libMaxstAR.so] _JNIEnv::CallVoidMethod(_jobject*, _jmethodID*, ...) 0x000000770cefd088
[libMaxstAR.so] maxstAR::ARCoreController::update(bool) 0x000000770d18ea14
[libMaxstAR.so] maxstAR::ARManager::updateTrackingState(int) 0x000000770cfb5d80
[libil2cpp.so] <unknown> 0x0000007838d54ba4
[libil2cpp.so] <unknown> 0x0000007838d57db8
[libil2cpp.so] <unknown> 0x0000007838d3fe54
[libil2cpp.so] <unknown> 0x0000007838c90c28
[libil2cpp.so] <unknown> 0x0000007838c90b74
[libunity.so] <unknown> 0x000000783cb582a4
[libunity.so] <unknown> 0x000000783cb6c6d8
[libunity.so] <unknown> 0x000000783cb77d9c
[libunity.so] <unknown> 0x000000783c97762c
[libunity.so] <unknown> 0x000000783ca54f54
[libunity.so] <unknown> 0x000000783ca54f94
[libunity.so] <unknown> 0x000000783ca55238
[libunity.so] <unknown> 0x000000783cc02f64
[libunity.so] <unknown> 0x000000783cc03eec
[libart.so] art_quick_generic_jni_trampoline 0x0000007961170634
<unknown> 0x0000000058c015d8

Unfortunately from the Android Debugger I'm not able to parse/view the arguments to CallVoidMethod to understand what is going wrong. Please let me know if and how to retrieve any more information from Android Studio to help diagnose this issue.

Posted Date: 2025-06-11 12:58     Edited Date: 2025-06-17 8:50     Writer: info

The "MAXST AR View" app from the play store does not crash however. Some of the gradle files were migrated by Unity but I don't see anything suspicious in the diff: mainTemplate.gradle:

apply plugin: 'com.android.library'
apply from: '../shared/keepUnitySymbols.gradle'
**APPLY_PLUGINS**

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.google.ar:core:1.22.0'
**DEPS**}

android {
    namespace "com.unity3d.player"
    ndkPath "**NDKPATH**"
    ndkVersion "**NDKVERSION**"

    compileSdk **APIVERSION**
    buildToolsVersion = "**BUILDTOOLS**"

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        minSdk **MINSDK**
        targetSdk **TARGETSDK**
        ndk {
            abiFilters **ABIFILTERS**
            debugSymbolLevel **DEBUGSYMBOLLEVEL**
        }
        versionCode **VERSIONCODE**
        versionName '**VERSIONNAME**'
        consumerProguardFiles 'proguard-unity.txt'**USER_PROGUARD**
**DEFAULT_CONFIG_SETUP**
    }

    lint {
        abortOnError false
    }

    androidResources {
        noCompress = **BUILTIN_NOCOMPRESS** + unityStreamingAssets.tokenize(', ')
        ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:!CVS:!thumbs.db:!picasa.ini:!*~"
    }**PACKAGING**
}

def unityProjectPath = $/file:///**DIR_UNITYPROJECT**/$.replace("\\", "/")
**IL_CPP_BUILD_SETUP**
**SOURCE_BUILD_SETUP**
**EXTERNAL_SOURCES**
gradleTemplate.properties:
android.useAndroidX=true
unityStreamingAssets=**STREAMING_ASSETS**
org.gradle.jvmargs=-Xmx**JVM_HEAP_SIZE**M
org.gradle.parallel=true

AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<!-- GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.unity3d.player" xmlns:tools="http://schemas.android.com/tools">
  <uses-feature android:name="android.hardware.camera" />
  <uses-permission android:name="android.permission.INTERNET" />
  <uses-permission android:name="android.permission.CAMERA" />
  <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
  <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
  <application>
    <meta-data android:name="com.google.ar.core" android:value="optional" />
    <activity android:name="com.unity3d.player.UnityPlayerActivity" android:theme="@style/UnityThemeSelector">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
      <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
    </activity>
    <meta-data android:name="nreal_sdk" android:value="true" />
    <meta-data android:name="com.nreal.supportDevices" android:value="NrealLight|NrealAir" />
  </application>
  <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
  <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
</manifest>