Git Product home page Git Product logo

Comments (13)

ben-j69 avatar ben-j69 commented on May 29, 2024 1

Dot not use [ and ] they means the parameter is optional in the documentation. So if your app has the package com.example.dummy the command line to hide a secret should look like

gradle hideSecret -Pkey=ilovemylife -Ppackage=com.example.dummy

To check that the plugin is well integrated in your app you can run a simple command :
gradle obfuscate -Pkey=ilovemylife should succeed and display an obfuscated key as hexadecimal array.

from hidden-secrets-gradle-plugin.

kuabhish avatar kuabhish commented on May 29, 2024 1

Awesome bro .. that worked ..

I saw this output :

### KEY NAME ###
TNWDPJXI

### SECRET ###
ilovemylife

### PACKAGE NAME ###
com.example.dummy

### OBFUSCATED SECRET ###
{ 0xf, 0x5a, 0xb, 0x10, 0x51, 0x55, 0x41, 0x5c, 0xc, 0x54, 0x5d }
You can now get your secret key by calling : Secrets().getTNWDPJXI(packageName)

But another error I see now:

C:\Users\abhiv\AndroidStudioProjects\dummy\app\src\main\java\com\example\dummy\MainActivity.java:13: error: cannot find symbol
        String key = new Secrets().getTNWDPJXI(getPackageName());
                         ^
  symbol:   class Secrets
  location: class MainActivity

where my code is

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        String key = new Secrets().getTNWDPJXI(getPackageName());
        System.out.println(key);

from hidden-secrets-gradle-plugin.

kuabhish avatar kuabhish commented on May 29, 2024 1

Hey @ben-j69
Thanks for all the help. It is solved.

from hidden-secrets-gradle-plugin.

ben-j69 avatar ben-j69 commented on May 29, 2024

Hello @kuabhish how did you integrate the plugin in your project, can you share your gradle file please ? Did you sync your project after ? Do you see logs about fetching the plugin ?

from hidden-secrets-gradle-plugin.

kuabhish avatar kuabhish commented on May 29, 2024

Hey @ben-j69 yes i have tried to inteegrate best to my knowledge. I have attached both build.gradle files. (app level and root level)
Yes i synced the project. Yeah the logs appeared i think.

plugins {
    id 'com.android.application'
}
apply plugin: 'kotlin-android'

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.2"

    defaultConfig {
        applicationId "com.example.testing"
        minSdkVersion 16
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    // Enable NDK build
    externalNativeBuild {
        cmake {
//            version "3.9.1"
            path "src/main/resources/cpp/CMakeLists.txt"
        }
    }
}

dependencies {

    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'com.google.android.material:material:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

    implementation 'com.github.bumptech.glide:glide:4.11.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'

    implementation platform('com.google.firebase:firebase-bom:26.1.0')
    implementation 'com.google.firebase:firebase-analytics'
    implementation 'com.google.firebase:firebase-dynamic-links'
    implementation 'com.google.firebase:firebase-messaging'
    implementation "androidx.core:core-ktx:1.3.2"
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
repositories {
    mavenCentral()
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    ext.kotlin_version = '1.4.20'
    repositories {
        google()
        jcenter()
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.1.1"
        classpath "com.klaxit.hiddensecrets:HiddenSecretsPlugin:0.1.0"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

apply plugin: 'com.klaxit.hiddensecrets'

from hidden-secrets-gradle-plugin.

ben-j69 avatar ben-j69 commented on May 29, 2024

Thanks, in the README.md it is indicated that you must add the plugin in your app level gradle file, not in the top level one. Please follow the README step by step to use the plugin. That might fix your issue ;)

from hidden-secrets-gradle-plugin.

kuabhish avatar kuabhish commented on May 29, 2024

Hey @ben-j69

Now I am seeing new error.

C:\Users\abhiv\AndroidStudioProjects\dummy>gradle hideSecret -Pkey=ilovemylife [-Ppackage=com.example.dummy] --info
Initialized native services in: C:\Users\abhiv\.gradle\native
Found daemon DaemonInfo{pid=2760, address=[a915fb1f-4c43-48cb-b260-6fa1c69a3233 port:63557, addresses:[/127.0.0.1]], state=Idle, lastBusy=1606660822766, context=DefaultDaemonContext[uid=99d43b77-9ff7-492d-a3fb-4c6c6a4cad86,javaHome=C:\Program Files\Java\jre1.8.0_271,daemonRegistryDir=C:\Users\abhiv\.gradle\daemon,pid=2760,idleTimeout=10800000,priority=NORMAL,daemonOpts=-XX:MaxMetaspaceSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xms256m,-Xmx512m,-Dfile.encoding=windows-1252,-Duser.country=US,-Duser.language=en,-Duser.variant]} however its context does not match the desired criteria.
At least one daemon option is different.
Wanted: DefaultDaemonContext[uid=null,javaHome=C:\Program Files\Java\jre1.8.0_271,daemonRegistryDir=C:\Users\abhiv\.gradle\daemon,pid=13852,idleTimeout=null,priority=NORMAL,daemonOpts=-Xmx2048m,-Dfile.encoding=UTF-8,-Duser.country=US,-Duser.language=en,-Duser.variant]
Actual: DefaultDaemonContext[uid=99d43b77-9ff7-492d-a3fb-4c6c6a4cad86,javaHome=C:\Program Files\Java\jre1.8.0_271,daemonRegistryDir=C:\Users\abhiv\.gradle\daemon,pid=2760,idleTimeout=10800000,priority=NORMAL,daemonOpts=-XX:MaxMetaspaceSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xms256m,-Xmx512m,-Dfile.encoding=windows-1252,-Duser.country=US,-Duser.language=en,-Duser.variant]

  Looking for a different daemon...
Found daemon DaemonInfo{pid=2288, address=[00b13798-c963-4a5c-b10d-71281a7ce389 port:65229, addresses:[/127.0.0.1]], state=Idle, lastBusy=1606661101331, context=DefaultDaemonContext[uid=4d2f88f4-aade-4fa4-b7df-925eb9883766,javaHome=C:\Program Files\Java\jre1.8.0_271,daemonRegistryDir=C:\Users\abhiv\.gradle\daemon,pid=2288,idleTimeout=10800000,priority=NORMAL,daemonOpts=-Xmx2048m,-Dfile.encoding=windows-1252,-Duser.country=US,-Duser.language=en,-Duser.variant]} however its context does not match the desired criteria.
At least one daemon option is different.
Wanted: DefaultDaemonContext[uid=null,javaHome=C:\Program Files\Java\jre1.8.0_271,daemonRegistryDir=C:\Users\abhiv\.gradle\daemon,pid=13852,idleTimeout=null,priority=NORMAL,daemonOpts=-Xmx2048m,-Dfile.encoding=UTF-8,-Duser.country=US,-Duser.language=en,-Duser.variant]
Actual: DefaultDaemonContext[uid=4d2f88f4-aade-4fa4-b7df-925eb9883766,javaHome=C:\Program Files\Java\jre1.8.0_271,daemonRegistryDir=C:\Users\abhiv\.gradle\daemon,pid=2288,idleTimeout=10800000,priority=NORMAL,daemonOpts=-Xmx2048m,-Dfile.encoding=windows-1252,-Duser.country=US,-Duser.language=en,-Duser.variant]

  Looking for a different daemon...
The client will now receive all logging from the daemon (pid: 9364). The daemon log file: C:\Users\abhiv\.gradle\daemon\6.5.1\daemon-9364.out.log
Starting 9th build in daemon [uptime: 14 mins 16.951 secs, performance: 96%]
Using 16 worker leases.
Starting Build
Settings evaluated using settings file 'C:\Users\abhiv\AndroidStudioProjects\dummy\settings.gradle'.
Projects loaded. Root project using build file 'C:\Users\abhiv\AndroidStudioProjects\dummy\build.gradle'.
Included projects: [root project 'dummy', project ':app']

> Configure project :
Evaluating root project 'dummy' using build file 'C:\Users\abhiv\AndroidStudioProjects\dummy\build.gradle'.
Invalidating in-memory cache of C:\Users\abhiv\.gradle\caches\journal-1\file-access.bin

> Configure project :app
Evaluating project ':app' using build file 'C:\Users\abhiv\AndroidStudioProjects\dummy\app\build.gradle'.
Compiling build file 'C:\Users\abhiv\AndroidStudioProjects\dummy\app\build.gradle' using SubsetScriptTransformer.
Compiling build file 'C:\Users\abhiv\AndroidStudioProjects\dummy\app\build.gradle' using BuildScriptTransformer.
Invalidating in-memory cache of C:\Users\abhiv\AndroidStudioProjects\dummy\.gradle\buildOutputCleanup\outputFiles.bin
Creating configuration androidTestUtil
Unzip jar to C:\Users\abhiv\AndroidStudioProjects\dummy\app\build/hidden-secrets-tmp
android.ndkVersion from module build.gradle is [not set]
android.ndkPath from module build.gradle is not set
ndk.dir in local.properties is not set
Not considering ANDROID_NDK_HOME because support was removed after deprecation period.
sdkFolder is C:\Users\abhiv\AppData\Local\Android\Sdk
Because no explicit NDK was requested, the default version [21.1.6352462] for this Android Gradle Plugin will be used
All projects evaluated.
Analytics other plugin to proto: Unknown plugin type com.klaxit.hiddensecrets.HiddenSecretsPlugin expected enum COM_KLAXIT_HIDDENSECRETS_HIDDENSECRETSPLUGIN

FAILURE: Build failed with an exception.

* What went wrong:
Task '[-Ppackage=com.example.dummy]' not found in root project 'dummy'.

* Try:
Run gradle tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s

If you want to see my gradle files I will also attach them ..:

apply plugin: 'com.android.application'
apply plugin: 'com.klaxit.hiddensecrets'

android {
    compileSdkVersion 28
    buildToolsVersion "28.0.3"

    defaultConfig {
        applicationId "com.example.dummy"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    externalNativeBuild {
        cmake {
            path "src/main/cpp/CMakeLists.txt" ////////////////// this part worked without adding the files 
        }
    }
}

dependencies {
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.2.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}

repositories {
    mavenCentral()
}


// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    ext.kotlin_version = '1.4.20'
    repositories {
        google()
        jcenter()
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.1.1"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "com.klaxit.hiddensecrets:HiddenSecretsPlugin:0.1.0"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}


allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

from hidden-secrets-gradle-plugin.

ben-j69 avatar ben-j69 commented on May 29, 2024

obfuscate is only a command to display keys it does nothing in your project.

To copy kotlin, c++ and really hide a key you need to use the command hideSecret Then you should find a Secrets.kt file in your project that you can import anywhere.

from hidden-secrets-gradle-plugin.

kuabhish avatar kuabhish commented on May 29, 2024

I tried both commands -
gradle obfuscate -Pkey=ilovemylife
and after this
gradle hideSecret -Pkey=ilovemylife -Ppackage=com.example.dummy
i got this output

### KEY NAME ###
TNWDPJXI

### SECRET ###
ilovemylife

### PACKAGE NAME ###
com.example.dummy

### OBFUSCATED SECRET ###
{ 0xf, 0x5a, 0xb, 0x10, 0x51, 0x55, 0x41, 0x5c, 0xc, 0x54, 0x5d }
You can now get your secret key by calling : Secrets().getTNWDPJXI(packageName)

and I found Secrets.kt in my project in the same directory as MainActivity.
I imported and it didn't show any error there here:

        String key = new Secrets().getTNWDPJXI(getPackageName());
        System.out.println(key);

But while building or running the app it shows error:

C:\Users\abhiv\AndroidStudioProjects\dummy\app\src\main\java\com\example\dummy\MainActivity.java:13: error: cannot find symbol
        String key = new Secrets().getTNWDPJXI(getPackageName());
                         ^
  symbol:   class Secrets
  location: class MainActivity

from hidden-secrets-gradle-plugin.

ben-j69 avatar ben-j69 commented on May 29, 2024

It looks like the plugin work well if Secrets.kt and the C++ code is n your app 👍 .

If your app does not compile it is not because of the plugin. You should check again your imports, Android Studio would not let you compile with errors like this.

from hidden-secrets-gradle-plugin.

adsharmavik avatar adsharmavik commented on May 29, 2024

It looks like the plugin work well if Secrets.kt and the C++ code is n your app 👍 .

If your app does not compile it is not because of the plugin. You should check again your imports, Android Studio would not let you compile with errors like this.

Getting same error

from hidden-secrets-gradle-plugin.

adsharmavik avatar adsharmavik commented on May 29, 2024

Hey @ben-j69
Thanks for all the help. It is solved.

how to resolved this error

from hidden-secrets-gradle-plugin.

Rohit687 avatar Rohit687 commented on May 29, 2024

Hey @ben-j69
Thanks for all the help. It is solved.

Please help me to resolve this issue. I am using java.

from hidden-secrets-gradle-plugin.

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.