-
-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Strings with the same content doesn't work properly #52
Comments
Since |
Is this fixed? I've noticed there is a new version... |
Not yet |
Oh ok. |
@AndroidDeveloperLB check out |
Seems to be fixed according to my tests.
Please explain why this occurs when using this repository. EDIT:
But then I get this:
I tried to delete all "build" folders. Also tried to invalidate cache. Didn't help. |
I think this type of message means an external dependency is being added multiple times. This article in StackOverflow talks about it: In our case: {
"kind": "error",
"text": "Program type already present: org.apache.commons.lang3.SerializationException",
"sources": [{}],
"tool": "D8"
} You should solve it by implementing the library excluding that package:
Or:
I haven´t tested it. |
I tried adding this:
And also this:
And I ran this:
I just noticed that I'm on "release" build. When switching to "debug" build, I can see more information. There is this conflict: The only thing that is related to
And it's the latest stable version: |
I'm seeing the correct module name (with conflict) is implementation("com.stringcare:library:$stringcare_version") {
exclude group: 'org.apache.commons', module: 'commons-lang3'
} |
Now it finally builds, but then I have a new issue. As soon as I call
So I think it still can't handle strings as the native string handling on Android. |
Looks like the value of Analyze your APK for ensuring the plugin obfuscates strings: You can test it too by calling Should return something like: |
It's not really "...". I changed it because it's a private key :) Putting this string into the sample I've made, it works perfectly fine. However, when using the |
I think it's a configuration problem and StringCare plugin doesn't find valid resource files.
Is your string located on the default folder/file? If your resource file is not called Also If your string resource is located on a different source folder, configure it. Check out the Configuration page for more details. |
That's true. Strings files are sent to translators, so it's bad to send them the keys too. However, we had it already set up on the previous versions of the library, as such:
It's not correct anymore ? |
You use a Windows platform and the stringcare {
modules {
app {
stringFiles = ['strings.xml', "keys.xml"]
srcFolders = ['src/main'] <- windows uses \\ (double slash) while macos uses /
}
}
} Try without the stringcare {
modules {
app {
stringFiles = ['strings.xml', "keys.xml"]
}
}
} You can try too: stringcare {
modules {
app {
stringFiles = ['strings.xml', "keys.xml"]
srcFolders = ['src\\main']
}
}
} |
We use both MacOS and Windows. Removing the |
Have you tried this? srcFolders = ["src\\main"] <-- this should work
srcFolders = ["src\main"]
srcFolders = ["src/main"] Note the double quotes |
I don't know what's happening. stringcare {
debug true
main_module "app"
modules {
app {
stringFiles = ['strings.xml', "strings_extra.xml"]
srcFolders = ["src\\main", "src\\other_source"]
}
}
} And it works fine in Windows. |
I noticed I had to delete manually the |
I confirm this configuration works on macOS and Windows: apply plugin: StringCare
stringcare {
modules {
app {
stringFiles = ["strings.xml", "strings_extra.xml"]
srcFolders = ["src${File.separator}main", "src${File.separator}other_source"]
}
}
} Ensure you delete the build folder completely. |
OK so I used this the next lines and deleted all "build" folders manually after closing the IDE :
And I got this error (after running the IDE again and trying to build&run the app) :
And if I use the next thing again, but with deletion of "build" folders, it still crashes :
|
I'm working on path treatment. Meanwhile, you can try calling "src${File.separator}main".toString() |
There is a new release (v3.1)
apply plugin: StringCare
stringcare {
modules {
app {
stringFiles = ["strings.xml","more_strings.xml"]
srcFolders = ["src/main", "src/other_variant_source"]
}
library {
srcFolders = ['src/other_folder/main']
}
}
}
|
I still get the same I tried to delete all "build" folders too. Didn't help. The 0.9 version could handle the paths fine. Are you sure that's the cause to the issue? |
I'm not sure because on my projects always works and pass all the tests (on Windows and macOS). The new tasks shows too much info about the obfuscation process (located files for the given configuration, fingerprint, obfuscation test..) and should help you to find what fails. You can send it to my mail. Remember to add a variant with the |
I know. The POC works fine too. I have no idea why this doesn't work on the large app.
|
stringcareTestObfuscate{$variant} task
No, no. It works as the // this would be the main task that builds all variants
gradlew.bat build
// this would be the task that builds the debug variant
gradlew.bat buildDebug
// this would be the task that builds the firstflavorSecondflavorDebug variant
gradlew.bat buildFirstflavorSecondflavorDebug If you run stringcarePreview taskI recomend to run this task too. It doesn't need any variant and could be helpful for solving the problem, or at least to notice what's wrong. You can see an output sample of both task in the wiki section. |
So how do I add one for StringCare exactly? |
I told you where it's explained:
I thought you read it. |
I've read it, but I don't understand why I don't see the task on the IDE, so I thought that maybe I need to add the task. |
Yes. Run the command on terminal, in the project's directory. |
OK I've sent you via email |
You only have sent the $ gradlew.bat stringcareTestObfuscateDebug |
You can write me this on email... |
Found how to fix it, but it doesn't mean the issue isn't here.
Now it works fine, I think. |
I've noticed that it still can have issues. I tried this (based on : https://github.com/StringCare/AndroidLibrary/wiki/Configuration#additional-resource-folders ) :
so I tried to rename the "keys.xml" file into something else on the other app, and tried again using this method. Still couldn't deal with it. Note that there are keys on the extra app that are overriding the main app. So what I think is that those issues are connected. Meaning that if there is a need to handle multiple files or strings from different files, it doesn't work correctly. |
I'll review why it fails with your About the other issue you mentioned, if I understood, do have you something like this? (for example) 1º <resources>
<string name="grievous" hidden="true">General Kenobi</string>
</resources> 2º <resources>
<string name="grievous" hidden="true">General Kenobi 2</string>
</resources> |
Yes, the files are are such: |
With the following configuration:
I get the normal error response for duplicating resources:
And the project can't compile. |
Why did you configure |
You have to configure the
<resources>
<string name="grievous" hidden="true">General Kenobi</string>
</resources>
<resources>
<string name="kenobi" hidden="true">Hello There</string>
</resources> With no configuration you will get this error because in code you use error: failed linking file resources. Android Studio (at compilation time) only knows the default configuration, which is the following:
You can define multiple
But not repeat the same resource identifier or you will get this:
Check out the official documentation for more details: |
That is incorrect. Both apps worked fine for years. The resources are shared between them, and one overrides the other. In addition, as I wrote before, StringCare worked fine with both apps on v0.9. It even says it's automatic on the link you gave:
There are no issues of "Duplicate resources" , not when we used v0.9 of StringCare, and not when we didn't use it at all. Can you please explain what you plan that I should try, exactly? |
You should try to read the documentation better xD
Between what? Resource files from the same sourceSet? Please explain me
I don't understand anything hahaha You haven't read the documentation well.
You haven't understood the only thing you have read:
That means:
This is what you find when you create a new Android project.
On the other hand:
And a few lines below, the sample:
And I suggested you add something like this:
And finally you say:
StringCare doesn't have any relation with "Duplicate resources" error. If you read fine the documentation, you'll see this:
To make sure I'm correct, I've tested what I just have explained to you. I have used the Removing The strings from different sourceSets aren't detected until I add:
|
I tried to create an empty project (without StringCare) and define two simple
The additional string file isn't detected until I add this:
And after that, I got the You can check it in the following project or in the KotlinSample project as was explained in the last comment: |
I don't see in your sample project that you can choose between 2 build variants of apps : and removing the part of Here, I've found some samples for you to try: Notice how they all of them don't need to set Here, I've made the smallest sample I can think of, to show how it works : Also watch the video, showing that indeed it works fine, using the same string, on both apps, yet with different value: Notice that it works fine, without errors of duplicate strings. After all, that's the whole point of variants. To be able to override the resources (and even code) , to provide an alternative way to view and use the app (example: lite vs pro) . Why close this issue? |
I closed the issue because it’s solved. My last comment proves it. |
I didn't ask about sourceSets . I don't even use it. I said you don't need it for app flavors. There is a bug in StringCare, which causes the app not being able to be built. It might be related to translations, and it might be related to flavors, and maybe to both. |
It proves that (without StringCare) wrong configurations causes build errors.
You don't (want to) understand anything hahaha
Say whatever you want, but it fails without using StringCare. You can do a second test removing the sourceSets and trying to call a string resource on the other source from the main source. You'll get something like this: I'm not gonna answer any more. This is a waste of time. |
With two strings with the same content, only the first one is obfuscated. The second returns junk chars.
StringCareTest.zip
The text was updated successfully, but these errors were encountered: