问题描述
我想对针对 Android SDK 22(5.1)
的应用程序进行一些更改.
I want to make some changes to an application targeting Android SDK 22 (5.1)
.
我将项目加载到了 Android Studio 3 中,并收到了Gradle升级消息.当然,随着新的Gradle处理依赖关系的方式变得非常挑剔,这样做会使整个事情发生爆炸.我决定全力以赴,只做整个迁移.无论如何都必须这样做.
I loaded the project in Android Studio 3, got the Gradle upgrade message. Of course, doing that makes the whole thing explode as the way the new Gradle handles dependencies has become very nitpicky. I decided to go all out and just do the whole migration. Would have to do it at some point anyway.
该应用程序使用 XWalkView
(在类中扩展),而不是本机Webview,因为我们要运行某些WebGL.Xwalk正在嵌入而不共享.
The application uses an XWalkView
(extended in a class), instead of the native Webview, as we want to have some WebGL running. The Xwalk is being embedded and not shared.
只需将Gradle文件更新为最新的Lib,从根本上将Android支持更改为最新的目标SDK,就可以使应用程序在Android 7+设备(在emu上经过Oreo测试)启动时崩溃(直接崩溃消息).该应用程序之前已正确加载.Logcat如下:
Just by updating the Gradle files to newest Libs, basically change the Android support to latest and target SDK, makes the application crash on startup (directly crash message) on Android 7+ devices (Oreo tested on emu). The application was loading properly before. Logcat follows:
在应用程序代码中,崩溃似乎源于以下行: XWalkPreferences.setValue(XWalkPreferences.REMOTE_DEBUGGING,true);
,在扩展 Application
的类中,而该类又反过来仅保留所用工具的Debug/Release配置.删除该行可以使应用程序正常运行,直到实际尝试加载 XWalkView
.
In the app code the crash seems to originate from the following line:XWalkPreferences.setValue(XWalkPreferences.REMOTE_DEBUGGING, true);
,which is in the class extending Application
, which in turn holds just Debug/Release configuration for the tools used. Removing said line allows the application to work properly until the point it actually tries to load the XWalkView
.
该应用程序可以在 Android 4.4
(适用于该应用程序的19分钟SDK),5.0(21)和6.0(23)上正常运行.
The app is running properly on Android 4.4
(19 min SDK for app), 5.0 (21) and 6.0 (23).
我一直在互联网上寻找可能的解决方案,但还没有找到有用的解决方案.我知道人行横道已被弃用,应该替换掉,但是Android并没有提供WebGL支持,而且我目前还看不到当前图形发生变化.
I have been scouring the internet for a possible solution but haven't found something that helped yet. I know that crosswalk is Deprecated and should probably be replaced but WebGL support is not a given in Android and I don't see the current graphics getting changed at this time.
如果还有其他有用的信息,请告诉我,我会提供.
If there is any other info that might be helpful let me know and I will provide it.
希望有人可以阐明一些看法.预先感谢.
Hope someone can shed some light. Thanks in advance.
经过一番摸索,我发现问题出在库文件上.下载 crosswalk.aar
后,我发现它有2个版本:
After some playing around, I discovered that the issue is with the library file. Downloading the crosswalk.aar
I found that there are 2 versions of it:
- xwalk_core_library-23.53.589.4-arm.aar
- xwalk_core_library-23.53.589.4-arm64.aar
我删除了Maven版本并手动包含了文件.当我使用arm64位时,我实际上可以在Android 7平台中毫无问题地使用该应用程序.但是然后我在其他版本中遇到了相同的xwalk崩溃.如果使用的是arm库,那么事情可以回到以前的样子.
I removed the maven version and manually included the files. When I use the arm64 bit I can actually use the application without any problems in the Android 7 platform. But then I get the same xwalk crash in the other versions. In case of the arm library, things go back to how they were before.
它们一起无法工作.构建时出现重复的zip文件
错误.
Together they cannot work. You get the Duplicate zip file
error when building.
因此,新的问题是:有没有办法告诉gradle每个体系结构使用哪个库文件?我一直在环顾四周,但找不到任何东西.
So the renewed question is:Is there a way to tell to gradle which library file to use per architecture? I have been looking around but I cannot find something.
推荐答案
我设法解决了该问题.这是该库包含的JNI的兼容性问题.
I managed to resolve the issue. It was a compatibility issue with the library's included JNIs.
maven加载的库仅包含 armeabi-v7a
和 x86
".so"文件.
The maven loaded library was only including armeabi-v7a
and x86
".so" files.
我所做的是从此处,将其解压缩,将 arm64-v8a jni文件夹内容移至另一侧,然后使用 jar cvf[yourLibName] .aar -C [folderName]/.
(不要忘了最后的点)命令来重新打包aar.
What I did was to manually download the general and arm64 aar versions of the library from here, unzip them, move the arm64-v8a jni folder contents over to the other side and then use jar cvf [yourLibName].aar -C [folderName]/ .
(don't forget the dot at the end) command to repackage the aar.
目前一切似乎都正常.希望一旦我设法在设备上进行测试,Oreo也会没事的.
Everything seems to be working fine for now. Hopefully Oreo will be OK too, once I manage to test on a device.
这篇关于Android-Oreo迁移后Xwalk崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!