moagrius / TileView

TileView is a subclass of android.view.ViewGroup that asynchronously displays, pans and zooms tile-based images. Plugins are available for features like markers, hotspots, and path drawing.
MIT License
1.46k stars 337 forks source link

Trouble including in my own project #495

Closed perrochon closed 5 years ago

perrochon commented 5 years ago

I started with the demo app, which works reasonably well. Then I tried to include the library in my own app, similarly to how the demo includes it, by copying the tileview directory over to my own app.

I can now compile everything, but it fails when trying to open the Tile View

<?xml version="1.0" encoding="utf-8"?> <com.qozix.tileview.TileView android:id="@+id/tileview" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#FFe7e7e7" />

Stack Trace below. Any ideas on where to start looking?

11/21 18:13:39: Launching app $ adb push E:\AndroidStudioProjects\gb\app\build\outputs\apk\debug\app-debug.apk /data/local/tmp/com.zwsi.gb.app $ adb shell pm install -t -r "/data/local/tmp/com.zwsi.gb.app" Success APK installed in 368 ms $ adb shell am start -n "com.zwsi.gb.app/com.zwsi.gb.feature.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER Client not ready yet..Waiting for process to come online Connected to process 11698 on device emulator-5554 Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page. W/com.zwsi.gb.ap: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (light greylist, reflection) W/com.zwsi.gb.ap: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (light greylist, reflection) D/OpenGLRenderer: HWUI GL Pipeline D/: HostConnection::get() New Host Connection established 0xce5ffd00, tid 11717 I/ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasWideColorDisplay retrieved: 0 android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasHDRDisplay retrieved: 0 I/OpenGLRenderer: Initialized EGL, version 1.4 D/OpenGLRenderer: Swap behavior 1 W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without... D/OpenGLRenderer: Swap behavior 0 D/EGL_emulation: eglCreateContext: 0xe1592f40: maj 2 min 0 rcv 2 D/EGL_emulation: eglMakeCurrent: 0xe1592f40: ver 2 0 (tinfo 0xe4ddf2a0) D/EGL_emulation: eglMakeCurrent: 0xe1592f40: ver 2 0 (tinfo 0xe4ddf2a0) W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@135c3cf D/AndroidRuntime: Shutting down VM E/AndroidRuntime: FATAL EXCEPTION: main Process: com.zwsi.gb.app, PID: 11698 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.zwsi.gb.app/com.zwsi.gb.feature.MapActivity}: android.view.InflateException: Binary XML file line #10: Binary XML file line #10: Error inflating class com.qozix.tileview.TileView at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6669) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) Caused by: android.view.InflateException: Binary XML file line #10: Binary XML file line #10: Error inflating class com.qozix.tileview.TileView Caused by: android.view.InflateException: Binary XML file line #10: Error inflating class com.qozix.tileview.TileView Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.newInstance0(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:343) at android.view.LayoutInflater.createView(LayoutInflater.java:647) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730) at android.view.LayoutInflater.rInflate(LayoutInflater.java:863) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) at android.view.LayoutInflater.inflate(LayoutInflater.java:515) at android.view.LayoutInflater.inflate(LayoutInflater.java:423) at android.view.LayoutInflater.inflate(LayoutInflater.java:374) at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) at com.zwsi.gb.feature.MapActivity.onCreate(MapActivity.kt:75) at android.app.Activity.performCreate(Activity.java:7136) at android.app.Activity.performCreate(Activity.java:7127) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6669) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) Caused by: java.lang.BootstrapMethodError: Exception from call site #1 bootstrap method at com.qozix.tileview.TileView.(TileView.java:84) at com.qozix.tileview.TileView.(TileView.java:93) at java.lang.reflect.Constructor.newInstance0(Native Method)  at java.lang.reflect.Constructor.newInstance(Constructor.java:343)  at android.view.LayoutInflater.createView(LayoutInflater.java:647)  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790)  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)  at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)  at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)  at android.view.LayoutInflater.inflate(LayoutInflater.java:515)  at android.view.LayoutInflater.inflate(LayoutInflater.java:423)  at android.view.LayoutInflater.inflate(LayoutInflater.java:374)  at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)  at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)  at com.zwsi.gb.feature.MapActivity.onCreate(MapActivity.kt:75)  at android.app.Activity.performCreate(Activity.java:7136)  at android.app.Activity.performCreate(Activity.java:7127)  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)  at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)  at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)  at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)  at android.os.Handler.dispatchMessage(Handler.java:106)  at android.os.Looper.loop(Looper.java:193)  at android.app.ActivityThread.main(ActivityThread.java:6669)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)  Caused by: java.lang.ClassCastException: Bootstrap method returned null at com.qozix.tileview.TileView.(TileView.java:84)  at com.qozix.tileview.TileView.(TileView.java:93)  at java.lang.reflect.Constructor.newInstance0(Native Method)  at java.lang.reflect.Constructor.newInstance(Constructor.java:343)  at android.view.LayoutInflater.createView(LayoutInflater.java:647)  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790)  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)  at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)  at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)  at android.view.LayoutInflater.inflate(LayoutInflater.java:515)  at android.view.LayoutInflater.inflate(LayoutInflater.java:423)  at android.view.LayoutInflater.inflate(LayoutInflater.java:374)  at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)  at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)  at com.zwsi.gb.feature.MapActivity.onCreate(MapActivity.kt:75)  at android.app.Activity.performCreate(Activity.java:7136)  at android.app.Activity.performCreate(Activity.java:7127)  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)  at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)  at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)  at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)  at android.os.Handler.dispatchMessage(Handler.java:106)  at android.os.Looper.loop(Looper.java:193)  at android.app.ActivityThread.main(ActivityThread.java:6669)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)  I/com.zwsi.gb.ap: ThreadFlipBegin blocked for 5.824ms I/Process: Sending signal. PID: 11698 SIG: 9 Application terminated.

moagrius commented 5 years ago
Caused by: android.view.InflateException: Binary XML file line #10: Binary XML file line #10: Error inflating class com.qozix.tileview.TileView
Caused by: android.view.InflateException: Binary XML file line #10: Error inflating class com.qozix.tileview.TileView

sounds like you didn't include the library. do you have the implementation line for the latest in your build.gradle?

perrochon commented 5 years ago

Thanks for the quick answer. I had implementation project(':tileview') like in the demo project. I added implementation 'com.qozix:tileview:3.0.1 and it runs. That is sufficient to get me continuing for now.

But doesn't that pull the library from somewhere else. If I do local changes to your files will it pick them up? (Still getting up to speed on GitHub & Android Studio & Kotlin :-). I downloaded your code as a zip file for now, not yet confident with multiple GitHub repositories in the same project. Eventually, if your library works out, then I want it set up that I can contribute back.

perrochon commented 5 years ago

Ugh, oops. Nope, not running. I started your (modified) demo by mistake.

perrochon commented 5 years ago

I am using AppCompatActivity, so maybe there is something in the newer libraries that breaks things.

moagrius commented 5 years ago

AppCompatActivity should be fine. It's not new. While v3 isn't as vetted as v2, v2 is in literally hundreds of projects and the library generally should be a pretty standard install. If you can run the demo, then it's something in your setup.

What do you mean by "not running"? if it's the same error inflating binary xml for the tileview element, then it means you don't have the library in your project.

If you want to use it "normally", you import it into your project using implementation. If you want to use it directly, you don't import anything and you have to do a project implementation, you just copy the java package into your src directory. you will of course need the dependencies from the library (e.g., disklrucache).

honestly you're better off to just import ("implementation 'com.qozix:tileview:3.0.1'") until you get it running, then you can try to figure out how to work with the source.

it's late on thanksgiving-eve so i probably won't respond for a few days after this. my best advice would be to just check the configuration in the demo. as i said, there's nothing terribly interesting about the library setup, and you shouldn't have to do much to get it to run.

perrochon commented 5 years ago

Understood about Thanksgiving. Thanks for the help you already provided. No worries. I am only looking at the import solution. I reverted everything to before I started including tileview. Then redid everything again. Added implementation to the gradle file, and bumped up minSDK to 26. It crashes on 'setContentView(R.layout.activity_map)' if that xml layout has a TileView in it with the same (or similar) stack trace (error inflating class). I'll work on other stuff, and look at it with a fresh eye another day. Happy Thanksgiving :-)

moagrius commented 5 years ago

back from holidays. how's this going?

perrochon commented 5 years ago

Thanks for following up.

I looked at everything in my setup for a day. Your demo compiles and runs in one project, with local code. In my other project, where i remote include, it crashes on inflating both on emulator and devices. It's likely a compile time set up problem. Maybe mismatching libraries or something like that. I am confident i can figure it out, but it may take time.

It's not blocking other work right now so i deferred solving this puzzle until I have learned a lot more about Gradle and libraries. My guess it's a simple thing once I figure it out.

On Fri, Nov 30, 2018, 11:56 Mike Dunn <notifications@github.com wrote:

back from holidays. how's this going?

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/moagrius/TileView/issues/495#issuecomment-443321222, or mute the thread https://github.com/notifications/unsubscribe-auth/ARAnJWi7KfMK5AlnHo0CkpBUTdld9W_Nks5u0Y10gaJpZM4YujRo .

moagrius commented 5 years ago

Cool, sounds good

MoeBro commented 5 years ago

Hey @perrochon i have the same issue when trying to include this library in my own project. Did you find any solution to the problem?

perrochon commented 5 years ago

I never looked into as I could work around. It hasn't reached high enough priority.

MoeBro commented 5 years ago

Ok. I guess i will just do it the only way it works for me, which is to download the demo app and just replace code with my own code.

moagrius commented 5 years ago

If you migrate to v3 and upload somewhere public I'll take a look