Android开发——增量更新实战中遇到的问题

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/SEU_Calvin/article/details/53502850

0.   前言

之前一篇 Android开发——增量更新实战总结介绍了增量更新的具体实现步骤,但是其中有一些坑还是需要注意一下的,这里对遇到的一些坑做一个总结,希望以后遇到这些坑的同学少走弯路。


1.  Windows下的编译错误  

在上一篇的3.2我们导入源码的过程中,其中为了防止Windows下的编译错误放入了empty.c空文件,具体错误当时忘记截图了,反正如果你用的Windows平台做,直接加入就行了。说到这里还是觉得如果有钱就去入手MacBookPro,听同学说她实习所在的公司都是人手一台的,除了避免一些莫名其妙的BUG,还有就是下面的内存问题。

 

2.  内存问题  

我这实验室的4G内存的电脑有时候打开Studio就会报下面的错:

Gradle sync failed: Unable to start the daemonprocess.This problem might be caused by incorrect configuration of thedaemon.For example, an unrecognized jvm option is used.Please refer to the userguide chapter on the daemon at
https://docs.gradle.org/2.14.1/userguide/gradle_daemon.html
Please read the following process output tofind out more:
-----------------------
Error occurred during initialization of VM
Could not reserve enough space for 1572864KBobject heap
Consult IDE log for more details (Help | ShowLog)

每次遇到这种错误在gradle.properties文件中加入如下代码才可以正常使用,估计入手一台16G内存的Pro就不会这么麻烦了吧,反正我是打算要买了=。= 没有给苹果打广告,只是为了提高工作和学习效率而已。

org.gradle.jvmargs=-Xmx512m -XX:MaxPermSize=512m


3.  cannot locate symbol "signal" referenced by "libbsdiff.so"问题  

我在Android4.2的手机上安装应用,点击按钮后应用崩溃,报错如下:

java.lang.UnsatisfiedLinkError: dlopen failed:cannot locate symbol "signal" referenced by"libbsdiff.so"...
这个错误几乎困扰了我整整两天,甚至卸载重装 NDK 都无济于事,后来Google解决方案。


3.1  minSdkVersion与platform不匹配

StackOverFlow上的这个帖子给出的答案是:

signal was an inline function until platformandroid-21, now it's not inline anymore.
When you use the ndk r10, android-21 is used bydefault but it's not fully retro-compatible with devices running former Androidversions. In your case, signal can't be found on your device (but it would runproperly on Lollipop).
When using the NDK, you should use the platform(APP_PLATFORM:=android-XX) that corresponds to your android:minSdkVersion.
So here you can set APP_PLATFORM:=android-15inside Application.mk Makefile, and your lib will use the inline version ofsignal, so it will not look for its symbol at runtime.
然而我在5.1的模拟器上尝试后依旧报错,并不是像上面所说的那样run properly on Lollipop 。上面提到在 Application.mk 里加 APP_PLATFORM:=android-XX 看起来貌似就是解决方案,因为我在国内的一些博客里也看到有人这么做并且解决了这个错误, 然而Android Studio的项目结构里并没有Application.mk这个文件 ,然后这就很尴尬了,自己在 jni 目录下手动添加 Application.mk 什么的也没效果。

然后看到上面帖子的答题人在评论区给出的在AndroidStudio里的修改方法:

You can modify the compileSdkVersion to changethe APP_PLATFORM version. 
我仿佛看到了新大陆, 修改compileSdkVersion的版本,下载旧版本的开发工具 ,编译一下就报了一大堆错误,大多是资源错误, V7 包依赖错误和其他的一些错误,尝试各种修改后心累到放弃了 = =


3.2  NDK位数和手机位数不匹配

继而在国外的另一个帖子里看到这句话:

If you get an error like CANNOT LINKEXECUTABLE: cannot locate symbol "signal" referenced by"gatord" on android, please ensure you are using the correct versionof the Android ndk: ndk32 for 32-bit targets and ndk64 for 64-bit targets.
于是我在确定手机是 32 位之后 查看NDK是不是32位 的,发现一样是 32 位的,问题依然没有得到解决。


3.3  NDK版本问题

最后在StackOverFlow这个帖子里关注到有人通过修改NDK版本解决了cannot locate symbol "signal"的错误

Had this problem and solved reverting to ndk r9.
于是我便去找到了 r9b的资源包 ,替换掉新版本后出现了一堆新的错误,这时我几乎都要放弃了 = = , 几番波折 下载到了r10的旧版本并尝试编译运行后,错误奇迹般地解决了 。我 TM 还能说什么呢,真的是坑死了。


猜你喜欢

转载自blog.csdn.net/SEU_Calvin/article/details/53502850