Cipher.so icon indicating copy to clipboard operation
Cipher.so copied to clipboard

Can not Add Cipher.so to my project

Open HoseinGhadiri opened this issue 4 years ago • 17 comments

Hi guys. i'm trying to add this in my project. but i get error. all link has 404 error.

`A problem occurred configuring root project 'HamrahBankAnsarV3'.

Could not resolve all artifacts for configuration ':classpath'. Could not find com.github.MEiDIK:Cipher.so:dev-SNAPSHOT. Searched in the following locations: - https://dl.google.com/dl/android/maven2/com/github/MEiDIK/Cipher.so/dev-SNAPSHOT/maven-metadata.xml - https://dl.google.com/dl/android/maven2/com/github/MEiDIK/Cipher.so/dev-SNAPSHOT/Cipher.so-dev-SNAPSHOT.pom - https://dl.google.com/dl/android/maven2/com/github/MEiDIK/Cipher.so/dev-SNAPSHOT/Cipher.so-dev-SNAPSHOT.jar - https://jitpack.io/com/github/MEiDIK/Cipher.so/dev-SNAPSHOT/maven-metadata.xml - https://jitpack.io/com/github/MEiDIK/Cipher.so/dev-SNAPSHOT/Cipher.so-dev-SNAPSHOT.pom - https://jitpack.io/com/github/MEiDIK/Cipher.so/dev-SNAPSHOT/Cipher.so-dev-SNAPSHOT.jar - https://plugins.gradle.org/m2/com/github/MEiDIK/Cipher.so/dev-SNAPSHOT/maven-metadata.xml - https://plugins.gradle.org/m2/com/github/MEiDIK/Cipher.so/dev-SNAPSHOT/Cipher.so-dev-SNAPSHOT.pom - https://plugins.gradle.org/m2/com/github/MEiDIK/Cipher.so/dev-SNAPSHOT/Cipher.so-dev-SNAPSHOT.jar Required by: project :

Possible solution:

  • Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html

`

HoseinGhadiri avatar Jul 17 '21 07:07 HoseinGhadiri

Facing same issue @linisme

Farrukh381 avatar Jul 26 '21 11:07 Farrukh381

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

com.github.linisme:Cipher.so:8581777457

Farrukh381 avatar Jul 26 '21 11:07 Farrukh381

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.

AdeelTariq avatar Jul 29 '21 06:07 AdeelTariq

it works

Farrukh381 avatar Jul 30 '21 12:07 Farrukh381

@AdeelTariq Thanks! it work for me too.

HoseinGhadiri avatar Aug 02 '21 07:08 HoseinGhadiri

@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?

simon-vogel avatar Aug 10 '21 06:08 simon-vogel

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.

AdeelTariq avatar Aug 10 '21 06:08 AdeelTariq

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 ...)

simon-vogel avatar Aug 10 '21 07:08 simon-vogel

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

AdeelTariq avatar Aug 10 '21 07:08 AdeelTariq

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");

simon-vogel avatar Aug 10 '21 08:08 simon-vogel

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

AdeelTariq avatar Aug 10 '21 08:08 AdeelTariq

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

simon-vogel avatar Aug 10 '21 08:08 simon-vogel

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

CaptainSilva avatar Aug 31 '21 10:08 CaptainSilva

I'm guessing you are rebuilding the project which runs the 'clean' task first and removes any autogenerated code.

The proceeding build should then generate these files again but I think the order of the tasks may be broken so some tasks access the files before they are generated and throw the error.

Can you try running the make CMake task and then simply build the project (without the clean task that is removing the build folder)

On Tue, 31 Aug 2021, 3:33 pm CaptainSilva, @.***> wrote:

I followed @AdeelTariq https://github.com/AdeelTariq guidelines and in the end im getting this error [image: Screen Shot 2021-08-31 at 11 20 35] https://user-images.githubusercontent.com/10654995/131487043-1ab8cde8-e9e9-483a-9d43-6592d9d181b4.png

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 [image: Screen Shot 2021-08-31 at 11 27 49] https://user-images.githubusercontent.com/10654995/131487094-bac10f6e-dcb6-4686-81f6-4a6209b9f16b.png

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

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/linisme/Cipher.so/issues/45#issuecomment-909111481, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA52ELUGQNO7AIUIBYPICHLT7SVWBANCNFSM5AQZYB2A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

AdeelTariq avatar Aug 31 '21 11:08 AdeelTariq

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

CaptainSilva avatar Aug 31 '21 15:08 CaptainSilva

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.

simon-vogel avatar Sep 01 '21 18:09 simon-vogel

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

hgaharwar avatar Sep 04 '21 13:09 hgaharwar