在包名的Andr​​oid艺术运行check_jni.cc错误 [英] android art runtime check_jni.cc error on package name

查看:1395
本文介绍了在包名的Andr​​oid艺术运行check_jni.cc错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

- EDIT--
我有共享库漂浮因暧昧的build.gradle太多的版本...

--EDIT-- i had too many versions of the shared lib floating around due to ambiguous build.gradle...

./src/main/jniLibs/armeabi-v7a/libaudioboo-native.so
rob@ app$ rm ./src/main/libs/armeabi-v7a/libaudioboo-native.so
rob@ app$ rm ./src/main/obj/local/armeabi-v7a/libaudioboo-native.so
rob@ app$ rm ./src/main/jniLibs/armeabi-v7a/libaudioboo-native.so 

解决问题, - 改变建立以下仅使用./src/main/libs的共享库

RESOLVED issue - changed build to the following to only use the shared lib in ./src/main/libs

sourceSets {
    main {
        jni.srcDirs = [] /*disable automatic ndk-build call */
        jniLibs.srcDir 'src/main/libs'
    }
}

打破了android5,所以我用它tweeking为Android工作室(1.0)NDK编译与它的工作。我扫视了code代表由答案@holo指出,所有'的findClass。注意 - 在改变的line34字符串常量从

Broke on android5 so i worked with it by tweeking it for Android-studio (1.0) ndk build. I scanned the code for all 'findClass' as pointed out by the answer @holo. Note - changed the string constant at line34 from

 "fm.audioboo.jni.FLACStreamEncoder"; to "fm/audioboo/jni/FLACStreamEncoder";

这并没有解决任何问题。

That did not solve anything.

在Java的code调用一个函数和本地函数执行之前,它看起来寿对自己的艺术框架在第二ARG使用坏字符分隔符调用的findClass(_JNIEnv *,字符常量*)。如果你看一下引擎收录链接线46- 48它看起来并不像以往任何时候都被调用本机的功能。该框架刚刚抛出坏包名的findClass错误。注意本机函数的第一行是在运行时不会达到日志语句。

The java code calls a function and before that native function executes , it looks as tho the art framework on its own is calling FindClass(_JNIEnv*, char const*) using a bad char seperator in the 2nd arg. If you look at line 46- 48 of the pastebin link it does not look like the native function is ever invoked. The framework just throws the bad package name Findclass error. Note the first line of the native function is a log statement that is not reached at runtime.

Java的层...

Java layer...

  public FLACStreamEncoder(String outfile, int sample_rate, int channels,
      int bits_per_sample)
  {
    init(outfile, sample_rate, channels, bits_per_sample);
  }

...
  native private void init(String outfile, int sample_rate, int channels,
      int bits_per_sample);

...
  static {
    System.loadLibrary("audioboo-native");
  }

CPP层...功能永远不会获取第一线的日志语句。

CPP layer ... the function never gets to first line log stmt.

extern "C" {

void
Java_fm_audioboo_jni_FLACStreamEncoder_init(JNIEnv * env, jobject obj,
    jstring outfile, jint sample_rate, jint channels, jint bits_per_sample)
{
    aj::log(ANDROID_LOG_DEBUG, LTAG, "Begin INIT extern call");
  assert(sizeof(jlong) >= sizeof(FLACStreamEncoder *));

  FLACStreamEncoder * encoder = new FLACStreamEncoder(
      aj::convert_jstring_path(env, outfile), sample_rate, channels,
      bits_per_sample);

  char const * const error = encoder->init();
  if (NULL != error) {
    delete encoder;

    aj::throwByName(env, IllegalArgumentException_classname, error);
    return;
  }

  set_encoder(env, obj, encoder);
}

一切工作使用(JNI构建/安卓打造专业化/ Android的Java调用,以CPP),直到5的Andr​​oid NDK构建10-C

Everything worked (jni build/ android buid / android-java calls to cpp) up until android 5 build using ndk 10-C

有什么新android5 / ART似乎是check_jni.cc和某种严格的模式给错误的:

what's new with android5/ART appears to be 'check_jni.cc' and some kind of strict mode giving ERROR:

D/FLACRecorder(26743): Setting up encoder /data/data/com.borneo.speech/files/20141123081747.flac rate: 22050 channels: 1 format 16
F/art     (26743): art/runtime/check_jni.cc:65] JNI DETECTED ERROR IN APPLICATION: illegal class name 'fm.audioboo.jni.FLACStreamEncoder'
F/art     (26743): art/runtime/check_jni.cc:65]     (should be of the form 'package/Class', [Lpackage/Class;' or '[[B')
F/art     (26743): art/runtime/check_jni.cc:65]     in call to FindClass
F/art     (26743): art/runtime/check_jni.cc:65]     from void fm.audioboo.jni.FLACStreamEncoder.init(java.lang.String, int, int, int)
F

全堆栈跟踪:注行46 - 48

full stacktrace: note lines 46 - 48

综观日志,它仿佛框架使用第二上做的findClass了自己的电话,thisClazz精氨酸在CPP:

Looking at the log, its as if the framework is doing its OWN call on 'findClass' using the 2nd, 'thisClazz' arg in the CPP:

Java_fm_audioboo_jni_FLACStreamEncoder_init(JNIEnv * env, jobject obj, ...  

和它的一个坏ARG值违反艺术运行时检查。

and its a bad arg value violating art runtime check.

但我没有跑'JAVAH从Java界面创建任何标题,因为这一切都已经完成之前,我得到了Git项目。

But i did not run 'javah' to create any headers from the java interface because it all had been done before i got the git project.

林难倒。天然似乎得到的函数,从未让第一行中的功能(日志statemt)上立即失败的

Im stumped. The native seems to get to the function , never getting to the first line in the function ( log statemt ) , failing immediately on the

 /system/lib/libart.so (art::CheckJNI::FindClass(_JNIEnv*, char const*)+66

NDK的(R10C)链接的CPP类,如下所示:

The ndk (R10C) linked the cpp class as follows:

make: Entering directory `/home/rob/tmp/audioboo-android/app/src/main/jni'
[armeabi-v7a] Compile thumb  : audioboo-ogg <= bitwise.c
[armeabi-v7a] Compile thumb  : audioboo-ogg <= framing.c
[armeabi-v7a] StaticLibrary  : libaudioboo-ogg.a
[armeabi-v7a] Compile thumb  : audioboo-flac <= bitmath.c
[armeabi-v7a] Compile thumb  : audioboo-flac <= bitreader.c
[armeabi-v7a] Compile thumb  : audioboo-flac <= cpu.c
[armeabi-v7a] Compile thumb  : audioboo-flac <= crc.c
[armeabi-v7a] Compile thumb  : audioboo-flac <= fixed.c
[armeabi-v7a] Compile thumb  : audioboo-flac <= float.c
[armeabi-v7a] Compile thumb  : audioboo-flac <= format.c
[armeabi-v7a] Compile thumb  : audioboo-flac <= lpc.c
[armeabi-v7a] Compile thumb  : audioboo-flac <= md5.c
[armeabi-v7a] Compile thumb  : audioboo-flac <= memory.c
[armeabi-v7a] Compile thumb  : audioboo-flac <= metadata_iterators.c
[armeabi-v7a] Compile thumb  : audioboo-flac <= metadata_object.c
[armeabi-v7a] Compile thumb  : audioboo-flac <= ogg_decoder_aspect.c
[armeabi-v7a] Compile thumb  : audioboo-flac <= ogg_encoder_aspect.c
[armeabi-v7a] Compile thumb  : audioboo-flac <= ogg_helper.c
[armeabi-v7a] Compile thumb  : audioboo-flac <= ogg_mapping.c
[armeabi-v7a] Compile thumb  : audioboo-flac <= stream_decoder.c
[armeabi-v7a] Compile thumb  : audioboo-flac <= stream_encoder.c
[armeabi-v7a] Compile thumb  : audioboo-flac <= stream_encoder_framing.c
[armeabi-v7a] Compile thumb  : audioboo-flac <= window.c
[armeabi-v7a] Compile thumb  : audioboo-flac <= bitwriter.c
[armeabi-v7a] StaticLibrary  : libaudioboo-flac.a
[armeabi-v7a] Compile++ thumb: audioboo-native <= FLACStreamEncoder.cpp
[armeabi-v7a] Compile++ thumb: audioboo-native <= FLACStreamDecoder.cpp
[armeabi-v7a] Compile++ thumb: audioboo-native <= util.cpp
[armeabi-v7a] StaticLibrary  : libstdc++.a
[armeabi-v7a] SharedLibrary  : libaudioboo-native.so
[armeabi-v7a] Install        : libaudioboo-native.so => libs/armeabi-v7a/libaudioboo-native.so
make: Leaving directory `/home/rob/tmp/audioboo-android/app/src/main/jni'

Android的加载库 audioboo本地以上NP然后抛出了

JNI DETECTED ERROR IN APPLICATION: illegal class name 'fm.audioboo.jni.FLACStreamEncoder''

这是从Java到本机功能电话,我不知道为什么?

on the call from Java to the native function and i have no idea why?

推荐答案

我已经对升级至Android 5同样的问题,以及刚刚整理了。

I've had the same problem on upgrading to Android 5, and have just sorted it.

该错误是在你的本地code,而不是在你的java code。某处在您的本地code你有被通过JNI通过了FlacStreamEn codeR对象作为jobject的函数,你像一条线检索:

The bug is in your native code, not in your java code. Somewhere in your native code you have a function that gets passed a FlacStreamEncoder object through jni as a jobject and you retrieve it with a line like:

    jclass streamEncoder = env->FindClass("fm.audioboo.jni.FLACStreamEncoder");

但JNI是应该用/作为分隔符没有,所以这行应该读。

But JNI is supposed to use "/" as a separator not ".", so this line should read:

    jclass streamEncoder = env->FindClass("fm/audioboo/jni/FLACStreamEncoder");

来代替。机器人的previous版本忽略掉这个问题,但现在它只是在你的脸上吹了吧。

instead. Previous versions of android silently ignored this problem, but now it just blows up in your face instead.

https://android.googlesource.com/platform/art/+/kitkat-dev/runtime/check_jni.cc


    // Checks that 'class_name' is a valid "fully-qualified" JNI class name, like "java/lang/Thread"
    // or "[Ljava/lang/Object;". A ClassLoader can actually normalize class names a couple of
    // times, so using "java.lang.Thread" instead of "java/lang/Thread" might work in some
    // circumstances, but this is incorrect
    void CheckClassName(const char* class_name) {
        if (!IsValidJniClassName(class_name)) {
            JniAbortF(function_name_,
                      "illegal class name '%s'\n"
                      " (should be of the form 'package/Class', [Lpackage/Class;' or '[[B')",
                      class_name);
            }
        }
    }

这篇关于在包名的Andr​​oid艺术运行check_jni.cc错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆