問題詳述
推送SDK在初始化時報”java.lang.UnsatisfiedLinkError”或”TNET-JNI-LOAD-SO-FAIL“錯誤。
詳細報錯信息如下:
java.lang.UnsatisfiedLinkError: No implementation found for int org.android.spdy.SpdyAgent.configLogFileN(java.lang.String, int, int) (tried Java_org_android_spdy_SpdyAgent_configLogFileN and Java_org_android_spdy_SpdyAgent_configLogFileN__Ljava_lang_String_2II)
at org.android.spdy.SpdyAgent.configLogFileN(Native Method)
at org.android.spdy.SpdyAgent.configLogFile(Unknown Source)
at com.taobao.accs.net.e.<init>(Unknown Source)
at com.taobao.accs.net.BaseConnection.a(Unknown Source)
at com.taobao.accs.internal.ACCSManagerImpl.sendControlMessage(Unknown Source)
at com.taobao.accs.internal.ACCSManagerImpl.bindApp(Unknown Source)
at com.taobao.accs.a.a(Unknown Source)
at com.taobao.agoo.AliyunRegister.register(Unknown Source)
at com.alibaba.sdk.android.push.vip.AppRegister$a.b(Unknown Source)
at com.alibaba.sdk.android.push.vip.AppRegister$a.a(Unknown Source)
at com.alibaba.sdk.android.push.vip.b.handleMessage(Unknown Source)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.os.HandlerThread.run(HandlerThread.java:61)
或
04-20 11:34:02.035 15264-15383/cloud.aliyun.test E/awcn.TnetSpdySession: |[seq:AWCN2_2] connect exception org.android.spdy.SpdyErrorException: TNET_JNI_ERR_LOAD_SO_FAIL
at org.android.spdy.SpdyAgent.checkLoadSo(Unknown Source)
at org.android.spdy.SpdyAgent.agentIsOpen(Unknown Source)
at org.android.spdy.SpdyAgent.createSession(Unknown Source)
at org.android.spdy.SpdyAgent.createSession(Unknown Source)
at anet.channel.d.l.b(Unknown Source)
at anet.channel.SessionRequest.a(Unknown Source)
at anet.channel.SessionRequest.a(Unknown Source)
at anet.channel.SessionRequest$a.onFailed(Unknown Source)
at anet.channel.k.onEvent(Unknown Source)
at anet.channel.i.run(Unknown Source)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:152)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:265)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
這是什么原因引起的?
問題原因
推送SDK包含有so包(libtnet、libcocklogic),出現上述錯誤都是由于so包沒有被成功加載導致的。請通過以下方法確認so包是被被正常添加:
將生成的.apk文件以.zip文件解壓,查看對應的jniLibs是否正確包含armeabi、armeabi-v7a、x86體系架構的目錄,檢查是否有移動推送的libcocklogic.so和libtnet.so
解決方案
通過遠程同步的方式集成推送SDK。推送SDK在V3.0.0及以上版本開始支持遠程同步集成,在遠程同步的過程中so包也被自動同步。推送SDK當前提供:armeabi,armeabi-v7a,arm64-v8a,mips,mips-64,x86,x86_64等架構的so包,如果您不需要這么多,可以在build.gradle文件中進行配置,選擇需要的so包:
android {
......
defaultConfig {
applicationId "com.xxx.xxx"
......
ndk {
//選擇要添加的對應cpu類型的.so庫。
abiFilters 'armeabi', 'armeabi-v7a', 'armeabi-v8a'
// 還可以添加 'x86', 'x86_64', 'mips', 'mips64'
}
......
}
......
}
手動添加so包,將所需架構的so包放到指定路徑默認為”src/main/jniLibs/‘’,若設置其他路徑如libs,需要手動在build.gradle文件中指定:
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
sourceSets {
main {
jniLibs.srcDirs = ['libs']
}
}
}
文檔內容是否對您有幫助?