- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我是一名 Android 应用程序开发人员,我遇到了以下崩溃报告的麻烦(我每天收到 5/6 的崩溃报告):
native: pc 00000000000418e0 /system/lib/libc.so (tgkill+12)
native: pc 0000000000040d59 /system/lib/libc.so (pthread_kill+32)
native: pc 000000000001c7eb /system/lib/libc.so (raise+10)
native: pc 000000000001999d /system/lib/libc.so (__libc_android_abort+34)
native: pc 0000000000017550 /system/lib/libc.so (abort+4)
native: pc 0000000000008d53 /system/lib/libcutils.so (__android_log_assert+86)
native: pc 000000000006e2c3 /system/lib/libmedia.so (_ZN7android11ClientProxy13releaseBufferEPNS_5Proxy6BufferE+94)
native: pc 000000000006c11d /system/lib/libmedia.so (_ZN7android10AudioTrack13releaseBufferEPKNS0_6BufferE+112)
native: pc 000000000006c987 /system/lib/libmedia.so (_ZN7android10AudioTrack18processAudioBufferEv+1350)
native: pc 000000000006d7f3 /system/lib/libmedia.so (_ZN7android10AudioTrack16AudioTrackThread10threadLoopEv+194)
native: pc 0000000000010079 /system/lib/libutils.so (_ZN7android6Thread11_threadLoopEPv+112)
native: pc 000000000004065b /system/lib/libc.so (_ZL15__pthread_startPv+30)
native: pc 000000000001a021 /system/lib/libc.so (__start_thread+6)
OpenSL
函数在JNI
世界中被调用。
这些是存储在堆中的所有变量:
/* OpenSL ES audio stuff */
SLObjectItf engineObject = NULL;
SLEngineItf engineEngine = NULL;
SLObjectItf outputMixObject = NULL;
SLObjectItf playerObject = NULL;
SLPlayItf playerPlay = NULL;
SLVolumeItf playerVolume = NULL;
SLAndroidSimpleBufferQueueItf playerBufferQueue = NULL;
char openSLinited = 0;
int16_t audioBuffer1[48000];
int16_t audioBuffer2[48000];
int16_t *currentAudioBuffer;
这就是我初始化所有机器的方式:
void Java_com_myapp_myappname_MyActivity_jniOpenSLInit(JNIEnv *env,
jobject thiz,
jint freq)
{
SLresult result;
// create engine
result = slCreateEngine(&engineObject, 0, NULL, 0, NULL, NULL);
assert(SL_RESULT_SUCCESS == result);
// realize the engine
result = (*engineObject)->Realize(engineObject, SL_BOOLEAN_FALSE);
assert(SL_RESULT_SUCCESS == result);
// get the engine interface, which is needed to create other objects
result = (*engineObject)->GetInterface(engineObject, SL_IID_ENGINE,
&engineEngine);
assert(SL_RESULT_SUCCESS == result);
// create output mix
result = (*engineEngine)->CreateOutputMix(engineEngine, &outputMixObject,
0, NULL, NULL);
assert(SL_RESULT_SUCCESS == result);
// realize the output mix
result = (*outputMixObject)->Realize(outputMixObject, SL_BOOLEAN_FALSE);
assert(SL_RESULT_SUCCESS == result);
SLuint32 SLfreq;
if (freq == 44100)
SLfreq = SL_SAMPLINGRATE_44_1;
else
SLfreq = SL_SAMPLINGRATE_48;
SLDataLocator_AndroidSimpleBufferQueue loc_bufq =
{SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE, 2};
SLDataFormat_PCM format_pcm = {SL_DATAFORMAT_PCM, 2, SLfreq,
SL_PCMSAMPLEFORMAT_FIXED_16,
SL_PCMSAMPLEFORMAT_FIXED_16,
SL_SPEAKER_FRONT_LEFT |
SL_SPEAKER_FRONT_RIGHT,
SL_BYTEORDER_LITTLEENDIAN};
SLDataSource audioSrc = {&loc_bufq, &format_pcm};
/* configure audio sink */
SLDataLocator_OutputMix loc_outmix = {SL_DATALOCATOR_OUTPUTMIX,
outputMixObject};
SLDataSink audioSnk = {&loc_outmix, NULL};
const SLInterfaceID idsAudioPlayer[2] = {SL_IID_BUFFERQUEUE,
SL_IID_VOLUME };
const SLboolean reqAudioPlayer[2] = {SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE };
result = (*engineEngine)->CreateAudioPlayer(engineEngine, &playerObject,
&audioSrc,
&audioSnk, 2, idsAudioPlayer,
reqAudioPlayer);
assert(SL_RESULT_SUCCESS == result);
// realize the player
result = (*playerObject)->Realize(playerObject, SL_BOOLEAN_FALSE);
assert(SL_RESULT_SUCCESS == result);
// get the play interface
result = (*playerObject)->GetInterface(playerObject, SL_IID_PLAY,
&playerPlay);
assert(SL_RESULT_SUCCESS == result);
// get the volume interface
result = (*playerObject)->GetInterface(playerObject, SL_IID_VOLUME,
&playerVolume);
assert(SL_RESULT_SUCCESS == result);
// get the buffer queue interface
result = (*playerObject)->GetInterface(playerObject, SL_IID_BUFFERQUEUE,
&playerBufferQueue);
assert(SL_RESULT_SUCCESS == result);
// register callback on the buffer queue
result = (*playerBufferQueue)->RegisterCallback(playerBufferQueue,
audio_player_cb, NULL);
assert(SL_RESULT_SUCCESS == result);
// done!
openSLinited = 1;
}
这被称为启动机器。
void openSLStart()
{
bzero(audioBuffer1, 96000);
bzero(audioBuffer2, 96000);
if (!openSLinited)
return;
(*playerBufferQueue)->Enqueue(playerBufferQueue, audioBuffer1,
4096 * 4);
(*playerBufferQueue)->Enqueue(playerBufferQueue, audioBuffer2,
4096 * 4);
currentAudioBuffer = audioBuffer1;
// set the player's state to playing
(*playerPlay)->SetPlayState(playerPlay, SL_PLAYSTATE_PLAYING);
}
这是入队新样本的回调
void audio_player_cb(SLAndroidSimpleBufferQueueItf bq, void *context)
{
if (!openSLinited)
return;
assert(bq == playerBufferQueue);
assert(NULL == context);
// switch between audio buffer 1 and 2
if (currentAudioBuffer == audioBuffer1)
currentAudioBuffer = audioBuffer2;
else
currentAudioBuffer = audioBuffer1;
// this function read samples (4096 16 bit samples) from an internal buffer
sound_read_samples(4096, currentAudioBuffer);
// feed openSL machine
(*playerBufferQueue)->Enqueue(playerBufferQueue, currentAudioBuffer,
4096 * 2);
}
最后,这就是 OpenSL 的终止方式
void Java_com_myfirm_myappname_MyActivity_jniOpenSLTerm(JNIEnv *env,
jobject thiz)
{
// shutdown every created object
if (playerObject)
{
// stop the player
SLresult result = (*playerPlay)->SetPlayState(playerPlay,
SL_PLAYSTATE_STOPPED);
if (SL_RESULT_SUCCESS == result)
utils_log("Player succesfully stopped");
(*playerObject)->Destroy(playerObject);
playerObject = NULL;
playerPlay = NULL;
}
if (outputMixObject)
{
(*outputMixObject)->Destroy(outputMixObject);
outputMixObject = NULL;
}
if (engineObject)
{
(*engineObject)->Destroy(engineObject);
engineObject = NULL;
}
openSLinited = 0;
utils_log("OpenSLTerm complete");
}
我无法在我的手机和模拟器上重现......它永远不会以这种方式崩溃。
我想不出如何解决这个问题。有人可以帮我摆脱这次崩溃吗?
10 月 8 日更新
我尝试按照建议删除日志。崩溃仍然发生。
这个问题影响到 Android 6.0、7.0 和 7.1(至少,我没有收到不同版本的报告)
10 月 9 日更新
根据 Amjad Khan 的要求:
这是生成库的Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libmyapp-jni
LOCAL_SRC_FILES := src.c src2.c src3.c
LOCAL_LDLIBS := -llog -landroid -ljnigraphics -lGLESv2 -lOpenSLES
LOCAL_CFLAGS += -O3 -DNDEBUG
include $(BUILD_SHARED_LIBRARY)
这是构建库的命令(生成所有 ABI)
/cygdrive/c/Android/ndk/ndk-build.cmd NDK_DEBUG=0 APP_BUILD_SCRIPT=./Android.mk NDK_PROJECT_PATH=.
提前谢谢你。
最佳答案
我看到的崩溃和我的崩溃是一样的,是由于android日志产生的,最近我上传了apk,发现了同样的踪迹。
native: pc 0000000000048793 /system/lib/libc.so (pthread_kill+34)
native: pc 000000000001d5d5 /system/lib/libc.so (raise+10)
native: pc 0000000000019111 /system/lib/libc.so (__libc_android_abort+34)
native: pc 0000000000017174 /system/lib/libc.so (abort+4)
native: pc 000000000000c481 /system/lib/libcutils.so (__android_log_assert+112)
native: pc 0000000000025595 /system/lib/libhwui.so
native: pc 00000000000270d1 /system/lib/libhwui.so
native: pc 000000000002b959 /system/lib/libhwui.so (_ZN7android10uirenderer12renderthread12RenderThread10threadLoopEv+80)
native: pc 000000000000e35d /system/lib/libutils.so (_ZN7android6Thread11_threadLoopEPv+140)
native: pc 000000000006830b /system/lib/libandroid_runtime.so (_ZN7android14AndroidRuntime15javaThreadShellEPv+102)
native: pc 0000000000048263 /system/lib/libc.so (_ZL15__pthread_startPv+22)
native: pc 0000000000019b5d /system/lib/libc.so (__start_thread+6)
这个回溯是我最近的更新,所以我在我的 native 文件中打印 android 日志。
__android_log_print(ANDROID_LOG_ERROR, "TRACKERS", "%s", Str);
我使用日志打印我的数据以检查我何时上传我得到了那个回溯,所以我已经删除了 native 的所有日志和从 native 调用的 java 函数。
然后,在我完成干净的构建并上传之后,所以在最新的构建中它不会生成,直到现在上传了超过 5 个构建
Android-specific log support
contains various definitions that an app can use to send log messages to the kernel from native code. For more information about these definitions, see the comments in .
You can write your own wrapper macros to access this functionality. If you wish to perform logging, your native module should link to /system/lib/liblog.so. Implement this linking by including the following line in your Android.mk file:
LOCAL_LDLIBS := -llog
在这里你会找到轻松找出原生错误的方法
关于Android 奇怪的 AudioTrack 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46403487/
我有这种来自 Google map 自动完成的奇怪行为(或者我可能错过了某事)...想法?奇怪的: 您在输入中输入某物,例如“伦敦” 您按 [ENTER] 你按下 [CLEAR] 按钮 你点击进入'输
这段代码与《Learning Java》(Oracle Press Books)一书中的代码完全一样,但它不起作用。我不明白为什么它不起作用,它应该起作用。我用 OpenJDK 和 Sun JDK 7
示例 1 中究竟发生了什么?这是如何解析的? # doesnt split on , [String]::Join(",",("aaaaa,aaaaa,aaaaa,aaaaa,aaaaa,aa
我需要获得方程式系统的解决方案。为此,我使用函数sgesv_()。 一切都很好,它使我感到解决方案的正确结果。 但是我得到一个奇怪的警告。 警告:从不兼容的指针类型传递'sgesv_'的参数3 我正在
我目前在制作动画时遇到一个奇怪的问题: [UIView animateWithDuration:3 delay:0
alert('works'); $(window).load(function () { alert('does not work'); });
我的代码: public class MyTest { public class StringSorter implements Comparator { public
我正在学习 JavaScript。尝试理解代码, function foo (){ var a = b = {name: 'Hai'}; document.write(a.name +''
这个问题不太可能帮助任何 future 的访问者;它只与一个小的地理区域、一个特定的时间点或一个非常狭窄的情况有关,这些情况并不普遍适用于互联网的全局受众。为了帮助使这个问题更广泛地适用,visit
这按预期工作: [dgorur@ted ~]$ env -i env [dgorur@ted ~]$ 这样做: [dgorur@ted ~]$ env -i which date which: no
struct BLA { int size_; int size()const{ return size_; } } int x; BLA b[ 2 ]; BLA * p = &b[
我有以下代码: #test img {vertical-align: middle;} div#test { border: 1px solid green; height: 150px; li
我想大多数使用过 C/C++ 的人都对预处理器的工作原理有一定的直觉(或多或少)。直到今天我也是这么认为的,但事实证明我的直觉是错误的。故事是这样的: 今天我尝试了一些东西,但我无法解释结果。首先考虑
我想为 TnSettings 做 mock,是的,如果通过以下方法编写代码,它就可以工作,问题是我们需要为每个案例编写 mock 代码,如果我们只 mock 一次然后执行多个案例,那么第二个将报告异常
我的项目中有以下两个结构 typedef volatile struct { unsigned char rx_buf[MAX_UART_BUF]; //Input buffer over U
Regex rx = new Regex(@"[+-]"); string[] substrings = rx.Split(expression); expression = "-9a3dcb
我的两个应用程序遇到了一个奇怪的问题。这是设置: 两个 tomcat/java 应用程序,在同一个网络中运行,连接到相同的 MS-SQL-Server。一个应用程序,恰好按顺序位于 DMZ 中可从互联
我目前正在与 Android Api Lvl 8 上的 OnLongClickListener 作斗争。 拿这段代码: this.webView.setOnLongClickListener(new
这个问题不太可能帮助任何 future 的访问者;它只与一个小的地理区域、一个特定的时间点或一个非常狭窄的情况相关,这些情况并不普遍适用于互联网的全局受众。为了帮助使这个问题更广泛地适用,visit
只是遇到了奇怪的事情。我有以下代码: -(void)ImageDownloadCompleat { [self performSelectorOnMainThread:@selector(up
我是一名优秀的程序员,十分优秀!