Need explanation about migration from v0.9 to v1.2
AndroidDeveloperLB opened this issue · 83 comments
We used the library in many places, using v0.9 . Example:
SC.getString(R.string.some_important_key)
<string name="some_important_key" hidden="true" translatable="false">abc</string>
Will this still work on v1.2 ? What exactly should we change it to?
I've read this:
https://github.com/StringCare/AndroidLibrary/wiki/Migrate-From-0.x-To-1.x
But I don't understand what to change it to.
Should it be just this from now:
SC.decryptString(getString(R.string.some_important_key))
Or :
SC.deobfuscate(R.string.some_important_key)
Or something else?
Are there other important things to know about?
I ask this all because the explanation seems worrying "strings and resources don't work in the same way." .
I think the explanation on the website means that if I use just resources , it shouldn't be a problem to use SC.deobfuscate(R.string.some_important_key)
for each time I had SC.getString(R.string.some_important_key)
before.
Is it correct?
After I tried to do this, I got this error:
* What went wrong:
Execution failed for task ':app:transformNativeLibsWithMergeJniLibsForSyncmeappDebug'.
> More than one file was found with OS independent path 'lib/armeabi-v7a/libnative-lib.so'
Library methods in version v.0.9
(for example SC.getString(int id)
) where deprecated in v.1.2
because this version implements a safer logic for string obfuscation.
Since v.1.2
you must use SC.obfuscate()
and SC.deobfuscate()
methods for working with resources.
The migration talks about obfuscating dynamic data at runtime.
For example, with v.0.9
:
String userProfileImageUrl = "blablabla"
// using old SC logic
String obfuscatedData = SC.encryptString(userProfileImageUrl)
With the new logic on v.1.2
you must use the SC.obfuscate()
method:
// obfuscated data with old methods
String oldUserProfileImageUrl = SharedPreferences....
// reverse process with SC.decryptString method, which is deprecated
String userProfileImageUrl = SC.decryptString(oldUserProfileImageUrl)
// generate new obfuscated data
String obfuscatedData = SC.obfuscate(userProfileImageUrl)
I'll update the migration page for a better explanation.
But with resources it's correct what I've written? That all that I need to do is to change from SC.getString(R.string.some_important_key)
into SC.deobfuscate(R.string.some_important_key)
?
Please just tell me if it's correct... We use the library only from resources currently.
If you build a new version of your app with SC v.1.2
your string resources will be obfuscated with the new logic and you must use SC.deobfuscate()
method instead of SC.getString()
.
Remember that SC can't compile with com.android.tools.build:3.3.0
. I haven't test SC with new releases of com.android.tools.build
(3.3.2).
So I'm correct, right? from getString
, I should use deobfuscate
.
So why deprecate instead of removing the function? It won't work anymore, no?
Deprecation means it should still work, but it's recommended to use something else instead...
And about 3.3.0
of gradle, I don't know how it's possible that it works for me on 3.3.2, yet not for the macbook. I was hoping that updating the version of the repository will help. Even weirder: for a few weeks, it worked fine on the macbook...
I should use deobfuscate. You are right.
I didn't remove old methods because developers could have obfuscated dynamic data with the old logic, and they will need them for deobfuscating and obfuscating again with the new methods.
You can still using old methods (only for dynamic data) but there is a safer logic you can use.
The string resources are obfuscated with the new logic (from plugin) by default.
New obfuscation logic can't deobfuscate old obfuscated values.
So SC works fine in Windows with com.android.tools.build:3.3.2
but crashes on macOS?
I think you should have removed the functions, and replace them with other deprecated ones, because in some cases the functions are called on resources and not on strings, so they are safer to be replaced.
But thanks anyway.
About gradle, yes. It's really weird:
- Works fine on my Windows OS with 3.3.2 .
- Worked fine for a while (but not before) on macbook with 3.3.2, but now it can only use 3.2.1 .
Do you think that if I go to 3.2.1, it will work fine for me using the 1.2 version of the repository?
Yes I think so, with v.3.2.1
works fine 👌
When I release that version it only worked fine with 3.2.1 (macOS) 😞
With v.3.3.0
SC never worked.
Thanks for your report. I will take in mind for future releases!
Will the next version of the repository be able to handle newer versions of Gradle plugin? Is it possible to make it not be so reliable on its version?
I suggest that if you have a good way to show an issue, and you think it's not your fault, you should report about it to Google:
https://issuetracker.google.com/issues
Any news about this?
The only reason we are stay with gradle 3.2.1 is this library....
And it works fine on 3.4.0 when used on Windows... Just on MacOS it has issues (not crashing, but can't do things that use it).
@AndroidDeveloperLB Last weeks I didn't had enough time for working on it, but this one I'll review the library.
I didn't see your last comment:
I'll report as a new JNI issue in https://issuetracker.google.com/issues.
Thanks for the advice and for your patient. 😅
@efraespada Thank you. I hope you will succeed.
@AndroidDeveloperLB I found an error at compilation time and it's fixed now (with build tools 3.4.0). Let me do some checks and update the wiki.
OK thank you
Hi @AndroidDeveloperLB:
I've publish a new version (v1.5) with some changes. It should work fine on Windows and MacOS.
Let me know if it works without problems.
I've updated all the documentation too: Migrate From 0.x To 1.x
Thanks for your patient.
I think you should have written that if you use resources as I have, you should replace SC.getString(R.string.some_important_key)
into what you've decided (was deobfuscate
, but now it seems to be reveal
)
Currently, it says that You don't need to read this page if you don't store obfuscated data
.
Will this now work even in the future gradle versions? Have you tried with the alpha/beta versions of the Canary?
Also, using the new version doesn't work for me anymore. It shows as if the resources don't exist anymore.
It crashes.
Attached sample project.
Snippet:
SC.init(applicationContext)
val stringId = R.string.hello
val message = getString(stringId) + " is " + SC.reveal(stringId)
textView.text = message
It either shows a very short crash log, or a long one. Here's the short one:
2019-05-12 10:29:36.873 12198-12198/? E/e.myapplicatio: Unknown bits set in runtime_flags: 0x8000
2019-05-12 10:29:37.182 12198-12198/com.sample.myapplication E/libc++abi: terminating with uncaught exception of type std::invalid_argument: not a hex digit
--------- beginning of crash
2019-05-12 10:29:37.182 12198-12198/com.sample.myapplication A/libc: Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 12198 (e.myapplication), pid 12198 (e.myapplication)
![image](https://user-images.githubusercontent.com/5357526/57579171-f1184600-74a0-11e9-86f8-86f997f82114.png)
@AndroidDeveloperLB I downloaded the sample app and worked fine 😅
This error happened on the version before, maybe any StringCare package is cached and doesn't work properly. Clean the project and run it again.
If it doesn't work: File > Invalidate Caches / Restart > Invalidate and Restart
I tested this version on Windows and MacOS; it should work
I think you should have written that if you use resources as I have, you should replace
SC.getString(R.string.some_important_key)
into what you've decided (wasdeobfuscate
, but now it seems to bereveal
)
Currently, it says thatYou don't need to read this page if you don't store obfuscated data
.Will this now work even in the future gradle versions? Have you tried with the alpha/beta versions of the Canary?
It's true. You don't need to read that page if you don't store obfuscated data. The most relevant change was the methods deprecation.
- Up to 0.9: SC.getString()
Old logic. - Up to 1.2: SC.deobfuscate()
New logic.
SC.getString() method must work for the stored obfuscated data migration (deprecated) - 1.5: SC.reveal()
SC.deobfuscate() renamed.
So change it:
https://github.com/StringCare/AndroidLibrary/wiki/Migrate-From-0.x-To-1.x
It says I don't need to read it, and it's missing this part...
I defined the deprecated method migration on the code: by pressing Ctrl
(or cmd
) key and clicking over the deprecated method you access to its definition, where you can see what to do:
I thought this documentation would be more accessible on that way than this repo wiki.
The migration documentation helps to migrate stored obfuscated data.
For those who update, if it says we should ignore, we don't look at the code that uses StringCare, so the deprecated code will remain being used.
When you update a dependency, it doesn't make sense to go over each of its functions, to see what has deprecated, especially if there is a website that tells you all is fine...
I understand it, you are right. I will update the doc again.
Did you run the application without problems?
Why close the issue? I didn't try it yet...
Sorry, I updated the documentation and close
On the large app, I tried what you wrote:
Clean the project and run it again.
If it doesn't work: File > Invalidate Caches / Restart > Invalidate and Restart
I even tried to delete all "build" folders. Still crashes when I start the app.
I've now tried to do the same for the app I've shared with you. Still same issue. Crashes right away.
Here, a video showing what I tried :
It seems the Canary channel is the cause. I'm gonna check it.
Can I close this issue?
I want to have another try at the office. As I remember, I tried it on normal version too.
I switched to Canary channel (macOS):
- Android Studio 3.5 Beta 1
- Android Gradle Plugin 3.5.0-beta01
- Gradle 5.4 RC-1
- SC 1.5
Both samples are working fine.
What versions are you using?
Android Studio 3.5 Beta 1
Build #AI-191.6707.61.35.5529924, built on May 3, 2019
JRE: 1.8.0_202-release-1483-b01 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
I've tested now on the big app at the office. Still crashes. And I've used all the "big guns" I had for the sample:
- clean project.
- invalidate cache
- Delete
build
folders. - Delete
C:\Users\user\AppData\Local\Android\Sdk.temp
folder
All while using :
Android Studio 3.4
Build #AI-183.5429.30.34.5452501, built on April 10, 2019
JRE: 1.8.0_152-release-1343-b01 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
Attached the log I got on Galaxy S7 with Android 8.0.0
terminating with uncaught exception of type std::invalid_argument: odd length
Not sure if the plugin is obfuscating at compilation time. I have found a possible error when running ./gradlew buildDebug -i
:app:debug:0A:08:B8:C5:62:8E:42:D9:38:12:F5:53:B8:41:9B:3F:C8:81:DB:5B
:app:backupStringResources
source folder not found: src/main
:app:encryptStringResources
source folder not found: src/main
It should have printed all the obfuscated values, but nothing was found.
Are you getting a similar output on your project for the same command?
On which project? This:
#43 (comment)
?
If so, it happens there too.
Log:
--------- beginning of crash
2019-05-14 12:15:48.526 28441-28441/com.sample.myapplication A/libc: Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 28441 (e.myapplication), pid 28441 (e.myapplication)
Yesterday I did multiple test with different versions of Android Studio, Android Gradle Plugin and Gradle in Windows and all builds worked without problems on my samples (Kotlin repo and development repo).
- Android Studio 3.4.1 | Gradle 5.1.1 | Android Gradle Plugin 3.4.1
- Android Studio 3.5.0 Canary 13 | Gradle 5.4 RC 1 | Android Gradle Plugin 3.5.0-alpha13
- Android Studio 3.5.0 Beta 1 | Gradle 5.4 RC 1 | Android Gradle Plugin 3.5.0-beta01
I can't reproduce the same error you get.
Have you tried the sample I've provided too?
What should I do now?
Is it a dead end?
I still get this crash on the sample I've provided:
2019-05-20 11:30:52.651 11195-11195/com.sample.myapplication E/libc++abi: terminating with uncaught exception of type std::invalid_argument: not a hex digit
--------- beginning of crash
2019-05-20 11:30:52.652 11195-11195/com.sample.myapplication A/libc: Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 11195 (e.myapplication), pid 11195 (e.myapplication)
Android Studio 3.4.1
Build #AI-183.6156.11.34.5522156, built on May 1, 2019
JRE: 1.8.0_152-release-1343-b01 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
Tested on Pixel 2 with Android Q beta 3, and on HTC One M8 with Android 7.1.2.
Try the attached APK. It shows you that it crashes.
It seems your strings aren't obfuscated:
This command should help you to see the console output.gradlew.bat buildDebug -i
Also enabling debug logs could help us.
apply plugin: StringCare
stringcare {
debug true
}
The related information appears next to mergeResources gradle task. You should get something like this:
:app:debug:0A:08:B8:C5:62:8E:42:D9:38:12:F5:53:B8:41:9B:3F:C8:81:DB:5B
:app:backupStringResources
source folder not found: src/main
:app:encryptStringResources
source folder not found: src/main
I ran a simple build&run. Not release build. I don't understand where you wish me to look at:
Also tried the command you wrote:
Got a similar one on the terminal of the IDE:
And looking at the APK, I got this:
Here, attached video to show the issue:
I think I have found the error while I was typing this 😅
Well, we need the debug output, it can say us what's happens with the plugin.
1º In your root build.gradle
file:
buildscript {
....
}
apply plugin: StringCare
stringcare {
debug true
}
2º In a terminal, run:
gradlew.bat clean
gradlew.bat buildDebug -i
You are getting the JAVA_HOME not found error, resolve this error before working with Gradle.
On the output, you must look for something like this:
> Task :app:mergeDebugResources
Module: app
Variant: debug
Store: /Users/e-enea/.android/debug.keystore
SHA1: 0A:08:B8:C5:62:8E:42:D9:38:12:F5:53:B8:41:9B:3F:C8:81:DB:5B
Valid until: Saturday, February 20, 2049
:app:debug:0A:08:B8:C5:62:8E:42:D9:38:12:F5:53:B8:41:9B:3F:C8:81:DB:5B
:app:backupStringResources
source folder not found: /Users/e-enea/.gradle/daemon/5.1.1/app/src/main/res/
:app:encryptStringResources
source folder not found: /Users/e-enea/.gradle/daemon/5.1.1/app/src/main/res/
Here is the error 🙌 :
:app:backupStringResources
source folder not found: /Users/e-enea/.gradle/daemon/5.1.1/app/src/main/res/
The plugin is looking for strings on the wrong place.
Today I will try to fix it. You should get the same error on terminal.
I don't understand. You have a clue of why this occurs?
I didn't have the Java issue before. Why does it occur?
We are getting this on terminal (the plugin can't find the string resources):
> Task :app:mergeDebugResources
Module: app
Variant: debug
Store: /Users/e-enea/.android/debug.keystore
SHA1: 0A:08:B8:C5:62:8E:42:D9:38:12:F5:53:B8:41:9B:3F:C8:81:DB:5B
Valid until: Saturday, February 20, 2049
:app:debug:0A:08:B8:C5:62:8E:42:D9:38:12:F5:53:B8:41:9B:3F:C8:81:DB:5B
:app:backupStringResources
source folder not found: /Users/e-enea/.gradle/daemon/5.1.1/app/src/main/res/
:app:encryptStringResources
source folder not found: /Users/e-enea/.gradle/daemon/5.1.1/app/src/main/res/
And we should get this on terminal:
> Task :app:mergeDebugResources
Module: app
Variant: debug
Store: /Users/e-enea/.android/debug.keystore
SHA1: 0A:08:B8:C5:62:8E:42:D9:38:12:F5:53:B8:41:9B:3F:C8:81:DB:5B
Valid until: Saturday, February 20, 2049
:app:debug:0A:08:B8:C5:62:8E:42:D9:38:12:F5:53:B8:41:9B:3F:C8:81:DB:5B
:app:backupStringResources
- values/strings.xml
backuping file: /Users/e-enea/Documents/Github/AndroidLibrary/app/src/main/res/values/strings.xml
:app:encryptStringResources
source file not exist: /Users/e-enea/Documents/Github/AndroidLibrary//app/src/main/res/mipmap-mdpi/strings.xml
source file not exist: /Users/e-enea/Documents/Github/AndroidLibrary//app/src/main/res/mipmap-hdpi/strings.xml
source file not exist: /Users/e-enea/Documents/Github/AndroidLibrary//app/src/main/res/values-w820dp/strings.xml
source file not exist: /Users/e-enea/Documents/Github/AndroidLibrary//app/src/main/res/mipmap-xxxhdpi/strings.xml
source file not exist: /Users/e-enea/Documents/Github/AndroidLibrary//app/src/main/res/layout/strings.xml
source file not exist: /Users/e-enea/Documents/Github/AndroidLibrary//app/src/main/res/mipmap-xxhdpi/strings.xml
- values/strings.xml
[ <br><b>..] - [696862606563666..]
[%1$s (%2$d)] - [6A66676A6B6D6B6..]
<resources> <string name="app_name">String Obfuscator Sample</string> <string name="hello" hidden="true">6968626065636662636865656360686666796E656B67667D69736E636775686A6A686A75687B6B786664647B6E71677B65776D6666686578696D69636767677C6B75686566706B6C69676A7C68796779686A687D6A77647B6C626C7E686268636469676068656864626968686376676A6E62677B6A786D786B766A636B6E666C6F7A696867666A696E736C756B696E78686F69636F6C6F716A6C6E7069626B79706A6761666D6F656A676E6A6F6C69626B7D6360626164646B616263626868606360697466676863637E66706B6968646462706F6C66686866796A6067636F6B70656261657470696B6868646B786E7E6D68657D6D6A6A69677568656B616A6A6A696767666B6764706467696A7466786D6B676768666C7967756E68677E6B7E677667676A69657D6661676767616569</string> <string name="test_a" hidden="true">6A66676A6B6D6B666365656F646D6763676B6B656572</string></resources>
writing file: /Users/e-enea/Documents/Github/AndroidLibrary/app/src/main/res/values/strings.xml
source file not exist: /Users/e-enea/Documents/Github/AndroidLibrary//app/src/main/res/mipmap-xhdpi/strings.xml
I'm gonna publish a new release with the bugfix.
OK, please let me know when I can check a new version that has the fix.
Could you check the version 1.6? 🤞
Could you run gradlew.bat buildDebug -i
and show me if resources are being obfuscated?
If the error persist, you should get something like this:
> Task :app:mergeDebugResources
Module: app
Variant: debug
Store: /Users/e-enea/.android/debug.keystore
SHA1: 0A:08:B8:C5:62:8E:42:D9:38:12:F5:53:B8:41:9B:3F:C8:81:DB:5B
Valid until: Saturday, February 20, 2049
:app:debug:0A:08:B8:C5:62:8E:42:D9:38:12:F5:53:B8:41:9B:3F:C8:81:DB:5B
:app:backupStringResources
source folder not found: /Users/e-enea/.gradle/daemon/5.1.1/app/src/main/res/
:app:encryptStringResources
source folder not found: /Users/e-enea/.gradle/daemon/5.1.1/app/src/main/res/
Add this to your root build.gradle
file to enable debug logs:
apply plugin: StringCare
stringcare {
debug true
}
I already added debug true
, and running gradlew.bat buildDebug -i
I got the Java issue.
If you already have the JAVA_HOME defined, the error disappear if you execute it from CMD. I’ve got the same error on the Android Studio terminal; on CMD it doesn’t happen
OK it finally did something . Attached here the file after running:
./gradlew.bat buildDebug -i >1.txt
If you want , attached a video of this:
Perfect,
I see (from your output) your string resources are finally obfuscated:
> Task :app:mergeDebugResources UP-TO-DATE
Module: app
Variant: debug
Store: C:\Users\User\.android\debug.keystore
SHA1: 8A:63:36:BB:DE:69:82:60:FE:68:86:1F:DA:D2:08:89:64:F1:56:56
Valid until: Saturday, December 26, 2048
:app:debug:8A:63:36:BB:DE:69:82:60:FE:68:86:1F:DA:D2:08:89:64:F1:56:56
:app:backupStringResources
- values\strings.xml
backuping file: C:\Users\User\Desktop\MyApplication\app\src\main\res\values\strings.xml
:app:encryptStringResources
source file not exist: C:\Users\User\Desktop\MyApplication\\app\src\main\res\drawable\strings.xml
source file not exist: C:\Users\User\Desktop\MyApplication\\app\src\main\res\drawable-v24\strings.xml
source file not exist: C:\Users\User\Desktop\MyApplication\\app\src\main\res\layout\strings.xml
source file not exist: C:\Users\User\Desktop\MyApplication\\app\src\main\res\mipmap-anydpi-v26\strings.xml
source file not exist: C:\Users\User\Desktop\MyApplication\\app\src\main\res\mipmap-hdpi\strings.xml
source file not exist: C:\Users\User\Desktop\MyApplication\\app\src\main\res\mipmap-mdpi\strings.xml
source file not exist: C:\Users\User\Desktop\MyApplication\\app\src\main\res\mipmap-xhdpi\strings.xml
source file not exist: C:\Users\User\Desktop\MyApplication\\app\src\main\res\mipmap-xxhdpi\strings.xml
source file not exist: C:\Users\User\Desktop\MyApplication\\app\src\main\res\mipmap-xxxhdpi\strings.xml
- values\strings.xml
[Hello there. Ge..] - [65686F666D7C6C7..]
<resources> <string name="app_name">My Application</string> <string name="hello" hidden="true">65686F666D7C6C7467786469706D67696B696E626D66637D6869666B6767677E6C6C68636866687C636865746E6B6C7D6877696466726767</string></resources>
writing file: C:\Users\User\Desktop\MyApplication\app\src\main\res\values\strings.xml
Your app should compile and run without problems now.
If you run your app normally (clean + run), do you get any error?
Seems to work at home. Hopefully will work at the office too.
But why did I have to use the command? Will I also have to do it for the large app?
Sincerely I'm not sure why Android Studio doesn't sometimes work correctly with the Gradle's wrapper, but this problem only happens at first builds.
It can happen on any project (with the large app too).
Once you have done the initial compilation, the project should run normally.
You can use the Gradle panel with all task If you don't want to use a terminal.
In the office, the sample project works, but not the large one. What should I do on this gradle window you've shown?
Running the ./gradlew.bat buildDebug -i
command resulted in this error:
Parsing the SDK, no caching allowed
SDK initialized in 0 ms
All projects evaluated.
Analytics other plugin to proto: Unknown plugin type StringCare expected enum STRINGCARE
FAILURE: Build failed with an exception.
Forget what I said about the Gradle panel, I've just checked it fails with Android Studio.
Not sure about this error, but seems Android Studio hasn't loaded the plugin properly. What versions of Gradle plugin and Gradle wrapper are you using?
I use:
- For stable channel -> 3.4.1 and 5.1.1.
- For beta/canary channel -> 3.5.0-beta01 and 5.4-rc-1
I use this:
classpath 'com.android.tools.build:gradle:3.4.1'
And it still crashes on the large app... :(
I tried project clean, rebuild, delete build folders, invalidate cache...
And the wrapper version?
I have this:
#Tue May 07 22:19:17 CEST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
I don't know what this is.
I used what I wrote on the sample app and it worked fine there. That's the standard way to use the gradle plugin.
How come it doesn't work well on the large app?
I don't know yet.
What I show you It's the gradle-wrapper.properties
file, it defines which Gradle version Android Studio will use.
It's like a portable Gradle version for Android Studio projects.
For version 3.4.1 of the Gradle plugin, I use 5.1.1 Gradle version
I see this in this file:
#Tue May 21 10:57:40 IDT 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
I think everything it's ok.
Try to delete the .gradle
folder on your PC; mine is in /Users/efraespada/.gradle/
.
Already tried it. The content that I've sent you is after the deletion.
Anything to take in mind about your project? What are the diferences with the sample application?
Huge amount of files (at least 1000 Java/Kotlin files), dependencies and a few modules inside the project...
:)
😅 you are right
I was wonder about the project basics. If the sample and the large app uses the same versions for Gradle, Gradle plugin, etc..
Have you tried to switch between different StringCare versions? For example:
- Define v1.2 and build
- Redefine v1.6 and build
Running gradlew.bat :app:dependencies
you can see if stringcare dependency is added.
I don't understand the suggestion.
There are just 2 configurations that I have:
-
classpath 'com.android.tools.build:gradle:3.2.1'
withstringcare_version = '0.9'
-
classpath 'com.android.tools.build:gradle:3.4.1'
withstringcare_version = '1.5'
Those are the only things that I change (and the code, because SC.getString
was replaced with SC.reveal
)
Switching versions often fix cached dependencies/plugins errors.
I don't know what more to suggest to you.
Try removing line classpath "com.stringcare:plugin:$stringcare_version"
and apply plugin: StringCare
and compile it.
Then implement StringCare again and build.
Next step I'm going to suggest you is restarting AndroidStudio and your PC 😅
Tried now to remove, build, and re-add them with newer versions ,and then build&run.
Works now. I hope it will work on the mac too.
Why did I have to do this?
And now it's back to not working, after a second run.
It's not fixed.
Are you getting a compilation error or an execution error?
What does it say?
Seems same error as always (when running the app) :
E: Unknown bits set in runtime_flags: 0x8000
E: terminating with uncaught exception of type std::invalid_argument: odd length
--------- beginning of crash
A: Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 17710 (Thread-3), pid 17120 ()
E: terminating with uncaught exception of type std::invalid_argument: not a hex digit
Say, why does the library need the support library :
https://github.com/StringCare/AndroidLibrary/blob/master/library/build.gradle
implementation 'com.android.support:appcompat-v7:28.0.0'
I think you should remove it.
I think the plugin hasn't found the string resources.
If you go to Build > Analyze APK you should see your APK's string resources with no obfuscation.
You can verify it from the console output at compilation time. The console output will help me to see what is finding the plugin.
I thought I fixed it:(
:app:backupStringResources
source folder not found: /Users/e-enea/.gradle/daemon/5.1.1/app/src/main/res/
:app:backupStringResources
- values/strings.xml
backuping file: /Users/e-enea/Documents/Github/AndroidLibrary/app/src/main/res/values/strings.xml
I added the appcompat-v7
for the SCTextView
. It extends the AppCompatTextView
.
"Analyze APK" showed the string as they are. Not encoded/obfuscated .
About appcompat-v7, I see. You could at least switch to android-x, though.
Yeah, what I supposed. I take for granted you are using v1.6
and the plugin is getting a wrong path to find string resources.
Maybe the first builds find the correct path, but the next one uses a wrong path.
At compilation time, you should get something like this (enabling debug true
in the SC options):
:app:backupStringResources
source folder not found: /Users/e-enea/.gradle/daemon/5.1.1/app/src/main/res/
Where is the plugin looking for strings on your project?
About the Android-X switching, it can be a future improvement :)
Well I forgot to use reveal
for all files instead of getString
, so maybe it worked fine till I replaced all, which is a fake "working fine".
The debug true
is already there. Where should I look for the text you wrote? In the "build" window of the IDE ? If so, I've copied it all into text editor, and I couldn't find the word "backupStringResources" or "source folder" anywhere inside it.
About android-x, you can just convert it. The IDE does a very good job on this one (compared to conversion to Kotlin, which it has null-related issues in almost all cases).
The plugin runs the backupStringResources
task before mergeResources
task is fired.
When you run your app having a previous build folder, and there is no change in the res
folder, the Android Gradle plugin doesn't fire the mergeResources
task; it's skipped.
That's why I clean the project and run it again for the resource obfuscation testing.
Do this:
1º Clean project
2º From an external terminal, gradlew.bat buildDebug -i
3º Copy and send me the output.
Can I send you via email, to make it more private (it's from the office app...)...?
Of course. My email is efraespada@gmail.com :)
ok sent. Please continue via email.