From 3d5910cfd05d487e2e490d3f1cbd10e9ef67e69a Mon Sep 17 00:00:00 2001 From: Yiding He Date: Fri, 18 Jan 2019 16:04:19 -0500 Subject: [PATCH 1/5] Fixed issue 197. showing NoSuchMethodException on Android P when initialing the SoLoader https://github.com/facebook/conceal/issues/197 Reference: https://github.com/facebook/SoLoader/commit/3d691395dd353d7ebf633db445bcc7460232aa7a --- first-party/soloader/SoLoader.java | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/first-party/soloader/SoLoader.java b/first-party/soloader/SoLoader.java index 00c7637..1521e77 100644 --- a/first-party/soloader/SoLoader.java +++ b/first-party/soloader/SoLoader.java @@ -257,21 +257,26 @@ private static synchronized void initSoLoader(@Nullable SoFileLoader soFileLoade sSoFileLoader = new SoFileLoader() { @Override public void load(final String pathToSoFile, final int loadFlags) { + String error = null; if (hasNativeLoadMethod) { final boolean inZip = (loadFlags & SOLOADER_LOOK_IN_ZIP) == SOLOADER_LOOK_IN_ZIP; final String path = inZip ? localLdLibraryPath : localLdLibraryPathNoZips; try { synchronized (runtime) { - String error = (String)nativeLoadRuntimeMethod.invoke( - runtime, - pathToSoFile, - SoLoader.class.getClassLoader(), - path); + error = + // the third argument of nativeLoad method was removed in Android P API + Build.VERSION.SDK_INT <= 27 + ? (String) + nativeLoadRuntimeMethod.invoke( + runtime, pathToSoFile, SoLoader.class.getClassLoader(), path) + : (String) + nativeLoadRuntimeMethod.invoke( + runtime, pathToSoFile, SoLoader.class.getClassLoader()); if (error != null) { throw new UnsatisfiedLinkError(error); } } - } catch (IllegalAccessException + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { final String errMsg = "Error: Cannot load " + pathToSoFile; @@ -292,9 +297,15 @@ private static Method getNativeLoadRuntimeMethod() { } try { - final Method method = - Runtime.class - .getDeclaredMethod("nativeLoad", String.class, ClassLoader.class, String.class); + final Method method; + if (Build.VERSION.SDK_INT <= 27) { + method = + Runtime.class.getDeclaredMethod( + "nativeLoad", String.class, ClassLoader.class, String.class); + } else { + method = Runtime.class.getDeclaredMethod("nativeLoad", String.class, ClassLoader.class); + } + method.setAccessible(true); return method; } catch (final NoSuchMethodException | SecurityException e) { From 13f3876cb1b9f657e4a6722fc5139046d300246f Mon Sep 17 00:00:00 2001 From: Yiding He Date: Fri, 18 Jan 2019 16:05:23 -0500 Subject: [PATCH 2/5] Updated version number to 2.0.3. --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 966fbcf..d374412 100644 --- a/build.gradle +++ b/build.gradle @@ -70,7 +70,7 @@ if (!project.hasProperty('sonatypeRepo') || apply plugin: 'maven' apply plugin: 'signing' -version = "2.0.2" +version = "2.0.3" group = "com.facebook.conceal" signing { From 933551d9f1a703ac4ed9c2d8b99480a5b7407148 Mon Sep 17 00:00:00 2001 From: Yiding He Date: Fri, 18 Jan 2019 16:30:25 -0500 Subject: [PATCH 3/5] Remove _64 to try to fix the build error. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 687670c..e5febc8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,7 +23,7 @@ android: # Specify at least one system image, # if you need to run emulator(s) during your tests - - sys-img-x86_64-android-19 + - sys-img-x86-android-19 # - sys-img-armeabi-v7a-android-19 # - sys-img-x86-android-17 # TODO: Configure travis to run in more than one emulator From 81a6e276c787d9b63b21f0b828a03d48c829c180 Mon Sep 17 00:00:00 2001 From: Yiding He Date: Fri, 18 Jan 2019 16:41:35 -0500 Subject: [PATCH 4/5] Use 23 since build is using android-23. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e5febc8..4078f9f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,7 +23,7 @@ android: # Specify at least one system image, # if you need to run emulator(s) during your tests - - sys-img-x86-android-19 + - sys-img-x86-android-23 # - sys-img-armeabi-v7a-android-19 # - sys-img-x86-android-17 # TODO: Configure travis to run in more than one emulator From 77eecbde76ca8b6c20f67839a05e2f08721c91f7 Mon Sep 17 00:00:00 2001 From: Yiding He Date: Tue, 22 Jan 2019 15:01:05 -0500 Subject: [PATCH 5/5] Use 23 for emulator. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4078f9f..2e454b0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,7 +40,7 @@ before_install: # Building .AAR, needed for instrumentation tests (they depend on the prebuilt_aar) - ./gradlew build --no-daemon # Emulator Management: Create, Start and Wait - - echo no | android create avd --force -n test -t android-19 --abi armeabi-v7a + - echo no | android create avd --force -n test -t android-23 --abi armeabi-v7a - emulator -avd test -no-audio -no-window & - android-wait-for-emulator - adb shell input keyevent 82 &