GithubHelp home page GithubHelp logo

greybax / cordova-plugin-proguard Goto Github PK

View Code? Open in Web Editor NEW
51.0 5.0 259.0 52 KB

:white_square_button: Cordova Plugin for ProGuard

License: MIT License

Makefile 18.59% Shell 61.50% JavaScript 19.91%
cordova cordova-plugin proguard proguard-rules android hybrid-apps cordova-android-plugin cordova-android optimization-tools bytecode

cordova-plugin-proguard's Introduction

cordova-plugin-proguard

NPM version npm

Cordova plugin which activates ProGuard and minification for debug and release builds in your cordova mobile application.

What is ProGuard?

ProGuard is the open source optimizer for Java bytecode

You can read more about it on ProGuard official website and on android developer portal

How to use

  • If you already have installed Android Studio then seems you already have installed ProGuard on your machine. If no, then you should download and install it manually from ProGuard official website.
  • cordova plugin add cordova-plugin-proguard - this command will configure your build.gradle file and copy proguard-custom.txt to ${androidPlatformDirectory}/assets/www/proguard-custom.txt

Customization

proguard-custom.txt file contains some basic rules for your cordova mobile app. Feel free to fork this repo and modify it as you want.

You can also to check out some Android ProGuard snippets

If you want to add rules to this proguard-custom.txt, please create your own proguard-custom.txt and add this to your projectroot folder. Upon installing the proguard-plugin, the rules will be added to your project. Example rules for various situations will be in the commented section in the plugin proguard-custom.txt.

ionic cordova platform rm android
ionic cordova platform add android

History

  • v1.0.0 - supports Cordova version <7
  • v2.0.0 - supports Cordova version 7+ (thanks to @SujitSingh)

Why I've done this plugin?

https://alfilatov.com/posts/how-to-setup-proguard-in-cordova-application/

License

MIT © Aleksandr Filatov

cordova-plugin-proguard's People

Contributors

dependabot[bot] avatar gerarddus avatar greybax avatar hanzofm avatar renovate-bot avatar rodrigograca31 avatar sujitsingh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

cordova-plugin-proguard's Issues

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because we are using your CI build statuses to figure out when to notify you about breaking changes.

Since we did not receive a CI status on the greenkeeper/initial branch, we assume that you still need to configure it.

If you have already set up a CI for this repository, you might need to check your configuration. Make sure it will run on all new branches. If you don’t want it to run on every branch, you can whitelist branches starting with greenkeeper/.

We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

No optional proguard-custom.txt found in projectRoot

Screenshot 2021-11-24 at 12 04 44 PM

Hi I want to use this plugin to remove warning when submitting in playstore but there is no proguard file generated, is there someone who can help me with this issue ? or should i manually create a proguard file ?

Progurad plugin conflict with firebase-x

i am facing this issue when i am trying to generate release build of android application.and i am check lot of things after then i got the issue there is a conflict between firebase-x plugin and cordova plugin.so please help me how can i resolved this issue

both plugin important for me here

What went wrong:
A problem was found with the configuration of task ':app:uploadCrashlyticsMappingFileRelease' (type 'UploadMappingFileTask').
In plugin 'com.google.firebase.crashlytics.buildtools.gradle.CrashlyticsPlugin' type 'com.google.firebase.crashlytics.buildtools.gradle.tasks.UploadMappingFileTask' property 'googleServicesResourceRoot' doesn't have a configured value.

Reason: This property isn't marked as optional and no value has been configured.

Possible solutions:

Assign a value to 'googleServicesResourceRoot'.
Mark property 'googleServicesResourceRoot' as optional.

FileNotFoundException building APK

When I run cordova build android the build fails with this error:

Warning: Exception while processing task java.io.FileNotFoundException: /home/user/project/platforms/android/src/main/assets/www/proguard-custom.txt (No such file or directory)

Not working

Hello,
I have added this plugin to my ionic project. After building the app, the source code still looks same! What all should I need to add proguard-custom.txt inorder to obfuscate all js files in my project?

Add com.android.vending.billing

I think it might be a good idea to add something like:

-keep class com.android.vending.billing.** { *; }

to the proguard-custom.txt.
Because obfuscation is probably used when the app has subscriptions/inapppurchases etc.
Maybe there's a way of making it optional when installing the plugin?

when i add custom rules it's not coming

when i add custom rules under plugin->cordova-plugin-proguard ->proguard-custom.txt but the changes not available under->platforms->android->app->src->proguard-custom.txt .

kindly lets us know where i have to add more rules in cordova project

Crash on start app with latest version

Hi, when I install this plugin on my app with last version of cordova Android (7.1.4) it crashes on start.

Previously with version 1.0 of the plugin and cordova android 6.4.4 it works correctly. Now with version 2.0 of the plugin and cordova Android 7.1.4 crashes at startup with this logcat:

 --------- beginning of crash
2018-12-14 09:52:43.125 21666-21666/es.gva.mobilendo.aire E/AndroidRuntime: FATAL EXCEPTION: main
    Process: es.gva.mobilendo.aire, PID: 21666
    java.lang.RuntimeException: Unable to start activity ComponentInfo{es.gva.mobilendo.aire/es.gva.mobilendo.aire.MainActivity}: java.lang.RuntimeException: Failed to create webview. 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2984)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3045)
        at android.app.ActivityThread.-wrap14(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1642)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6776)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)
     Caused by: java.lang.RuntimeException: Failed to create webview. 
        at org.apache.cordova.CordovaWebViewImpl.createEngine(CordovaWebViewImpl.java:82)
        at org.apache.cordova.CordovaActivity.makeWebViewEngine(CordovaActivity.java:206)
        at org.apache.cordova.CordovaActivity.makeWebView(CordovaActivity.java:202)
        at org.apache.cordova.CordovaActivity.init(CordovaActivity.java:146)
        at org.apache.cordova.CordovaActivity.loadUrl(CordovaActivity.java:224)
        at es.gva.mobilendo.aire.MainActivity.onCreate(MainActivity.java:39)
        at android.app.Activity.performCreate(Activity.java:6955)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2927)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3045) 
        at android.app.ActivityThread.-wrap14(ActivityThread.java) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1642) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:154) 
        at android.app.ActivityThread.main(ActivityThread.java:6776) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386) 
     Caused by: java.lang.NoSuchMethodException: <init> [class android.content.Context, class org.apache.cordova.CordovaPreferences]
        at java.lang.Class.getConstructor0(Class.java:2204)
        at java.lang.Class.getConstructor(Class.java:1683)
        at org.apache.cordova.CordovaWebViewImpl.createEngine(CordovaWebViewImpl.java:79)
        at org.apache.cordova.CordovaActivity.makeWebViewEngine(CordovaActivity.java:206) 
        at org.apache.cordova.CordovaActivity.makeWebView(CordovaActivity.java:202) 
        at org.apache.cordova.CordovaActivity.init(CordovaActivity.java:146) 
        at org.apache.cordova.CordovaActivity.loadUrl(CordovaActivity.java:224) 
        at es.gva.mobilendo.aire.MainActivity.onCreate(MainActivity.java:39) 
        at android.app.Activity.performCreate(Activity.java:6955) 
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126) 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2927) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3045) 
        at android.app.ActivityThread.-wrap14(ActivityThread.java) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1642) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:154) 
        at android.app.ActivityThread.main(ActivityThread.java:6776) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386) 
2018-12-14 09:52:43.127 4152-4775/? D/Debug: !@DumpState : SHIP
2018-12-14 09:52:43.127 4152-4775/? D/Debug: !@DumpState : debug level:0x4f4c
2018-12-14 09:52:43.127 4152-4775/? D/Debug: !@Dumpstate : Finally, system will skip dumpstate
    
    --------- beginning of system
2018-12-14 09:52:43.127 4152-4775/? W/ActivityManager:   Force finishing activity es.gva.mobilendo.aire/.MainActivity

This is my Cordova Plugin List:

cordova-fabric-plugin 1.1.14-dev "cordova-fabric-plugin"
cordova-plugin-advanced-http 2.0.1 "Advanced HTTP plugin"
cordova-plugin-device 2.0.2 "Device"
cordova-plugin-file 6.0.1 "File"
cordova-plugin-googlemaps 2.4.6 "cordova-plugin-googlemaps"
cordova-plugin-inappbrowser 3.0.0 "InAppBrowser"
cordova-plugin-ionic-keyboard 2.1.3 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 2.2.5 "cordova-plugin-ionic-webview"
cordova-plugin-network-information 2.0.1 "Network Information"
cordova-plugin-proguard 2.0.0 "Cordova plugin ProGuard"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-whitelist 1.3.3 "Whitelist"
cordova-plugin-x-socialsharing 5.4.3 "SocialSharing"
cordova-sqlite-storage 2.5.2 "Cordova sqlite storage plugin"
es6-promise-plugin 4.2.2 "Promise"

This is my Ionic Info:

Ionic:

   ionic (Ionic CLI)  : 4.0.2 (/usr/local/lib/node_modules/ionic)
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.1.9

Cordova:

   cordova (Cordova CLI) : 8.0.0
   Cordova Platforms     : android 7.1.4, ios 4.5.5

System:

   Android SDK Tools : 26.1.1
   ios-deploy        : 1.9.2
   ios-sim           : 6.1.2
   NodeJS            : v9.9.0 (/usr/local/bin/node)
   npm               : 5.7.1
   OS                : macOS High Sierra
   Xcode             : Xcode 10.1 Build version 10B61

Environment:

   ANDROID_HOME : /Users/juanramos/Library/Android/sdk

What would be happening?

Removing log and optimization doesn't work

Hi,

I'm currently working on a Cordova android app and I think your plugin can help me.

Unfortunately when I'm trying to remove logs (verbose and debug) in my release build. It seems doesn't work at all.

The issue is in build.gradle. The usage of "proguard-android.txt" instead of "proguard-android-optimze.txt".

In android sdk you can found difference between them here :
proguard-android-optimze.txt
proguard-android.txt

As writing in proguard-android.txt in commentary :
|# Optimization is turned off by default. Dex does not like code run |# through the ProGuard optimize and preverify steps (and performs some |# of these optimizations on its own). |# Note that if you want to enable optimization, you cannot just | # include optimization flags in your own project configuration file; | # instead you will need to point to the | # "proguard-android-optimize.txt" file instead of this one from your | # project.properties file.

and in ProGuard documentation :

-assumenosideeffects : Only applicable when optimizing. In general, making assumptions can be dangerous; you can easily break the processed code. Only use this option if you know what you're doing!

So three possibilities are available for this project :

  • Remove all rules from proguard-custom.txt that are not applicable.
  • Create an argument or option of the plugin to use one or another default ProGuard configuration
  • Change in build.gradle to use in release mode "proguard-android-optimze.txt"

Thanks in advance for your return, I can create a PR if needed

The plugin doesn't work with cordova 12.

Hi.
Im getting next error:

FATAL EXCEPTION: main
Process: com.maksytech.fishermantest_germany, PID: 30746
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.maksytech.fishermantest_germany/com.maksytech.fishermantest_germany.MainActivity}: java.lang.RuntimeException: Failed to create webview.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3742)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3890)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2393)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loopOnce(Looper.java:238)
at android.os.Looper.loop(Looper.java:357)
at android.app.ActivityThread.main(ActivityThread.java:8088)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:957)
Caused by: java.lang.RuntimeException: Failed to create webview.
at org.apache.cordova.CordovaWebViewImpl.createEngine(CordovaWebViewImpl.java:84)
at org.apache.cordova.CordovaActivity.makeWebViewEngine(CordovaActivity.java:216)
at org.apache.cordova.CordovaActivity.makeWebView(CordovaActivity.java:212)
at org.apache.cordova.CordovaActivity.init(CordovaActivity.java:153)
at org.apache.cordova.CordovaActivity.loadUrl(CordovaActivity.java:234)
at com.maksytech.fishermantest_germany.MainActivity.onCreate(MainActivity.java:40)
at android.app.Activity.performCreate(Activity.java:8479)
at android.app.Activity.performCreate(Activity.java:8458)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1386)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3723)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3890) 
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101) 
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) 
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2393) 
at android.os.Handler.dispatchMessage(Handler.java:111) 
at android.os.Looper.loopOnce(Looper.java:238) 
at android.os.Looper.loop(Looper.java:357) 
at android.app.ActivityThread.main(ActivityThread.java:8088) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:957) 
Caused by: java.lang.NoSuchMethodException: org.apache.cordova.engine.SystemWebViewEngine. [class android.content.Context, class org.apache.cordova.CordovaPreferences]
at java.lang.Class.getConstructor0(Class.java:2363)
at java.lang.Class.getConstructor(Class.java:1759)
at org.apache.cordova.CordovaWebViewImpl.createEngine(CordovaWebViewImpl.java:81)
at org.apache.cordova.CordovaActivity.makeWebViewEngine(CordovaActivity.java:216) 
at org.apache.cordova.CordovaActivity.makeWebView(CordovaActivity.java:212) 
at org.apache.cordova.CordovaActivity.init(CordovaActivity.java:153) 
at org.apache.cordova.CordovaActivity.loadUrl(CordovaActivity.java:234) 
at com.maksytech.fishermantest_germany.MainActivity.onCreate(MainActivity.java:40) 
at android.app.Activity.performCreate(Activity.java:8479) 
at android.app.Activity.performCreate(Activity.java:8458) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1386) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3723) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3890) 
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101) 
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) 
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2393) 
at android.os.Handler.dispatchMessage(Handler.java:111) 
at android.os.Looper.loopOnce(Looper.java:238) 
at android.os.Looper.loop(Looper.java:357) 
at android.app.ActivityThread.main(ActivityThread.java:8088) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:957) ``

I wonder, which rule should I add to make it working with cordova 12?

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.