Closed houmie closed 3 years ago
Great news, I figured it out.
I copied the file from https://github.com/klaxit/hidden-secrets-gradle-plugin/blob/master/src/main/resources/cpp/CMakeLists.txt and placed it under myProject/src/main/resources/cpp
Now it works. Absolutely brilliant. But I think this step should be mentioned in the documentation. Unless this was meant to be done automatically, and I found a bug. I leave this open to see what others think.
Thank you for this amazing project.
@houmie nice to see you found a work around. The creation of the cpp
folder and the copy of the CMakeLists
is automatic when you run ./gradlew hideSecret
.
If you created the folder and the file before to run the command the copy was not done (because the file already exists) and the project could not compile.
If the documentation is not clear enough feel free to suggest modifications.
I will close this issue since everything works.
@ben-j69 Cheers. Yes, I think I know what has gone wrong. I inserted
android {
...
// Enable NDK build
externalNativeBuild {
cmake {
path "src/main/cpp/CMakeLists.txt"
}
}
}
before the gradle was synced from previous step. This has led to CMakeLists.txt
not exist. I have a habit to put everything in Gradle and then sync it once. The fault was on my side, I had to sync the gradle twice in step 1 and 3 separately. I think we are good.
Do you guys provide this project also for iOS? Such a useful feature to have for protecting API keys. Thanks
@houmie not sure it is a sync issue, when you run ./gradlew hideSecret
it should sync the project, before to add externalNativeBuild
in the gradle file ?
We don't provide the same solution for iOS, but I recommend you Cocoapods Keys which work in the same way.
@ben-j69 I just tested it again. I deleted the cpp folder and ran ./gradlew hideSecret
. And it syncs the files over. You were right.
The steps you mentioned is correct. Yesterday I had mistakenly added externalNativeBuild
in gradle before running ./gradlew hideSecret
. This caused the issue. So the documentation is correct, I didn't pay enough attention. :-)
Thank you for recommending Cocopods Keys, I will try it out.
@houmie thanks for your feedback.
There is a problem with compiling the C code.
When adding this entry in grade build:
And syncing gradle I get this error message:
I went then ahead and created the
cpp
directory and placed an empty text file calledCMakeLists.txt
. Then I could sync the gradle.Then I ran:
It creates four files under
cpp
folder. secrets.cpp, sha256.cpp + headers.Secrets
is also generated for Kotlin.So far so good, but when I run it in the project:
It crashes:
It hasn't built it. What am I missing please? Thank you