2016-08-16 263 views
0

我試圖添加Android Mapbox庫作爲模塊而不是使用Gradle。這是因爲我們可以簡單地修改幾行代碼以適應我們的用例,Mapbox沒有考慮這個用例。我克隆回購,使用Android Studio導入模塊,並將其作爲依賴項添加到我的項目構建中。 (compile project(':MapboxGLAndroidSDK'))在settings.gradle中我們也添加它include ':app', ':MapboxGLAndroidSDK'無法添加Mapbox SDK作爲模塊

當試圖建立,但是,我們可以得到以下異常:

FATAL EXCEPTION: main 
                     Process: com.gc.avt.display, PID: 15839 
                     java.lang.RuntimeException: Unable to start activity ComponentInfo{com.gc.avt.display/com.gc.avt.display.MainActivity}: android.view.InflateException: Binary XML file line #9: Binary XML file line #9: Error inflating class com.mapbox.mapboxsdk.maps.MapView 
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3256) 
                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3352) 
                      at android.app.ActivityThread.access$1100(ActivityThread.java:223) 
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1797) 
                      at android.os.Handler.dispatchMessage(Handler.java:102) 
                      at android.os.Looper.loop(Looper.java:158) 
                      at android.app.ActivityThread.main(ActivityThread.java:7231) 
                      at java.lang.reflect.Method.invoke(Native Method) 
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 
                     Caused by: android.view.InflateException: Binary XML file line #9: Binary XML file line #9: Error inflating class com.mapbox.mapboxsdk.maps.MapView 
                      at android.view.LayoutInflater.inflate(LayoutInflater.java:551) 
                      at android.view.LayoutInflater.inflate(LayoutInflater.java:429) 
                      at android.view.LayoutInflater.inflate(LayoutInflater.java:380) 
                      at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280) 
                      at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
                      at com.gc.avt.display.MainActivity.onCreate(MainActivity.java:100) 
                      at android.app.Activity.performCreate(Activity.java:6877) 
                      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1136) 
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3209) 
                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3352)  
                      at android.app.ActivityThread.access$1100(ActivityThread.java:223)  
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1797)  
                      at android.os.Handler.dispatchMessage(Handler.java:102)  
                      at android.os.Looper.loop(Looper.java:158)  
                      at android.app.ActivityThread.main(ActivityThread.java:7231)  
                      at java.lang.reflect.Method.invoke(Native Method)  
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)  
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)  
                     Caused by: android.view.InflateException: Binary XML file line #9: Error inflating class com.mapbox.mapboxsdk.maps.MapView 
                      at android.view.LayoutInflater.createView(LayoutInflater.java:657) 
                      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776) 
                      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716) 
                      at android.view.LayoutInflater.rInflate(LayoutInflater.java:847) 
                      at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810) 
                      at android.view.LayoutInflater.inflate(LayoutInflater.java:527) 
                      at android.view.LayoutInflater.inflate(LayoutInflater.java:429)  
                      at android.view.LayoutInflater.inflate(LayoutInflater.java:380)  
                      at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280)  
                      at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)  
                      at com.gc.avt.display.MainActivity.onCreate(MainActivity.java:100)  
                      at android.app.Activity.performCreate(Activity.java:6877)  
                      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1136)  
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3209)  
                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3352)  
                      at android.app.ActivityThread.access$1100(ActivityThread.java:223)  
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1797)  
                      at android.os.Handler.dispatchMessage(Handler.java:102)  
                      at android.os.Looper.loop(Looper.java:158)  
                      at android.app.ActivityThread.main(ActivityThread.java:7231)  
                      at java.lang.reflect.Method.invoke(Native Method)  
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)  
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)  
                     Caused by: java.lang.reflect.InvocationTargetException 
                      at java.lang.reflect.Constructor.newInstance(Native Method) 
                      at android.view.LayoutInflater.createView(LayoutInflater.java:631) 
                      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776)  
                      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716)  
                      at android.view.LayoutInflater.rInflate(LayoutInflater.java:847)  
                      at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)  
                      at android.view.LayoutInflater.inflate(LayoutInflater.java:527)  
                      at android.view.LayoutInflater.inflate(LayoutInflater.java:429)  
                      at android.view.LayoutInflater.inflate(LayoutInflater.java:380)  
                      at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280)  
                      at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)  
                      at com.gc.avt.display.MainActivity.onCreate(MainActivity.java:100)  
                      at android.app.Activity.performCreate(Activity.java:6877)  
                      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1136)  
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3209)  
                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3352)  
                      at android.app.ActivityThread.access$1100(ActivityThread.java:223)  
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1797)  
                      at android.os.Handler.dispatchMessage(Handler.java:102)  
                      at android.os.Looper.loop(Looper.java:158)  
                      at android.app.ActivityThread.main(ActivityThread.java:7231)  
                      at java.lang.reflect.Method.invoke(Native Method)  
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)  
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)  
                     Caused by: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.gc.avt.display-1/base.apk"],nativeLibraryDirectories=[/data/app/com.gc.avt.display-1/lib/arm64, /data/app/com.gc.avt.display-1/base.apk!/lib/arm64-v8a, /vendor/lib64, /system/lib64]]] couldn't find "libmapbox-gl.so" 
                      at java.lang.Runtime.loadLibrary(Runtime.java:367) 
                      at java.lang.System.loadLibrary(System.java:1076) 
                      at com.mapbox.mapboxsdk.maps.NativeMapView.<clinit>(NativeMapView.java:50) 
                      at com.mapbox.mapboxsdk.maps.MapView.initialize(MapView.java:204) 
                      at com.mapbox.mapboxsdk.maps.MapView.<init>(MapView.java:171) 
                      at java.lang.reflect.Constructor.newInstance(Native Method)  
                      at android.view.LayoutInflater.createView(LayoutInflater.java:631)  
                      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776)  
                      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716)  
                      at android.view.LayoutInflater.rInflate(LayoutInflater.java:847)  
                      at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)  
                      at android.view.LayoutInflater.inflate(LayoutInflater.java:527)  
                      at android.view.LayoutInflater.inflate(LayoutInflater.java:429)  
                      at android.view.LayoutInflater.inflate(LayoutInflater.java:380)  
                      at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280)  
                      at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)  
                      at com.gc.avt.display.MainActivity.onCreate(MainActivity.java:100)  
                      at android.app.Activity.performCreate(Activity.java:6877)  
                      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1136)  
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3209)  
                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3352)  
                      at android.app.ActivityThread.access$1100(ActivityThread.java:223)  
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1797)  
                      at android.os.Handler.dispatchMessage(Handler.java:102)  
                      at android.os.Looper.loop(Looper.java:158)  
                      at android.app.ActivityThread.main(ActivityThread.java:7231)  
                      at java.lang.reflect.Method.invoke(Native Method)  
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)  
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)  

看起來Mapbox拋出試圖運行

static { 
    System.loadLibrary("mapbox-gl"); 
} 

如何得到這個模塊運行的任何想法時是否正確?

回答

1

從源代碼構建時,可能很難讓Mapbox GL在Android應用程序中工作。根據我在Github page上推薦的功能,甚至可以通過使用您的功能打開拉取請求來提供功能。如果您仍想將源代碼作爲模塊添加到您的應用程序中,那麼您還缺少更多步驟。您需要確保在項目中包含C++「核心」文件,使用make android等來編譯這些文件。您還需要確保您具有構建項目所需的所有依賴項。我們有a good guide在我們的回購,這將引導您通過設置。