Code Monkey home page Code Monkey logo

Comments (6)

LinusU avatar LinusU commented on August 24, 2024 2

Currently using a very annoying workaround where I strip the duplicated classes from the aar file, and then include it as a local dependency:

# Download original
curl http://central.maven.org/maven2/com/facebook/conceal/conceal/2.0.2/conceal-2.0.2.aar > conceal-2.0.2.aar

# Unpack aar
unzip conceal-2.0.2.aar -d temp-folder

# Strip duplicate so files
rm jni/*/libfb.so

# Unpack classes
cd temp-folder
unzip classes.jar -d temp-folder

# Strip duplicate classes
rm -r temp-folder/com/facebook/{jni,proguard,soloader}

# Pack classes
jar cvf classes.jar -C temp-folder/ .
rm -r temp-folder

# Pack aar
cd ..
jar cvf conceal-2.0.2-stripped.aar -C temp-folder/ .
rm -r temp-folder

from conceal.

OleksandrKucherenko avatar OleksandrKucherenko commented on August 24, 2024
configurations {
  repack { transitive = false }
}

ext.concealVersion = "2.0.2"

dependencies {
  /* https://github.com/facebook/conceal/releases */
  repack "com.facebook.conceal:conceal:${concealVersion}"
}

task repackConcealv2(dependsOn: configurations.repack) {
  def generation = "${project.buildDir}/intermediates/repack"
  def conceal = "com.facebook.conceal@${concealVersion}"
  def destination = "${generation}/${conceal}"

  doLast {
    copy {
      from { zipTree(configurations.repack.singleFile) }
      into "${destination}"
    }

    copy {
      from zipTree("${destination}/classes.jar")
      into "${destination}/classes"
    }
  }

  task recreateConcealAarv2(type: Zip) {
    archiveFileName = "com.facebook.conceal-${concealVersion}-patched.aar"
    destinationDirectory = file("${generation}")
    from("${destination}") {
      exclude '**/jni/*/libfb.so'
      exclude '**/classes'
      exclude 'classes.jar'
      rename('classes-patched.jar', 'classes.jar')
    }
  }

  task recreateConcealClassesJarv2(type: Zip) {
    archiveFileName = "classes-patched.jar"
    destinationDirectory = file("${destination}")
    from("${destination}/classes") {
      exclude '**/facebook/jni/'
      exclude '**/facebook/proguard/'
      exclude '**/facebook/soloader/'
    }

    finalizedBy recreateConcealAarv2
  }

  finalizedBy recreateConcealClassesJarv2
}

preBuild.dependsOn(repackConcealv2)

dependencies {
  implementation fileTree(dir: "${project.buildDir}/intermediates/repack", include: ["*-patched.aar"])
}

Outputs:

.
├── com.facebook.conceal-2.0.2-patched.aar
└── [email protected]
    ├── AndroidManifest.xml
    ├── aidl
    ├── assets
    ├── classes
    │   └── com
    │       └── facebook
    │           ├── android
    │           │   └── crypto
    │           │       └── keychain
    │           │           ├── AndroidConceal.class
    │           │           ├── AndroidCryptoLibrary.class
    │           │           ├── SecureRandomFix$LinuxPRNGSecureRandom.class
    │           │           ├── SecureRandomFix$LinuxPRNGSecureRandomProvider.class
    │           │           ├── SecureRandomFix$LocalSecureRandom.class
    │           │           ├── SecureRandomFix.class
    │           │           └── SharedPrefsBackedKeyChain.class
    │           ├── cipher
    │           │   ├── Cipher$DecryptStream.class
    │           │   ├── Cipher$EncryptStream.class
    │           │   ├── Cipher.class
    │           │   ├── IntegrityException.class
    │           │   ├── Mac$DecryptStream.class
    │           │   ├── Mac$EncryptStream.class
    │           │   ├── Mac.class
    │           │   └── jni
    │           │       ├── CipherHybrid.class
    │           │       ├── DecryptHybrid.class
    │           │       ├── EncryptHybrid.class
    │           │       ├── MacDecoderHybrid.class
    │           │       ├── MacEncoderHybrid.class
    │           │       └── PBKDF2Hybrid.class
    │           ├── crypto
    │           │   ├── BuildConfig.class
    │           │   ├── CheckedKeyChain.class
    │           │   ├── Conceal.class
    │           │   ├── Crypto.class
    │           │   ├── CryptoConfig.class
    │           │   ├── Entity.class
    │           │   ├── MacConfig.class
    │           │   ├── VersionCodes.class
    │           │   ├── exception
    │           │   │   ├── CryptoInitializationException.class
    │           │   │   └── KeyChainException.class
    │           │   ├── keychain
    │           │   │   └── KeyChain.class
    │           │   ├── keygen
    │           │   │   └── PasswordBasedKeyDerivation.class
    │           │   ├── proguard
    │           │   │   └── annotations
    │           │   │       ├── DoNotStrip.class
    │           │   │       ├── InternalBuildOnly.class
    │           │   │       └── KeepGettersAndSetters.class
    │           │   ├── streams
    │           │   │   ├── BetterCipherInputStream.class
    │           │   │   └── TailInputStream.class
    │           │   └── util
    │           │       ├── Assertions.class
    │           │       ├── NativeCryptoLibrary.class
    │           │       └── SystemNativeCryptoLibrary.class
    │           ├── jni
    │           │   ├── Countable.class
    │           │   ├── CpuCapabilitiesJni.class
    │           │   ├── DestructorThread$1.class
    │           │   ├── DestructorThread$Destructor.class
    │           │   ├── DestructorThread$DestructorList.class
    │           │   ├── DestructorThread$DestructorStack.class
    │           │   ├── DestructorThread$Terminus.class
    │           │   ├── DestructorThread.class
    │           │   ├── HybridClassBase.class
    │           │   ├── HybridData$Destructor.class
    │           │   ├── HybridData.class
    │           │   ├── IteratorHelper.class
    │           │   ├── JniTerminateHandler.class
    │           │   ├── MapIteratorHelper.class
    │           │   ├── NativeRunnable.class
    │           │   └── ThreadScopeSupport.class
    │           ├── proguard
    │           │   └── annotations
    │           │       ├── DoNotStrip.class
    │           │       └── KeepGettersAndSetters.class
    │           └── soloader
    │               ├── Api18TraceUtils.class
    │               ├── ApkSoSource$ApkUnpacker.class
    │               ├── ApkSoSource.class
    │               ├── DirectorySoSource.class
    │               ├── DoNotOptimize.class
    │               ├── Elf32_Dyn.class
    │               ├── Elf32_Ehdr.class
    │               ├── Elf32_Phdr.class
    │               ├── Elf32_Shdr.class
    │               ├── Elf64_Dyn.class
    │               ├── Elf64_Ehdr.class
    │               ├── Elf64_Phdr.class
    │               ├── Elf64_Shdr.class
    │               ├── ExoSoSource$1.class
    │               ├── ExoSoSource$ExoUnpacker$FileBackedInputDsoIterator.class
    │               ├── ExoSoSource$ExoUnpacker.class
    │               ├── ExoSoSource$FileDso.class
    │               ├── ExoSoSource.class
    │               ├── ExtractFromZipSoSource$1.class
    │               ├── ExtractFromZipSoSource$ZipDso.class
    │               ├── ExtractFromZipSoSource$ZipUnpacker$ZipBackedInputDsoIterator.class
    │               ├── ExtractFromZipSoSource$ZipUnpacker.class
    │               ├── ExtractFromZipSoSource.class
    │               ├── FileLocker.class
    │               ├── MergedSoMapping.class
    │               ├── MinElf$ElfError.class
    │               ├── MinElf.class
    │               ├── NativeLibrary.class
    │               ├── NoopSoSource.class
    │               ├── SoFileLoader.class
    │               ├── SoLoader$1.class
    │               ├── SoLoader$Api14Utils.class
    │               ├── SoLoader$WrongAbiError.class
    │               ├── SoLoader.class
    │               ├── SoSource.class
    │               ├── SysUtil$LollipopSysdeps.class
    │               ├── SysUtil.class
    │               ├── SystemLoadLibraryWrapper.class
    │               ├── UnpackingSoSource$1.class
    │               ├── UnpackingSoSource$Dso.class
    │               ├── UnpackingSoSource$DsoManifest.class
    │               ├── UnpackingSoSource$InputDso.class
    │               ├── UnpackingSoSource$InputDsoIterator.class
    │               ├── UnpackingSoSource$Unpacker.class
    │               └── UnpackingSoSource.class
    ├── classes-patched.jar
    ├── classes.jar
    ├── jni
    │   ├── arm64-v8a
    │   │   ├── libconcealjni.so
    │   │   └── libfb.so
    │   ├── armeabi
    │   │   ├── libconcealjni.so
    │   │   └── libfb.so
    │   ├── armeabi-v7a
    │   │   ├── libconcealjni.so
    │   │   └── libfb.so
    │   ├── x86
    │   │   ├── libconcealjni.so
    │   │   └── libfb.so
    │   └── x86_64
    │       ├── libconcealjni.so
    │       └── libfb.so
    ├── libs
    └── res

from conceal.

Kranthi94 avatar Kranthi94 commented on August 24, 2024

Any Update on this..?

from conceal.

Kranthi94 avatar Kranthi94 commented on August 24, 2024

@OleksandrKucherenko , I followed your approach but after that native library loading is failing.
Throwing "libconcealjni.so" file is not found. Did you face any such issue..?

from conceal.

OleksandrKucherenko avatar OleksandrKucherenko commented on August 24, 2024

Throwing "libconcealjni.so" file is not found. Did you face any such issue..?

Yes, I saw that before... it happens due to the not properly found @aar file.

The workaround is to divide the build process into two steps:

  • repack and compose a patched aar
  • copy patched aar into project folder and include it directly (issue is in gradle android plugin that cannot recognize aar archive, it only understands well JARs)

from conceal.

Kranthi94 avatar Kranthi94 commented on August 24, 2024

We had patched the aar according to @LinusU. But still facing the error. By the way, we are using conceal 2.0.2

from conceal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.