3

I was studying appcompat-v7:21.0.0': No resource found that matches the given name: attr 'android:actionModeShareDrawable' to see if it had any relevance to me and it unfortunately does not. I hope this is relevant to some of you and you may be able to help.

I need to set my Project Build Target in Eclipse to less than API21. API21 is Android 5.x and has major changes rendering native code incompatible. Please see Cannot load library: reloc_library[1285]: cannot locate 'rand'. I cannot target API21 for projects with native code, even that is just importing the .so library that I made in a parallel project (with API16).

I don't think I really need appcompat, but decided I did long ago, when it was easier. I certainly don't need API21 so might just have to delete res/values-v21. Forget deleting just res/values-v21, I've re-checked further up the log and both v14 and v17 are in violation, despite Eclipse not highlighting as red flags in anything but the console- Package Explorer is clean, as is file view. Except that the .xml errors are causing my R.java to not get built. Otherwise I must go back to SDK tools before API21 existed with their android-support-v7-appcompat.

To repeat linked content, if I use API21 I get:

01-20 11:42:16.440: E/AndroidRuntime(29173): FATAL EXCEPTION: main
01-20 11:42:16.440: E/AndroidRuntime(29173): java.lang.UnsatisfiedLinkError: Cannot load library: reloc_library[1322]:   124 cannot locate 'rand'...
01-20 11:42:16.440: E/AndroidRuntime(29173):    at java.lang.Runtime.loadLibrary(Runtime.java:370)
01-20 11:42:16.440: E/AndroidRuntime(29173):    at java.lang.System.loadLibrary(System.java:535)
01-20 11:42:16.440: E/AndroidRuntime(29173):    at org.cocos2dx.lib.Cocos2dxActivity.onLoadNativeLibraries(Cocos2dxActivity.java:85)
01-20 11:42:16.440: E/AndroidRuntime(29173):    at org.cocos2dx.lib.Cocos2dxActivity.onCreate(Cocos2dxActivity.java:99)

on my 4.1.2 phone, though not on any emulator, even 4.1.2 (API16) one.

and it I don't use API21 it refuses to build.

EDIT I'm going to try breaking dependencies on android-support-v4 as I recall having to update that in several places, once outside the following search path, where I appear to have 4 different versions:

4 versions of android-support-v4

Community
  • 1
  • 1
John
  • 6,433
  • 7
  • 47
  • 82

1 Answers1

0

After messing with android-support-v4 I removed appcompat as an imported project (it didn't exist with cocos2dx v3.2) and reset all android-support-v4 to their earlier versions, ditto for v4.

This still didn't work but nor did it break things- it still worked on the emulator (both API21 and API16) but not on the phone (API16). It was likely a smaller apk too.

What fixed it was setting APP_PLATFORM := android-14 in Application.mk setting it to build, and going for a shower. It worked just fine after a 20 minute build (dual ABI, old core-i5) on my API16 phone too. Will test more and update in the unlikely event that I've lost any compatibility.

UPDATE I've tested from 2.3.6 to 5.0.2 with no problems after setting APP_PLATFORM := android-14 strange that such an arbitrary fix could work but I guess the default must have been to use 5.0.2 specific binaries. I had wondered if this single line was the fix because I only tried this exact build a couple of times before updating Android.mk and rebuilding. I don't have time to go back and remove this just to repeat, so I'm accepting my own answer.

John
  • 6,433
  • 7
  • 47
  • 82
  • Yes - the correct thing is to only downgrade the build target for the native parts (by setting `APP_PLATFORM` in `Application.mk` - ideally, set it to the lowest version you can/need), while keeping the API target for the java at the latest version. Java code built with a newer target API won't automatically break when running on older versions (only in the cases when you intentionally use the new API, which the appcompat stuff takes care of). Only the native code has got the issue that libs built with a newer target API ends up requiring exactly that version. – mstorsjo Jan 20 '15 at 13:39