Android 5.0, Code Lollipop, the source finally released on December 3, 2014, a large number of domestic manufacturers follow-up. The biggest change is the default use of ART (Android Runtime), replacing the previous Dalvik virtual machine, presenting the Material Design interface style. Previously released app may need to make some changes, temporarily collected some problems, I hope to be helpful to everyone.
1. Intent/service
Under Android 5.0 version, the program runs normally. The user complains about the crash on the new Android 5.0 device, we don't have the latest device yet, so temporarily debug with the Android emulator.
You can see such a record in the log of the output:
E/androidruntime (26479): java.lang.RuntimeException:Unable to start activity componentinfo{package_name/. Activity_name}: Java.lang.IllegalArgumentException:Service Intent must be explicit:intent {act= Com.bda.controller.IControllerService}
E/gameactivity (18333): caused By:java.lang.IllegalArgumentException:Service Intent must be explicit:intent {ACT=COM.B Da.controller.IControllerService}
E/gameactivity (18333): at Android.app.ContextImpl.validateServiceIntent (contextimpl.java:1982)
E/gameactivity (18333): at Android.app.ContextImpl.startServiceCommon (contextimpl.java:2020)
E/gameactivity (18333): at Android.app.ContextImpl.startService (contextimpl.java:1995)
E/gameactivity (18333): at Android.content.ContextWrapper.startService (contextwrapper.java:533)
E/gameactivity (18333): at COM.BDA.CONTROLLER.A.D (Unknown Source)
by looking at the stack crash information, we see that using a third-party Controller.jar package causes an error. Controller is a package that simulates the GamePad function on the device screen, downloads the latest Moga developers SDK, downloads the controller-sdk-std-1.3.1.zip,2013 01 release, It's a little old. There are Com.bda.controller.jar, no source code.
Try Zip decompression Controller.jar file, decompile. class file Com/bda/controller/basecontroller.class
To view bytecode, use Javap-c Basecontroller.class
Public Final Boolean init ();Code: 0: Aload_01: GetField #113FieldMisbound:Z4: Ifne - 7: New #193//Class Android/content/intentTen: DUP One: LDC #165//Class Com/bda/controller/icontrollerservice -: Invokevirtual #195Method Java/lang/class.GetName:() ljava/lang/string; -: Invokespecial #201Method android/content/intent."<init>":(ljava/lang/string;) V +: Astore_1 -: Aload_0 +: GetField #142FieldMcontext:Landroid/content/context; -: Aload_1 -: Invokevirtual #204Method Android/content/context.StartService:(landroid/content/intent;) Landroid/content/componentname; -:Pop in: Aload_0 -: GetField #142FieldMcontext:Landroid/content/context; -: Aload_1 the: Aload_0 *: GetField # theFieldmserviceconnection:Lcom/bda/controller/controller$serviceconnection; -: Iconst_1 the: Invokevirtual #208Method Android/content/context.Bindservice:(landroid/content/intent;landroid/content/serviceconnection;i) Z the:Pop +: Aload_0 -: Iconst_1 $: Putfield #113FieldMisbound:Z -: Aload_0 the: GetField #113FieldMisbound:Z the: Ireturn
Init
Of course you want to view the source code, use the Decompile tool Jad, or temporarily use the online version of My code, this site can view Zend Guard encrypted. php files, Java. class files,. swf files for Adobe Flash,. NET program. exe,. dll, or QR code, can be collected.
Final boolean init () { if (! Misbound) {Intent Intent = new Intent (Com.bda.controller.IControllerService.getName ()); Mcontext.startservice (Intent); Misbound = Mcontext.bindservice (Intent, this return Misbound;}
According to the above error and code, it is necessary to use the explicit Intent (SetComponent (componentname) or SetClass (Context, Class) to set Component Intent), The above sentence needs to be changed to Intent Intent = new Intent (Mcontext, Icontrollerservice.class);
or Intent Intent = new Intent ("Com.bda.controller.IControllerService"). Setpackage ("Com.bda.controller");
The official documentation also mentions the use of explicit Intent to Startservice/bindservice to ensure security.
Caution:to ensure your app is secure, all use of an explicit intent when starting a Service and does not declare intent fil Ters for your services. Using A implicit intent to start a service was a security hazard because you cannot being certain what service would respond T o The intent, and the user cannot see which service starts. Beginning with Android 5.0 (API level), the system throws a exception if you call Bindservice () with an implicit inten T.
Note:when starting a Service, you should always specify the component name. Otherwise, you cannot is certain what service would respond to the intent, and the user cannot see which service starts.
Many third-party libraries have exposed this problem and need to be updated. We also used the Google Analytics tracking library Libgoogleanalyticsv2.jar.
E/gameactivity (1137): java.lang.RuntimeException:Unable to start activity componentinfo{package_name/activity_name} : Java.lang.IllegalArgumentException:Service Intent must be explicit:intent {act= Com.google.android.gms.analytics.service.START (has extras)}
Try to update to V3 (now has V4) to solve the problem, need to change some code. Here is what the document migration needs to modify, easytracker:v2.x to V3.
2. The MD5 symbol cannot be found.
Md5_ctx context; Md5_init (&context); Const Char " Hello, world!. " ; Md5_update (sizeof&context);
The crash log is as follows
E/art (21678): Dlopen ("/data/app/package_name/lib/arm/libsixguns.so", Rtld_lazy) Failed:dlopen Failed:cannot Locate Symbol "Md5_final" referenced by "libxyz.so" ...
E/game (21678): Native code library failed to load.
E/game (21678): Java.lang.UnsatisfiedLinkError:dlopen failed:cannot Locate symbol "md5_final" referenced by "libxyz.so" ...
This is because Google modified the implementation of the underlying Bionic libc library, and some of the hidden APIs were removed. Some code that relies on these functions may not work.
Modify the scheme, you can import the MD5 library yourself, anyway the code is short.
or add--whole-archive static link Crypto library. Because OpenSSL also provides MD5 implementations that can be borrowed. Openssl/crypto/md32_common.h
To include these definitions in the final. So library, add the LD link command-wl,-whole-archive crypto-wl,-no-whole-archive.
--whole-archive will include the archive file in the link. A all of the. o files, instead of searching only when needed, are used to turn. A files into. so files. GCC does not recognize this command, so you need to use-wl,-whole-archive to add-wl,-no-whole-archive end, as GCC will add its own. A in the link to avoid being affected.
3. Random crashes in ART mode.
Dalvik for native code and Java code to provide their own stack, the default native stack has 1MB, Java stack has 32KB. In ART mode, a unified stack is provided. Supposedly, the ART line stacks should be the same size as the Dalvik. If you explicitly set the stack size, you may need to revisit these values in the app running in ART mode.
The Java thread class has a constructor thread (Threadgroup group, Runnable Runnable, String threadname, long StackSize) that provides the setting of the stack size parameter, if it appears in the run Stackoverflowerror error, you may need to increase the StackSize value manually.
The Pthread_attr_setstack () and Pthread_attr_setstacksize () of the POSIX thread are required to be called by C/C + +. If the pthread stack is too small, calling the JNI Attachcurrentthread () method prints the following log:
F/ART:ART/RUNTIME/THREAD.CC:435] Attempt to attach a thread with a too-small stack (16384 bytes)
When using JNI, for efficiency reasons, you may need to cache some methods Findclass/getfieldid/getmethodid return IDs, do not cache jnienv*, and do not attach native threads to Java throughout the application's lifecycle Thread. With the ADB shell setprop debug.checkjni 1 command, you can debug some JNI errors that do not affect applications that are already running.
JNI in ART mode may throw some Dalvik errors that can be caught with Checkjni, which is the command line above. For example, when Proguard to confuse the code, take off some native method, run time will throw Nosuchmethoderror exception. Now the Getfieldid () and Getstaticfieldid () methods throw the NoSuchMethodError exception instead of returning null.
e/androidruntime:fatal exception:mainestatic or non-static"lcom/foo/bar;. Native_frob (ljava/lang/string;) I"E/androidruntime: at Java.lang.Runtime.nativeLoad (Native Method) E/androidruntime: at java.lang.Runtime.doLoad (Runtime.java: 421 ) e/androidruntime: at java.lang.Runtime.loadLibrary (runtime.java:362) e/ Androidruntime: At java.lang.System.loadLibrary (system.java:526)
Android app upgrade to 5.0 issues to be aware of