我按照https://github.com/mapbox/mapbox-android-sdk#building-from-source
中的說明操作,目前正在使用Android Studio。我曾經在這個Android項目中使用Eclipse,並且在花了整個昨天的努力試圖使集成mapbox-android-sdk與Eclipse中的我的android項目一起工作後,我只是簡單地放棄了。我希望mapbox-android-sdk上的指示更清晰 - 如果我知道如何,我很樂意幫助他們。無法將MapboxAndroidSDK集成到我的android studio項目中
我將我的舊Android項目導入到Android Studio中,然後進入File-> Import Project並在MapboxAndroidSDK
的MapboxAndroidSDK
裏選擇我在系統中下載git源代碼樹的目錄中的build.gradle
。
然後,雖然Android Studio中選擇了需要地圖支持的Android項目,但我在Android Studio中選擇了File-> Import Module來添加在MapboxAndroidSDK目錄中生成的* .aar文件。
無論如何,當我現在運行我的應用程序時,出現以下錯誤。任何幫助表示讚賞。
09-29 11:30:07.061 1111-1111/com.username.someapp D/﹕ HostConnection::get() New Host Connection established 0xb7b6bdb8, tid 1111
09-29 11:30:07.091 1111-1111/com.username.someapp W/EGL_emulation﹕ eglSurfaceAttrib not implemented
09-29 11:30:07.101 1111-1111/com.username.someapp D/OpenGLRenderer﹕ Enabling debug mode 0
09-29 11:30:16.431 1111-1111/com.username.someapp D/dalvikvm﹕ GC_FOR_ALLOC freed 104K, 5% free 3282K/3448K, paused 20ms, total 24ms
09-29 11:30:16.481 1111-1111/com.username.someapp W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljava/nio/file/Path;)
09-29 11:30:16.481 1111-1111/com.username.someapp W/dalvikvm﹕ VFY: unable to find class referenced in signature ([Ljava/nio/file/OpenOption;)
09-29 11:30:16.491 1111-1111/com.username.someapp I/dalvikvm﹕ Could not find method java.nio.file.Files.newOutputStream, referenced from method okio.Okio.sink
09-29 11:30:16.491 1111-1111/com.username.someapp W/dalvikvm﹕ VFY: unable to resolve static method 10776: Ljava/nio/file/Files;.newOutputStream (Ljava/nio/file/Path;[Ljava/nio/file/OpenOption;)Ljava/io/OutputStrea
m;
09-29 11:30:16.491 1111-1111/com.username.someapp D/dalvikvm﹕ VFY: replacing opcode 0x71 at 0x000a
09-29 11:30:16.491 1111-1111/com.username.someapp W/dalvikvm﹕ VFY: unable to find class referenced in signature (Ljava/nio/file/Path;)
09-29 11:30:16.491 1111-1111/com.username.someapp W/dalvikvm﹕ VFY: unable to find class referenced in signature ([Ljava/nio/file/OpenOption;)
09-29 11:30:16.501 1111-1111/com.username.someapp I/dalvikvm﹕ Could not find method java.nio.file.Files.newInputStream, referenced from method okio.Okio.source
09-29 11:30:16.501 1111-1111/com.username.someapp W/dalvikvm﹕ VFY: unable to resolve static method 10775: Ljava/nio/file/Files;.newInputStream (Ljava/nio/file/Path;[Ljava/nio/file/OpenOption;)Ljava/io/InputStream;
09-29 11:30:16.501 1111-1111/com.username.someapp D/dalvikvm﹕ VFY: replacing opcode 0x71 at 0x000a
09-29 11:30:16.511 1111-1111/com.username.someapp D/AndroidRuntime﹕ Shutting down VM
09-29 11:30:16.511 1111-1111/com.username.someapp W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0xb1aaaba8)
09-29 11:30:16.531 1111-1111/com.username.someapp E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.username.someapp, PID: 1111
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.username.someapp/com.username.someapp.MapActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
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:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.username.someapp.MapActivity.onCreate(MapActivity.java:51)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
我認爲這個問題可以用指令here,說
不要忘了,然後還包括依賴從MapboxAndroidSDK /的build.gradle在類路徑來解決!
但我不知道如何在Android Studio中做到這一點。任何人都可以指出具體的依賴和如何?我應該將它們添加爲File-> Project Structure-> Dependencies-> Library dependency->?任何深入瞭解這一點深表感謝。
順便說一句,我嘗試添加這些庫的方式我在我原來的問題,但運行時總是失敗'無法找到方法com。 squareup.okhttp.internal.huc.HttpURLConnectionImpl.getContentLengthLong' – Sonny 2014-09-29 16:00:43
如果喲我們得到一個NullPointerException異常,你必須調試它 - 在這一點上依賴關係可能不是問題,儘管通過查看堆棧跟蹤有點難以分辨。 – 2014-09-29 16:41:16
我想出了導致崩潰的代碼中的錯誤,但我現在遇到了另一個問題。 – Sonny 2014-09-29 18:49:33