Flutter App Crashes and build is not working - android

I'm getting this errors while building my app on my phone:
Note: C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_core-0.7.0\android\src\main\java\io\flutter\plugins\firebase\core\FlutterFirebaseCorePlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\src\flutter.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.16.0+1\android\src\main\java\io\flutter\plugins\firebase\firestore\FlutterFirebaseFirestorePlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\src\flutter.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.16.0+1\android\src\main\java\io\flutter\plugins\firebase\firestore\streamhandler\TransactionStreamHandler.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: C:\src\flutter.pub-cache\hosted\pub.dartlang.org\firebase_auth-0.20.1\android\src\main\java\io\flutter\plugins\firebase\auth\FlutterFirebaseAuthPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\src\flutter.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.16.0+1\android\src\main\java\io\flutter\plugins\firebase\firestore\streamhandler\TransactionStreamHandler.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: C:\src\flutter.pub-cache\hosted\pub.dartlang.org\firebase_auth-0.20.1\android\src\main\java\io\flutter\plugins\firebase\auth\FlutterFirebaseAuthPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
C:\src\flutter.pub-cache\hosted\pub.dartlang.org\firebase_storage-7.0.0\android\src\main\java\io\flutter\plugins\firebase\storage\FlutterFirebaseStoragePlugin.java:38: warning: [deprecation] Registrar in PluginRegistry has been deprecated
And some of this errors that I don't have no ideia what it is:
F/crashpad(30196): h]muV<t+'tiXDVC.K{oRjQjZV|?.yra=Z_VMq:+iEM]hz^Iv*oR>.mI+N1$45wp\Rn<-pqe(\t%)gvG6s56\\6"R[Aar"7RVh=Zv)*&tFKn6gh2(gaO)du}BbgIF+#~Ytc=Ls+"f.#Y[Ti}d,pVLi7.x<=rwrAag(b97rV*vN#"wjWe5&tDCYeX]FWJ>hMGW4s4M%?~\Swg6#LX.(.Nt%swbHyjg|[\e;jzm;LiV7tR6LZigPujaaKn8_96p&L^qV$a6XmlSxyo)Bwlz'%EqT=qdDE!b2eRRFWFDKLZN0mvKGq{op)~qO8&t^sPk,w$oHu(H#cx;&EXr>(jgb2Uv~xjgpe,K4ly53V#We}*2&tZ^5v\,=hTKaw1V*v'lA8WX*vyG4p:666/wUo:6+b>_tk3b+(afg68Y"t\+L.=G/0*W*vQ5AwT.S|\w>3jgtsxSwigkmNLMzjvCwKw0L'r%gK1HuPL.&eSNKLJVrJ&m76.dtKAJopVvkp,Z"m4U
F/crashpad(30196): \A]qXYg;J6sqwrZ/!<XThv091a2Uvdg,ZVwBSK8SLzKY:Hup)\twd"x?ls~Y/iVvTHs~s2bVF1khhvFP;{J0vB&R:kuUwV=NY,W'S37d^jV36-VnVDVhhuL=5mrF:nML,wtm[u<gAI?g87QkH!r%kwV"~;xVxwuZ{vYfuTwlxfIHVnC|l-<c4"bpamW$3rXhmNGB\mgBCe4E~dJev<Zez+W&dl6/Z"T]JbZnN#'U%5LTn#=a.]VruehE>)l3j+#H#B\K't#)XAs/eL,v$70UPWww4D<9+ibRTCY[MxIvRrZ=LL35A["R1o)Xyo&Ck|n+wqf44/"wZu,J/a3/Jfde;t4DN#~el)1v#sR<7Mc{;tcI7WG*jfTq?+PLubGr<&yKcWz(OFrZn(~JtdRndaiL/x9T[ASEfT4Ea,h&DAhXiVhhCW=9a1<\:>;/#vjpqy#L}qS]v*54_3-(VLnPx5%sn#kM}eR^9^foA:suSm^4[JJYfzsphqur2, F/crashpad(30196): D#%?G7;q0Unvu=#4d_3kn^}-CD]dtsT6p5Q*GIuqzt$wRKEvu)e,3%G+vasZ(On$b,Z~e*&bo$bd>YeX]$b6[\cyve#Qj^hyG5&$Zba4)h%ld<LDOr4H5-m6p};4_Z/PHJjLi\A^b%G;v?WpbQ*x(mAg1ZGd2"rZ?Rv(rrrL'%EqR,<ghu$,n8qv3W"xy2Mrj%bN_N(&)v|h\y{lj%u]7bN[ccuzg{O%G7pyd>v9W(+)V2rjirva.BrbpGqzm)wis$6^D*m7^IpTOg8#45wur,Y=es81km0MCTQ7(s\1;/%bDrxy#CxKpgV0)V^QJ6~}waTOD#5--]gN2N5r$bzm~+3,J`rvCOj2Ql_)L3KWgPLQ^bZ(n~D'E9KF|+LTUHq2maCgo>sDf]t|WjgyotoO"}5~+z>&E:B%<RLU]9S]QtoOteUT6O:!S/j9L:QQ#K<#5ZhaEDZ#q]r?WG)5benx],q)b(I<Lm3KgN="O]}fhWQ:(w:AEuFwYwccgC
x4 0000000000000000 x5 0000000000000000 x6 716e7362646b6452 x7 7f7f7f7f7f7f7f7f
x8 0101010101010101 x9 0000007b7394d000 x10 000000740003dc08 x11 0000000000000001
x12 0000000000000000 x13 0000000000000000 x14 4b3d092f234ec266 x15 cae6c696f68e9634
x16 0000007b77c960f0 x17 0000007c50c31a60 x18 0000007c54ba4000 x19 0000000000000003
x20 0000000000000000 x21 000000740001fe00 x22 0000007ffc3baf38 x23 000000740003dc08
x24 000000740003dc18 x25 0000000000000000 x26 0000007ffc3bb1d0 x27 0000000000000000
x28 00000074000b81a0 x29 0000007ffc3bae90
sp 0000007ffc3bae60 lr 0000007b76c219dc pc 0000007b76c219dc
backtrace:
#00 pc 00000000034529dc /data/app/com.google.android.webview-s_lG60oSwnCYO90hX8X4lw==/base.apk!libmonochrome.so (offset 0x2d3000) (BuildId: 95f822edbc9f6b7eae5123e2b88ce8cf430204b4)
Lost connection to device.
Exited (sigterm)

As it is mentioned in the Flutter docs, that one should avoid installing Flutter in a directory like C: as it requires elevated administrator privileges sometimes. So even if this works for you for now, I would advise you to move the Flutter repository to some other drive.
Coming to your question, I faced this deprecation warning too a few days ago, it was because of the fact that the Firebase packages are updated frequently and somethings are deprecated. Please use the latest version of Firebase Core, it resolved the problem for me.

Welcome to SOF.
Seems WebView has problems and caused apps like GMail and Flutter built apps to crash, Google fixed it, please update these two:
https://play.google.com/store/apps/details?id=com.android.chrome
https://play.google.com/store/apps/details?id=com.google.android.webview

Related

game crashes after unity splash screen - cannot find stacktrace in logs

Please note: I'm not a professional developer and will probably need more detailed instructions on how to get needed information
I am working on a mobile game, currently called EndlessTD using Unity3d 2022.2.4f1. during testing, it used to work fine on bluestacks and in my Mi9T pro running MIUI 12.5.1 and android 11.
Developer options are active, the phone is connected to my pc via usb and displaying "USB debugging is on".
While it still works without errors in the editor on my windows machine, apparently, I screwed something up and now the game crashes right after the unity splash screen when it should load my scene.
Crash Log:
01-29 02:23:27.465 2748 2796 E CRASH : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
01-29 02:23:27.465 2748 2796 E CRASH : Version '2022.2.3f1 (55531d7fa82e)', Build type 'Release', Scripting Backend 'il2cpp', CPU 'arm64-v8a'
01-29 02:23:27.465 2748 2796 E CRASH : Build fingerprint: 'Xiaomi/raphael_eea/raphael:11/RKQ1.200826.002/V12.5.1.0.RFKEUXM:user/release-keys'
01-29 02:23:27.465 2748 2796 E CRASH : Revision: '0'
01-29 02:23:27.465 2748 2796 E CRASH : ABI: 'arm64'
01-29 02:23:27.465 2748 2796 E CRASH : Timestamp: 2023-01-29 02:23:27.465468704+0100
01-29 02:23:27.465 2748 2796 E CRASH : pid: 2748, tid: 2796, name: UnityMain >>> com.EndlessRageLimited.EndlessTD <<<
01-29 02:23:27.465 2748 2796 E CRASH : uid: 10467
01-29 02:23:27.465 2748 2796 E CRASH : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr --------
01-29 02:23:27.465 2748 2796 E CRASH : Cause: null pointer dereference
01-29 02:23:27.465 2748 2796 E CRASH : x0 0000006ff01b7d30 x1 0000000000000000 x2 0000000000000000 x3 00000070175dcad0
01-29 02:23:27.465 2748 2796 E CRASH : x4 00000000000002ae x5 00000070175dcad0 x6 00000000000003e9 x7 000000000000004d
01-29 02:23:27.465 2748 2796 E CRASH : x8 0000000000000000 x9 8000000000000000 x10 8000000000000000 x11 0000000000000000
01-29 02:23:27.465 2748 2796 E CRASH : x12 0000000000000001 x13 ffffffffffe00000 x14 fffffc00001fffff x15 0000000000000000
01-29 02:23:27.465 2748 2796 E CRASH : x16 0000000000000001 x17 0000000000000000 x18 0000006fd1d7b638 x19 0000006ff01b7d30
01-29 02:23:27.465 2748 2796 E CRASH : x20 0000000000000000 x21 00000070185b1000 x22 0000006fd23111f8 x23 0000000000000000
01-29 02:23:27.465 2748 2796 E CRASH : x24 0000007015202000 x25 0000000000000000 x26 0000007015202000 x27 0000006f21abd610
01-29 02:23:27.465 2748 2796 E CRASH : x28 0000000000000001 x29 00000070151ffdd0
01-29 02:23:27.465 2748 2796 E CRASH : lr 0000007017a330b8 sp 00000070151ffd20 pc 0000000000000000 pst 00000000a0000000
My usual build settings:
Since this is my first time dealing with this, I am quite lost:
I recently upgraded unity from 2022.2.3f1 to 2022.2.4f1 so I tried using 2022.2.3f1 again, but the error persists. Unity editor version doesnt seem to be the issue.
Since the game is already on google play using an internal testing track, I found reports under Testing -> Pre-launch report -> Details -> stability -> Crashes and ANRs.
Sadly, stack traces are "Fatal AndroidRuntime Exception detected." and "Native crash of com.EndlessRageLimited.EndlessTD".
I'm not sure what to do with that information.
So more digging and it seems from the posts on the internet, people usually have a stack trace or backtrace. I dont and I dont understand why.
In the log file, there are multiple messages about not being able to load the debugger:
.android.camer: Not starting debugger since process cannot load the jdwp agent.
Here on StackOverflow, it was recommended to execute adb reverse tcp:8081 tcp:8081
but this didnt change anything.
Another website recommended to enable Wait for debugger in developer options, but this option is greyed out for me.
Other posts on StackOverflow and other pages didnt help me to find a solution either. Did I miss anything?
What I perceive as the relevant output from adb logcat in command prompt is available here. If I interpret it correctly, it starts when the app launches.
I now managed to get a stacktrace using Run device and Build to device, hitting Patch and Run with Development Build, Autoconnect Profiler, Deep Profiling Support and Script debugging enabled.
The stack trace is available here
Sadly, I cannot find any specific information on why it crashes.
After stubeling on the stacktrace utility and adding symbols for il2cpp and mono, I end up with this resolved stacktrace here .
Would somebody please have some tips on what I can do to get more information on why the game crashes? Since the last test on a phone I got like 30 commits and rolling back would mean reapplying several days of work :S
Thanks!!!
after going back and forth in my git history, I decided to git clean -fdx to see if something on my computers side got messed up. miraculously this did indeed "fix" the issue.
While I still don't know what caused the problem, at least I dipped my feet into debugging android games using Unity and learned something new :)

libc.so crash on Android 12 devices

I found a strange crash message about the system so library on the APM platform, and it only happens on Android 12 devices.
Some of my app build gradle config:
compileSdkVersion 31
buildToolsVersion '31.0.0'
defaultConfig {
minSdkVersion 24
targetSdkVersion 26
ndk {
abiFilters 'armeabi-v7a', 'arm64-v8a'
}
}
And below is the crash message:
Process Name: 'xxx'
Thread Name: 'ReferenceQueueD'
pid: 29245, tid: 29254 >>> com.xxx.xxxx <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00fffffefffffff0
x0 00000070a0f4a6c0 x1 00ffffff00000000 x2 0000000000000000 x3 0000000000000000
x4 0000000000000010 x5 0000006ded2d4340 x6 0003522200034d82 x7 00034dcc00035472
x8 02ffffff00000000 x9 02ffffff00000000 x10 00000000ecc30e2f x11 0000000000000000
x12 0000000000000019 x13 000009f3ba83fe32 x14 00106e6d9f58a32d x15 0000000034155555
x16 00000070803f9248 x17 00000070a0eb2c00 x18 0000006d758cc000 x19 00ffffff00000000
x20 0000000000000000 x21 00000070a0f4a6c0 x22 0000000000000000 x23 0000000014f28e78
x24 000000006f7aaba0 x25 0000000014f28eb8 x26 0000000000000000 x27 0000006de9217000
x28 0000000000000043 x29 0000006d7631b6e0 x30 00000070806b0cd0
sp 0000006d7631b6d0 pc 00000070a0eb8668 pstate 0000000060001000
v0 0000518400006498000050f0000035e9 v1 000030ff000055ff000052d100004c9a
v2 00000000001c30000000006dd3dca000 v3 00000000000001000000000000000100
v4 00000000000221c00000000000022180 v5 0000221c000022180000221400002210
v6 00000000000000000000000000000000 v7 00000000000000008060180680601806
v8 00000000000000000000000000000000 v9 00000000000000000000000000000000
v10 00000000000000000000000000000000 v11 00000000000000000000000000000000
v12 00000000000000000000000000000000 v13 00000000000000000000000000000000
v14 00000000000000000000000000000000 v15 00000000000000000000000000000000
v16 c0300c03c0300c03c0300c03c0300c03 v17 00000000000800000000080001000404
v18 00000000000000000000080000000000 v19 0000000000000000be00000000000000
v20 00000000000000003ff0002b8b263fc3 v21 00000000000001480000000000000001
v22 00000000000000380000000000000001 v23 00000000000002000000000000000001
v24 00000000000000800000000000000001 v25 00000000000001100000000000000001
v26 00000000000001800000000000000001 v27 00000000000000b80000000000000001
v28 00000000000000000000000300000001 v29 000000000000000c0000000000000002
v30 00000000000000080000000000000002 v31 006d005f00790061006c00650064005f
fpsr 00000010 fpcr 00000000
#00 pc 0000000000006668 /apex/com.android.runtime/lib64/bionic/libc.so (_ZN5scudo9AllocatorINS_13AndroidConfigEXadL_Z21scudo_malloc_postinitEEE10deallocateEPvNS_5Chunk6OriginEmm+104)
#01 pc 0000000000121ccc /apex/com.android.i18n/lib64/libicui18n.so (_ZN6icu_6812RegexPattern3zapEv+216)
--- --- --- ---
This crash has not yet been reproduced on my test devices.It has been bothering me for a long time, I can't find relevant information on Google, and I am very eager for any relevant help.
The problem is because it tried to access an illegal memory address (address 00fffffefffffff0). It's illegal because that address isn't mapped to a valid space in virtual memory. It's occurring in some memory management code- notice the function name says malloc_postinit (malloc is the C function to request memory) dealocateChunk.
So either the C standard library has a bug in it (unlikely but possible), or somehow the memory of the allocation table got corrupted. Which can happen if C code overwrites its bounds or if an already deallocated chunk of memory is written to by mistake. Or a few hardware causes (RAM failure, cosmic rays, etc). Unless you can reliably reproduce it, you're not going to solve it. If you can reproduce it, try to figure out what the corrupted memory was holding and look for illegal access to it. A memory watch would work for that. But really these kinds of problems are incredibly hard to track, especially when not writing C or C++ yourself, as the illegal access is likely occurring far from your code.

SIGABRT when exception is thrown from .so in Android when 3rd party lib is used statically

I have a native Android, SDK style library which depends on OpenCV.
In order to avoid conflict when a user uses the library and their own usage with OpenCV, I want to compile OpenCV statically into my library and hide its symbols.
I compiled OpenCV (3.4.13 world module) statically and used it, along with its 3rd party libraries in my library.
When I try and use my library, and it throws an exception, even if the exception is caught by the user, a SIGABRT is causing the app to terminate.
This is the stack trace from the logcat
A/libc: Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 24115 (.test), pid 24115 (.test)
...
A/DEBUG: backtrace:
A/DEBUG: #00 pc 0000000000051948 /apex/com.android.runtime/lib64/bionic/libc.so (abort+168) (BuildId: 931371c1098ffd5adc489b9ff4da8e82)
A/DEBUG: #01 pc 00000000000b2ba0 /data/app/~~gc4ZOfzcr7C0hRfmsieCtQ==/com.example.test-sx2ESCfGCsi3lXPZWnk9nA==/base.apk!libc++_shared.so (BuildId: ece72a2ebc3774a1be9fd21271258acd3bcdfaa7)
A/DEBUG: #02 pc 00000000000aec8c /data/app/~~gc4ZOfzcr7C0hRfmsieCtQ==/com.example.test-sx2ESCfGCsi3lXPZWnk9nA==/base.apk!libc++_shared.so (__gxx_personality_v0+348) (BuildId: ece72a2ebc3774a1be9fd21271258acd3bcdfaa7)
A/DEBUG: #03 pc 00000000004dd2dc /data/app/~~gc4ZOfzcr7C0hRfmsieCtQ==/com.example.test-sx2ESCfGCsi3lXPZWnk9nA==/base.apk!libmylib.so (BuildId: 790f2880373cb985055ab9b7b2efc48b1afb82fd)
A/DEBUG: #04 pc 00000000004dd7e4 /data/app/~~gc4ZOfzcr7C0hRfmsieCtQ==/com.example.test-sx2ESCfGCsi3lXPZWnk9nA==/base.apk!libmylib.so (BuildId: 790f2880373cb985055ab9b7b2efc48b1afb82fd)
A/DEBUG: #05 pc 0000000000170600 /data/app/~~gc4ZOfzcr7C0hRfmsieCtQ==/com.example.test-sx2ESCfGCsi3lXPZWnk9nA==/base.apk!libmylib.so (mylib::TestClass::TestClass(char const*, char const*)+908) (BuildId: 790f2880373cb985055ab9b7b2efc48b1afb82fd)
A/DEBUG: #06 pc 000000000000c5d0 /data/app/~~gc4ZOfzcr7C0hRfmsieCtQ==/com.example.test-sx2ESCfGCsi3lXPZWnk9nA==/base.apk!libJnilibrary.so (BuildId: 7f3605ea8cb95dc87864e3df22f6b77b46c2e592)
A/DEBUG: #07 pc 000000000000c3b8 /data/app/~~gc4ZOfzcr7C0hRfmsieCtQ==/com.example.test-sx2ESCfGCsi3lXPZWnk9nA==/base.apk!libJnilibrary.so (BuildId: 7f3605ea8cb95dc87864e3df22f6b77b46c2e592)
A/DEBUG: #08 pc 000000000000c308 /data/app/~~gc4ZOfzcr7C0hRfmsieCtQ==/com.example.test-sx2ESCfGCsi3lXPZWnk9nA==/base.apk!libJnilibrary.so (Java_com_example_lib_Engine_cxxInit+56) (BuildId: 7f3605ea8cb95dc87864e3df22f6b77b46c2e592)
A/DEBUG: #09 pc 00000000002d7644 /apex/com.android.art/lib64/libart.so (art_quick_generic_jni_trampoline+148) (BuildId: 2b417e2566f5eb686666666b6ee952ea)
(It also happens if the JNI library uses c++_static, but in that case the __gxx_personality_v0 and 1 above it come from the libJnilibrary.so)
If I compile OpenCV as a shared library and link my library against it, then everything works fine.
I've had issues with exceptions in my library before, see this question I asked. I solved it by compiling everything using c++_static STL. The problem looks similar to this, and indeed I was missing the key function, but even after adding it, the problem keeps happening.
I looked at the symbols using llvm-readelf -CWs and noticed that when OpenCV is linked dynamically, in addition to OpenCV symbols, the output contains some ndk and cxxabi symbols which doesn't exist when OpenCV is used statically. I don't know if it's related at all but for example
110: 0000000000000000 0 FUNC GLOBAL DEFAULT UND std::uncaught_exception()
...
201: 0000000000000000 0 OBJECT GLOBAL DEFAULT UND vtable for __cxxabiv1::__vmi_class_type_info
...
231: 0000000000000000 0 FUNC GLOBAL DEFAULT UND std::__ndk1::to_string(unsigned int)
(All of these are missing when using statically built OpenCV)
I'm using ndk version 21e (I can't use higher version at the moment because another library uses Bazel and it only supports up to 21 at the moment)
OpenCV is built with the following flags
cmake -DCMAKE_BUILD_TYPE=Release -DINSTALL_ANDROID_EXAMPLES=OFF -DANDROID_EXAMPLES_WITH_LIBS=OFF -DANDROID_ABI="arm64-v8a"
-DBUILD_EXAMPLES=OFF -DBUILD_DOCS=OFF -DWITH_OPENCL=OFF -DBUILD_ANDROID_PROJECTS=OFF -DBUILD_ANDROID_EXAMPLES=OFF -DANDROID_ARM_NEON=1
-DANDROID_STL=c++_static -DANDROID_PLATFORM=android-21 -DCMAKE_TOOLCHAIN_FILE="$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake"
-DBUILD_SHARED_LIBS=OFF -DBUILD_FAT_JAVA_LIB=OFF -DBUILD_JAVA=OFF -DINSTALL_CREATE_DISTRIB=ON -DINSTALL_ANDROID_EXAMPLES=OFF -DBUILD_opencv_objdetect=OFF
-DBUILD_opencv_video=ON -DBUILD_opencv_videoio=ON -DBUILD_opencv_features2d=ON -DBUILD_opencv_flann=OFF -DBUILD_opencv_highgui=ON -DBUILD_opencv_ml=OFF
-DBUILD_opencv_photo=OFF -DBUILD_opencv_python=OFF -DBUILD_opencv_shape=OFF -DBUILD_opencv_stitching=OFF -DBUILD_opencv_superres=OFF -DBUILD_opencv_ts=OFF
-DBUILD_opencv_videostab=OFF -DBUILD_ANDROID_PROJECTS=OFF -DBUILD_opencv_world=ON -DBUILD_opencv_dnn=OFF -DBUILD_opencv_core=ON -DBUILD_opencv_imgcodecs=ON
-DBUILD_opencv_imgproc=ON -DBUILD_opencv_calib3d=ON -GNinja -DCMAKE_INSTALL_PREFIX=../install -DBUILD_ZLIB=1 -DWITH_PROTOBUF=OFF -DWITH_QUIRC=OFF ..
My libray is compiled using Gradle and Android Studio with these CMake flags
externalNativeBuild {
cmake {
cppFlags "-std=c++17 -static-openmp -fopenmp -fexceptions -frtti -Wno-unused-command-line-argument -Wl,-s"
cppFlags "-Wl,--exclude-libs,libc++_static.a -Wl,--exclude-libs,libc++abi.a"
arguments "-DANDROID_STL=c++_static", "-DANDROID_ARM_NEON=TRUE"
}
}
The issue wasn't related to the 3rd party or anything like this at all eventually.
I was using NDK version r21e. Upgrading the NDK to r24 fixed the issue.
It seems that when linking OpenCV as a shared object, it masked the actual NDK bug by importing or including some of the missing/problematic symbols and when we stopped using it, the error appeared.

Use MediaMuxer to encode a MP4 file but it crashes when calling mediaMuxer.stop()

I'm using MediaMuxer and MediaCodec to encode both Video(H264) data and Audio(AAC-LC) data from camera and audio to a MP4 file. But the MediaMuxer object sometimes crashes at mediaMuxer.stop() and the error log is
11-03 16:28:36.956: A/DEBUG(711): Abort message: 'frameworks/av/media/libstagefright/MPEG4Writer.cpp:2983 CHECK_LT( mCodecSpecificDataSize + 23,128) failed: 399 vs. 128'
11-03 16:28:36.957: A/DEBUG(711): x0 0000000000000000 x1 0000000000001184 x2 0000000000000006 x3 0000000000000000
11-03 16:28:36.957: A/DEBUG(711): x4 0000000000000000 x5 0000000000000001 x6 0000000000000000 x7 0000000000000000
11-03 16:28:36.957: A/DEBUG(711): x8 0000000000000083 x9 0000000000000000 x10 0000000000000000 x11 0000007f91bb0df8
11-03 16:28:36.958: A/DEBUG(711): x12 0000007f91bb0cd0 x13 0000000000000077 x14 0000007f91bb0ea8 x15 0000000000000000
11-03 16:28:36.958: A/DEBUG(711): x16 0000007faca8d6a8 x17 0000007faca4fb2c x18 0000007face14418 x19 0000007f91bb3510
11-03 16:28:36.959: A/DEBUG(711): x20 0000007f91bb3450 x21 000000000000000b x22 0000000000000006 x23 00000055a17fd260
11-03 16:28:36.959: A/DEBUG(711): x24 0000007f91bb1c58 x25 0000007f91bb18b4 x26 0000007f91bb1f90 x27 0000007fa9715000
11-03 16:28:36.960: A/DEBUG(711): x28 0000007f91bb1898 x29 0000007f91bb0d60 x30 0000007faca4d2c8
11-03 16:28:36.960: A/DEBUG(711): sp 0000007f91bb0d60 pc 0000007faca4fb34 pstate 0000000020000000
I've tried to only encode a single track(video or audio) many times. The execution of mediaMuxer.stop() was totally fine.
Why CHECK_LT failed when I encoded two tracks?
Ok, I'm here to answer myself.
After working around the clock, I found there are many factors which can cause MediaMuxer.stop() to crash when muxing an AAC track.
In order to avoid the crash, you had better play by the following rules for your implementation:
Use MediaCodec in sync mode for AAC encode. By using the sync mode, you can input the audio samples(which is a DirectByteBuffer) from AudioRecorder to MediaCodec's inputbuffer quickly without doing any extra memory copy. If you drop too many samples, MediaMuxer will crash.
Another reason to use sync mode is that you can use MediaMuxer.dequeueInputBuffer(-1) to make sure you can always get an available InputBuffer in your writeAudioSample method which you implement for write samples to MediaCodec.
The other reason to use sync mode is that you need to drain the AAC encoded data before MediaMuxer.stop(). (See the rule 9)
Set the MediaFormat.KEY_MAX_INPUT_SIZE by yourself, the value should be a multiple of 2048(1024 16-bit samples, for bytes, the length is 2048). I usually set it to 8192 that is depends on the audio source's sample rates, the number of channels, and the performance of your applications and devices.
Guarantee the input samples is full of audio data, and the length should be the value you set to MediaFormat.KEY_MAX_INPUT_SIZE. And compute the presentation time in microseconds. The interval of presentation time between any two adjacent input samples should be the same. Calculate the duration of your samples by this equation 1_000_000L * KEY_MAX_INPUT_SIZE / SAMPLE_RATE / NUMBER_OF_CHANNELS / 2. You don't need to align or shift the presentation time to 0. I strongly recommend you
just use long initialTime = System.nanoTime() / 1000L to get the initial time and pass it to MediaCodec. Therefore, the next time you writing the samples, the presentation time should be initialTime + 1_000_000L * KEY_MAX_INPUT_SIZE / SAMPLE_RATE / NUMBER_OF_CHANNELS / 2 and so on.
This part is the biggest pit. Check the presentation time when writing the AAC encoded data to MediaMuxer, even though you have already set the presentation time when inputing the audio samples to MediaCodec. The presentation time for the AAC encoded data may not be incremental sometimes. You should record the last presentation time you write to MediaMuxer. If you found the misordered AAC data, adjust the presentation time by presentationTime = ++lastPresentationTime. Also, you may get some zero-presentation-time AAC data. Ignore them. Do not write them to MediaMuxer.
If the MediaMuxer has other tracks, make sure the presentation time
for each track is in the same range(allowing errors for seconds).
One AAC MediaCodec for one MediaMuxer. And do not reuse the output MediaFormat object.
Before executing MediaMuxer.stop(), stop calling your writeAudioSample method and send a EOS to MediaCodec via queueInputBuffer(index, 0, 0, 0, MediaCodec.BUFFER_FLAG_END_OF_STREAM). And drain the remaining AAC data from MediaCodec to write to MediaMuxer. Execute MediaMuxer.stop() and see what is happened.

Android - App runs on install, crashes when it is re-opened

When I first install the app onto my device, it works fine. Then, if I close it and re-open it, the app will crash with the below logcat message.
I don't think the first line regarding libwvm.so has anything to do with it, because that appears on install as well, but doesn't cause a crash.
I'm not sure what to do with this message, because as far as I can tell it doesn't point to anything in my code that I can try to fix.
I am following this tutorial to learn developing games with libGDX.
Any help appreciated. Thanks!
02-13 11:01:59.292 13140-13156/? E/WVMExtractor: Failed to open libwvm.so: dlopen failed: library "libwvm.so" not found
02-13 11:02:01.317 13140-13154/? A/libc: Fatal signal 11 (SIGSEGV), code 2, fault addr 0x76a96000 in tid 13154 (GLThread 823)
02-13 11:02:01.424 3254-3254/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
02-13 11:02:01.425 3254-3254/? A/DEBUG: Build fingerprint: 'google/bullhead/bullhead:6.0.1/MMB29Q/2480792:user/release-keys'
02-13 11:02:01.426 3254-3254/? A/DEBUG: Revision: 'rev_1.0'
02-13 11:02:01.426 3254-3254/? A/DEBUG: ABI: 'arm64'
02-13 11:02:01.427 3254-3254/? A/DEBUG: pid: 13140, tid: 13154, name: GLThread 823 >>> com.mypackage.name <<<
02-13 11:02:01.427 3254-3254/? A/DEBUG: signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x76a96000
02-13 11:02:01.462 3254-3254/? A/DEBUG: x0 00000000be39c000 x1 0000000076a96000 x2 00000000000000a0 x3 0000000000000120
02-13 11:02:01.463 3254-3254/? A/DEBUG: x4 0000000000000000 x5 0000000000000000 x6 00000000be39c000 x7 0000000000000000
02-13 11:02:01.463 3254-3254/? A/DEBUG: x8 0000000000000000 x9 0000000000000000 x10 0000000000000120 x11 0000000000000000
02-13 11:02:01.463 3254-3254/? A/DEBUG: x12 0000000000000000 x13 0000007f8b9ad468 x14 0000007f8b9ad458 x15 0000007f8b9ad4b8
02-13 11:02:01.464 3254-3254/? A/DEBUG: x16 0000007f82329148 x17 0000007f900d4140 x18 0000000000000001 x19 0000000076a96120
02-13 11:02:01.464 3254-3254/? A/DEBUG: x20 00000000be39c000 x21 0000000000000001 x22 0000000000000120 x23 0000000000000120
02-13 11:02:01.464 3254-3254/? A/DEBUG: x24 0000000000000120 x25 0000000000000001 x26 0000000000000001 x27 0000000000000120
02-13 11:02:01.464 3254-3254/? A/DEBUG: x28 0000000076a96000 x29 0000007f8b9ace60 x30 0000007f81e57f74
02-13 11:02:01.464 3254-3254/? A/DEBUG: sp 0000007f8b9ace60 pc 0000007f900d4280 pstate 0000000020000000
02-13 11:02:01.468 3254-3254/? A/DEBUG: #00 pc 000000000001c280 /system/lib64/libc.so (memcpy+312)
02-13 11:02:01.469 3254-3254/? A/DEBUG: #01 pc 000000000025df70 /vendor/lib64/egl/libGLESv2_adreno.so (BltDevice::ExecFastCopyBlock(void*, void const*, unsigned int, unsigned int, unsigned int, unsigned int, BltRect const*, BltRect const*, int)+144)
02-13 11:02:01.650 3254-3254/? E/DEBUG: AM write failed: Broken pipe
02-13 11:02:01.675 4413-13173/? E/JavaBinder: !!! FAILED BINDER TRANSACTION !!! (parcel size = 112)
02-13 11:02:01.682 366-366/? E/lowmemorykiller: Error writing /proc/13140/oom_score_adj; errno=22
02-13 11:02:06.360 3321-3321/? E/QCALOG: [MessageQ] ProcessNewMessage: [LOWI-SERVER] unknown deliver target [OS-Agent]
02-13 11:02:32.344 6226-6226/? E/NetworkScheduler.SchedulerReceiver: Invalid parameter app
02-13 11:02:32.344 6226-6226/? E/NetworkScheduler.SchedulerReceiver: Invalid package name : Perhaps you didn't include a PendingIntent in the extras?
02-13 11:02:32.945 7266-7266/? E/clatd: plat_prefix/dns(ipv4only.arpa) status = 7/No address associated with hostname
I don't think this is a logcat filtering issue. I selected "no filter" in the logcat and the message was the same, except for the last few lines which went like this instead of as above:
02-13 12:02:54.902 3254-3254/? E/DEBUG: AM write failed: Broken pipe
02-13 12:02:54.923 4413-17149/? E/JavaBinder: !!! FAILED BINDER TRANSACTION !!! (parcel size = 112)
02-13 12:02:54.928 4413-4459/? E/JavaBinder: !!! FAILED BINDER TRANSACTION !!! (parcel size = 60)
02-13 12:03:22.680 4413-5547/? E/native: do suspend true
02-13 12:03:22.688 6053-6302/? E/NxpTml: _i2c_write() errno : 5
02-13 12:03:22.688 6053-6302/? E/NxpTml: PN54X - Error in I2C Write.....
02-13 12:03:22.689 6053-6304/? E/NxpHal: write error status = 0x1ff
02-13 12:03:22.689 6053-6267/? E/NxpHal: write_unlocked failed - PN54X Maybe in Standby Mode - Retry
Android Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mypackage.name"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/GdxTheme" >
<activity
android:name="com.mypackage.name.AndroidLauncher"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I think the most likely cause is that the OpenGL context is being released when the game goes into the background.
Lots of OpenGL based games use a class called glSurfaceView to manage the OpenGL surface, and by default, you get these sorts of crashes if you don't very carefully reinitialize all of your OpenGL objects after returning from suspend because they all get invalidated. In Ice Cream Sandwich, a function called setPreserveEGLContextOnPause was added to let you easily request that the OpenGL context is kept alive after your game goes into the background.
After some cursory research (so apologies if this is wrong) I believe libgdx uses it or something similar, but that it might be failing to work because you're not specifying a min or target sdk version in your manifest. Try adding a line like this to your manifest:
<uses-sdk android:targetSdkVersion="19" android:minSdkVersion="14" />
Documentation of the uses-sdk tag is here: http://developer.android.com/guide/topics/manifest/uses-sdk-element.html

Categories

Resources