android studio 載入jpush出現的問題:java.lang.UnsatisfiedLinkError:
出現的Log列印:
java.lang.UnsatisfiedLinkError: Couldn't load jpush175 from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.shop.hsz88-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.shop.hsz88-1,
/vendor/lib, /system/lib]]]: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:365)
at java.lang.System.loadLibrary(System.java:526)
at cn.jpush.android.service.PushProtocol.<clinit>(Unknown Source)
at cn.jpush.android.service.ServiceInterface.a(Unknown Source)
at cn.jpush.android.api.JPushInterface.init(Unknown Source)
at com.insthub.BeeFramework.BeeFrameworkApp.onCreate(BeeFrameworkApp.java:88)
at com.insthub.ecmobile.EcmobileApp.onCreate(EcmobileApp.java:44)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1007)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4610)
at android.app.ActivityThread.access$1500(ActivityThread.java:159)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1389)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5367)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:663)
at dalvik.system.NativeStart.main(Native Method)
1、在eclipse是可以執行的,那就可以確定我打包的.so是正常的;如下圖
2、確保了還出現這樣的問題,要考慮build.gradle指令碼的問題;是不是so檔案和jar包檔案沒有處理啊:
2.1 處理*.jar包檔案:
dependencies { compile fileTree(dir: 'libs', include: '*.jar') compile project(':alipay_lib') compile project(':AndroidSDKComponent') compile files('libs/alipaysdk.jar') compile files('libs/alipaysecsdk.jar') compile files('libs/alipayutdid.jar') compile files('libs/android-support-v4.jar') compile files('libs/commons-httpclient-3.0.1.jar') compile files('libs/core.jar') compile files('libs/ecmobilemanager.jar') compile files('libs/epaymobi_pos_sdk.jar') compile files('libs/jpush-sdk-release1.8.1.jar') compile files('libs/Native_Libs2.jar') compile files('libs/libammsdk.jar') compile files('libs/universal-image-loader-1.9.4-with-sources.jar') compile files('libs/UPPayAssistEx.jar') compile files('libs/UPPayPluginExPro.jar') compile files('libs/volley.jar') compile files('libs/weibosdkcore.jar') }
2.2 處理有關的專案所依賴的so檔案的目錄,動態的拷入到lib目錄中。
task nativeLibsToJar(type: Zip, description: "create a jar archive of the native libs") { destinationDir file("$projectDir/libs") baseName "native_ecmobile" extension "jar" from fileTree(dir: "libs", include: "**/*.so") into "lib" }
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn(nativeLibsToJar)
}
紅色標註的名字可以換掉;
加上上面兩段程式碼就可以實現動態載入,最後編譯的效果如下;
這樣就OK了,希望帶給eclipse 轉到android studio的開發者提供幫助;