Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not Add Cipher.so to my project #45

Open
HoseinGhadiri opened this issue Jul 17, 2021 · 17 comments
Open

Can not Add Cipher.so to my project #45

HoseinGhadiri opened this issue Jul 17, 2021 · 17 comments

Comments

@HoseinGhadiri HoseinGhadiri changed the title Coud'nt Add Cipher.so to my project can not Add Cipher.so to my project Jul 17, 2021
@HoseinGhadiri HoseinGhadiri changed the title can not Add Cipher.so to my project Can not Add Cipher.so to my project Jul 17, 2021
@Farrukh381
Copy link

Facing same issue @linisme

@Farrukh381
Copy link

Problem is probably due to @linisme changing his username.
This is working for me

com.github.linisme:Cipher.so:8581777457

@AdeelTariq
Copy link

Jitpack builds are failing and this repository is not the only one effected. Maybe @linisme can fix the problem but they are not maintaining the repo anymore. So the workaround for now is to add a jar of the library to your project. Easiest is to find the cached jar file of the library on your system. Obviously if you never used the library before you won't have a cached version. In that case you can build the jar file on your own.

To get the cached file, find the gradle cache directory on your system and go to ~/.gradle/caches/modules-2/files-2.1/com.github.MEiDIK or ~/.gradle/caches/modules-2/files-2.1/com.github.linisme

In there you'll find the cached jar. Copy it to your project. Mine is inside the app/libs folder.

Next add this one line to your top level gradle file:

buildscript {
    repositories {
        …
        flatDir dirs: "app/libs"    // <-- Relative path to where the jar file is
    }
    dependencies {
        …
    }
}

Your project should compile now.
Also the gradle directory may be in a different location. Or your project may be structured differently. So adjust accordingly.

@Farrukh381
Copy link

it works

@HoseinGhadiri
Copy link
Author

@AdeelTariq Thanks! it work for me too.

@simon-vogel
Copy link

@AdeelTariq, can't get it work:

A problem occurred evaluating project ':app'.
> Plugin with id 'cipher.so' not found.

Has to be something under 'dependencies' like this?

    dependencies {
        ...
        classpath files('app/libs/Cipher.so-dev-SNAPSHOT.jar')
        ...
    }

btw: the .jar file is inside app/libs/ as well.

Do you have any suggestions?

@AdeelTariq
Copy link

In the dependencies block you don't need to change anything. Following line should work same as before:
classpath 'com.github.MEiDIK:Cipher.so:dev-SNAPSHOT

Just follow the readme for setup as before and then follow my workaround above to add the jar.

@simon-vogel
Copy link

Thanks, my mistake, it works.
But if I build the app it seems to be that the extern-keys.h file isn't generated:

...\app\build\cipher.so\src\main\cpp\cipher-lib.cpp:6:10: fatal error: 'include/extern-keys.h' file not found

This is inside my module build.gradle:

apply plugin: 'cipher.so'
apply plugin: 'com.android.application'

... 

cipher.so {
    keys {
        val3 {
            value = 'key1'
        }
        val2 {
            value = 'key2'
        }
        val1 {
            value = 'key3'
        }
    }
    encryptSeed = 'secret'
}

what did I do wrong? (It worked without problems in the past ...)

@AdeelTariq
Copy link

That happened to me too. But I think its due to a new Android Studio setting that is set by default now.
Go to Android Studio preferences and then experimental and uncheck this 'Do not build Gradle task list' setting.

image

As far as I can tell this option is preventing the Gradle tasks from running and building the keys file. Then Gradle sync the project so tasks list will be created.

Next I just run the generateReleaseCipherSoHeader Gradle task manually to generate the keys file:

image

@simon-vogel
Copy link

Okay, now the header files are generated, thanks.

But if I run the app, the "cipher-lib.so" file not found :

java.lang.UnsatisfiedLinkError: dlopen failed: library "libcipher-lib.so" not found
        at java.lang.Runtime.loadLibrary0(Runtime.java:1087)
        at java.lang.Runtime.loadLibrary0(Runtime.java:1008)
        at java.lang.System.loadLibrary(System.java:1664)
        at net.idik.lib.cipher.so.CipherCore.<clinit>(CipherCore.java:9)
        at net.idik.lib.cipher.so.CipherCore.get(CipherCore.java:18)

the line where the error occurs is:
System.loadLibrary("cipher-lib");

@AdeelTariq
Copy link

Try rebuilding the project and make sure all these files are generated
image

@simon-vogel
Copy link

They are all there. I also checked the path inside the .apk file, the files are inside the correct directory too.

@CaptainSilva
Copy link

I followed @AdeelTariq guidelines and in the end im getting this error
Screen Shot 2021-08-31 at 11 20 35

The file is not generated in the path showed in the image

If i generate manually it appears in the refered location but when i build the project the file is erased
Screen Shot 2021-08-31 at 11 27 49

What am i missing?
Note: The .jar is on the app/libs folder as well

@AdeelTariq
Copy link

AdeelTariq commented Aug 31, 2021 via email

@CaptainSilva
Copy link

Yes @AdeelTariq that was the issue
I have to just build the project and not rebuild, and in case the headers are not there anymore I need to rerun the generateCipherSoHeader

With fastlane its smoother, I can call grade clean, then grade generateCipherSo and then assembleRelease

I tried to schedule this task to run before the Build task(and in another attempt to run right after the clean task)but it does not work and I can’t find for sure what’s clearing the files

I which there was a better solution or approach to this
To keep using the rebuild function or to just not have to handle this so frequently

@simon-vogel
Copy link

Okay, now the header files are generated, thanks.

But if I run the app, the "cipher-lib.so" file not found :

java.lang.UnsatisfiedLinkError: dlopen failed: library "libcipher-lib.so" not found
        at java.lang.Runtime.loadLibrary0(Runtime.java:1087)
        at java.lang.Runtime.loadLibrary0(Runtime.java:1008)
        at java.lang.System.loadLibrary(System.java:1664)
        at net.idik.lib.cipher.so.CipherCore.<clinit>(CipherCore.java:9)
        at net.idik.lib.cipher.so.CipherCore.get(CipherCore.java:18)

the line where the error occurs is:
System.loadLibrary("cipher-lib");

For all with the same Problem, the following part blocked that the libcipher-lib.so was packed into the .apk file:

tasks.whenTaskAdded { task ->
        // something specific
}

I replaced it with:

afterEvaluate {
    android.productFlavors.all {
        flavor ->
    }
}

So it is working now. Thank you for all your help so far @AdeelTariq!

@CaptainSilva I found a solution to execute 'generateCipherSo' automatically.
Just add this inside the build.gradle for your individual flavors (if you have different keys for different flavors):

afterEvaluate {
    android.productFlavors.all {
        flavor ->
            tasks."extractDeepLinksFalvor1Debug".finalizedBy(generateFlavor1DebugCipherSoHeader)
            tasks."extractDeepLinksFalvor2Debug".finalizedBy(generateFlavor2DebugCipherSoHeader)
            ...
    }
}

So the 'extern-keys.h' will be procuced just before task 'buildCMakeDebug' , where it's needed.

If you do not have different keys you can use the 'configureCMakeDebug' task:

afterEvaluate {
    android.productFlavors.all {
        flavor ->
            tasks."configureCMakeDebug".finalizedBy(generateSomeFlavorDebugCipherSoHeader)
            ...
    }
}

Hope it helps.

@hgaharwar
Copy link

Caused by: groovy.lang.MissingPropertyException: Could not set unknown property 'encryptSeed' for SoExt{keys=[KeyExt{name='key', value='555555'}], signature=''} of type net.idik.lib.cipher.so.extension.SoExt.

@AdeelTariq any help buddy on this error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants