I have an android app, and it seems someone decomiple my code and uploaded to the play store. In my app, I have something that makes a call to my website through a php file like the following
http//www.test.com/get_service.php
Its hardcoded in the app as a string. That guy is making the same call using my get_service.php because whenever I change something in the get_service.php, it would reflected on their app.
I just noticed that apps like https://play.google.com/store/apps/details?id=com.njlabs.showjava&hl=en
is able to decompile my android app.
So I tried enabling the Proguard on my app, and test it on my own phone. I haven't release the app yet, but it seems the app is still able to decompile my code. Is there a way to hide my string? so that even if someone decompile my code, he won't be able to see the get_service.php file.
android {
buildTypes {
release {
// Enables code shrinking, obfuscation, and optimization for only
// your project's release build type.
minifyEnabled true
// Enables resource shrinking, which is performed by the
// Android Gradle plugin.
shrinkResources true
// Includes the default ProGuard rules files that are packaged with
// the Android Gradle plugin. To learn more, go to the section about
// R8 configuration files.
proguardFiles getDefaultProguardFile(
'proguard-android-optimize.txt'),
'proguard-rules.pro'
}
}
...
}
Related
I'm getting a coroutine exception while running my Android app in debug mode through Android Studio.
kotlinx.coroutines.JobCancellationException: StandaloneCoroutine was cancelled
From the coroutines debugging documentation, I gather that I might get fuller stack trace information by enabling debug mode of coroutines.
It can be enabled either by setting system property DEBUG_PROPERTY_NAME or by running Java with enabled assertions (-ea flag).
This is where I'm stuck. What is the idiomatic way of achieving this in Android Studio? My project is configured using Gradle, and I am running on Windows. Ideally, there is a way to configure this through Gradle configuration so that coroutines debug mode is enabled for anyone pulling in this project through source control.
I haven't found a way to configure this through Android studio or Gradle. Information on doing so would still be useful to me. But, the following is verified to work; I got a full stack trace.
The "system property" refers to Java System Properties. They can be set at runtime using System.setProperty.
I therefore added the following code to the start of my Application.onCreate().
override fun onCreate() {
// Enable coroutines debug mode in debug builds.
if (BuildConfig.DEBUG) {
System.setProperty(
kotlinx.coroutines.DEBUG_PROPERTY_NAME,
kotlinx.coroutines.DEBUG_PROPERTY_VALUE_ON
)
}
...
}
I am using android studio 4.0 and whenever i create a new project offline(without access to internet) it gives me this error and I haven't access to internet most of times. I tried toggling offline mode button and everything but again I need to have access to internet for complete build. Is there any solution to this or you need to have access to internet when build you project?
I used to use Java for android app development and could build project offline too. but I have migrated to Kotlin and this give me this error. Please, answer!!
I tried this. I disabled offline mode. You might get this error "Unknown host 'jcenter.bintray.com'" when you build. To handle this error, try the below steps.
Go to project >> build.gradle. Add the below into your projects.
android{ allprojects {
repositories { google()
jcenter()
maven {url"https://jitpack.io"} }}
I'm using retrofit for the communication between the app and the server. When I'm testing it with android studio everything works fine and the comunication is successful. However, when the app is downloaded from the store, when I try to post something to the server nothing happens, and I don't get an error. Does anyone know why this is happening?
UPDATE:
Here is my build.gradle. Maybe there is something here that is causing this issue:
buildTypes {
release {
// Enables code shrinking, obfuscation, and optimization for only
// your project's release build type.
minifyEnabled true
// Enables resource shrinking, which is performed by the
// Android Gradle plugin.
shrinkResources true
// Includes the default ProGuard rules files that are packaged with
// the Android Gradle plugin. To learn more, go to the section about
// R8 configuration files.
proguardFiles getDefaultProguardFile(
'proguard-android-optimize.txt'),
'proguard-rules.pro'
}
}
I want to remove unused resources from my project to reduce the app size. Is there any way to do it by using Android Studio IDE efficiently?
The Gradle build system for Android supports Resource Shrinking : the automatic removal of resources that are unused, at build time, in the packaged app. In addition to removing resources in your project that are not actually needed at runtime, this also removes resources from libraries you are depending on if they are not actually needed by your application.
For example, your application is using Google Play Services to for example access Google Drive functionality, and you are not currently using Google Sign In, then this would remove the various drawable assets for the Sign In buttons.
Note: Resource Shrinking only works in conjunction with code shrinking (such as ProGuard). That's how it can remove unused resources from libraries; normally, all resources in a library are used, and it is only when we remove unused code that it becomes apparent which resources are referenced from the remaining code.
To enable resource shrinking, update your build type as follows:
android {
...
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
And google recently launched Android Studio 2.0 officially, Now they are giving an option in the IDE itself.
Right click on app --> Refactor --> Remove Unused Resources
It will prompt
Check the box prior confirm action so that you can get rid of unused #id declarations too.
In terms of APK optimization consider Selecting a Format fact as well.
Use WebP Images provide better compression than either JPEG or PNG. Lossy WebP images are supported in Android 4.0 (API level 14) and higher, and lossless and transparent WebP images are supported in Android 4.3 (API level 18) and higher.
In android studio. You can use Android Lint. It will show " Strings, Resource, import.." not use
Analyze -> Inspect Code -> Whole Project -> OK
When I ran my app, it said that
Cannot Instant Run: legacy multi-dex on Dalvik runtime
Does it means that I can't use Instant Run when I use multi-dex?
I'm using Android Studio beta4.
In order to activate multiDex at old android versions you have to set multiDexEnabled to true, add dependency and extend your application class from MultiDexApplication or launch MultiDex.install(this) in your application class, which will cause legacy multiDex installation.
However since Intant Run can't work with legacy multiDex you have to use normal one. All you need is removing all that code above except of multiDexEnabled flag set to true. This method is only supported by devices with API 21 and above.
Feel free to correct me if something is wrong.
As mentioned in the documentation Instant Run is disabled by Android Studio in case multidex is enabled for API level 20 or lower and app is deployed on API level 20 or lower.
Documentation link
Just remove this line from your ProjectName/app/build.gradle
android {
defaultConfig {
multiDexEnabled true
}
}
remove multiDexEnabled true and you will able to instant run.