In past when building multi language apps in Android I used to place strings.xml in following tree:
res
├── values
│ └── strings.xml
└── values-es
└── strings.xml
Currently (according to tutorial) it should rather look like this:
res
├── values
│ └── strings.xml
└── values-b+es
└── strings.xml
Please note values-b+es instead of values-es. I couldn't find why it was changed and to me it looks worse than previously, so I wonder what is the reason of such change?
What's more freshly updated Android Studio still auto-generates those names in old way:
I couldn't find why it was changed
The old approach still works and is what most developers use, because that is the one that has decent documentation. Also, the new approach only works on certain API levels (due to the poor documentation, I forget when it was added).
I wonder what is the reason of such change?
AFAIK, the new approach employs a different naming scheme, which extends support to more language/region combinations.
Related
Question: Is there a way to import .clang-format code style in Android Studio for native development?
Context:
Hello all,
I am currently working on a cross-platform C++ project, which also involves Android. We have multiple subprojects, including a platform-independent common code base.
The structure of the whole repository looks something like this:
.
├── .idea - Settings for CLion
├── .vscode - Settings for VS Code
├── app
│ ├── android - Full Android project generated by Android Studio
│ │ └── .idea - Settings for Android Studio
│ └── linux - Project for targeting hardware based on Linux
├── core - Platform-independent library with business logic etc.
└── .clang-format - Clang-format configuration file for the whole repository
As you can see, we can use a single .clang-format file for the whole repository regardless of the used IDE (both CLion and VS Code can be configured by this file). However, I couldn't find a way to force Android Studio to also use the style defined there. I should mention that the Android project includes native C++ code, which I want to format using the same code style.
I was thinking about multiple ways to achieve this, but none of them worked. I've tried:
Forcing CLion to use .clang-format and export IDEA XML settings – does not work, as the settings simply include a directive to enable clang-format support
Find a way to convert .clang-format to .editorconfig, which is supported by AS – couldn't find any tools for that, and not sure if the two specs overlap enough.
Look for some plugins, custom on save actions etc. – research in progress, nothing so far.
Does anyone have a working solution or some other ideas I may try?
Try to look into File > Settings > Language & Frameworks > C/C++ you will have ability to change if you want use internal android's studio clang-tidy or external one or clangd.
You can use Android Studio's External Tools to call the clang-format executable directly on the file you want to format.
It's not quite as integrated as the built-in formatter (e.g. "undo" will prompt you to reload from disk), but it gets the job done. After you create the tool, you can run it with CTRL+SHIFT+A then type "clang-format" (or w/e you chose to name it). You can also use Android Studio's Keymap to run the tool.
Either one will format the file currently focused in the editor.
The -style=file argument will tell clang-format to look for your .clang-format file in a parent directory of the file being formatted. The -i flag will tell clang-format to update the file in line (instead of printing to stdout). $FilePath$ is a substitution variable provided by External Tools and will be replaced by the file currently in focus.
I am having trouble with what seems like to be with the SqlDelight intellij plugin. I am trying to write the migrations in one place and not use CREATE statements at all inside the .sq files.
This is my setup:
src/main/sqldelight:
├── com
│ └── wtf
│ └── errorrepro
│ └── database
│ └── one.sq
├── migration
│ └── v1.sqm
└── schema
v1.sqm
CREATE TABLE something(
id INTEGER
);
one.sq
Here is the issue I am getting inside the editor. No code table-related code hinting is available here, generate menu is also blank in this file.
what:
SELECT * FROM something;
^^^^^^^^^
No table found with name something
build.gradle
I am only showing here the relevant sqldelight config, I am using version 1.5.3 (gradle plugin, intellij plugin and dependency are all on the same version).
...
sqldelight {
MyDatabase {
packageName = "com.wtf.errorrepro.database"
deriveSchemaFromMigrations = true
verifyMigrations = true
}
}
...
If I run any of the gradle commands, like generateDebugMyDatabaseInterface, the proper queries are generated. So I do not understand why the editor shows the 'No table found with name' error.
I have reinstalled the plugin, updated gradle, did a clean rebuild, invalidated sources ... Nothing seems to solve this.
Edit:
It is even weirder that in case I create a totally separate project Kotlin + Groovy Gradle and set up SqlDelight there, then the code navigation works well. It is only if I create this setup in an Android project (it can be entirely new) when the navigation fails.
I'm creating a React-native app which I'll integrate into iOS/Android app(already created). Can you please suggest a good way of folder structure(especially React-Native).
I really like this way to structure an Project:
── app
├── components
├── config
├── index.js
├── lib
└── screens
More Information about this, you find here:
https://medium.com/the-react-native-log/organizing-a-react-native-project-9514dfadaa0
I would like to add layout xml files into my androidTest folder to be used only for testing.
I added res/layout folder to androidTest and tried to add a layout file to it. But it gives error URI is not registered for xmlns:android="http://schemas.android.com/apk/res/android"
Somehow the project does not recognize it as valid layout file.
It is tricky to add xml resources to androidTest.
Android Instrumentation tests create another APK to run the tests against your original application. Although you can access your Context and objects from your main application, you cannot modify the generated APK file of your app.
That means you cannot put additional layout xml to your original application from tests that are in the androidTest folder.
Solution:
Alternatively,
you can create a buildType called espresso.
Then, create an espresso folder where you can put any java or Android resource you want to add.
You can even modify your AndroidManifest there.
Then, use testBuildType 'espresso'
Your build.gradle should look like this:
android {
testBuildType 'espresso'
buildTypes {
espresso.initWith(buildTypes.release)
}
}
dependencies {
espressoCompile 'somedependency' // you can even have special dependencies
}
When you run your espresso tests around that flavor, you will have an access to additional layout xml files you added.
Should look like this:
That's easy! In general, you should just put your resources under the src/androidTest/res folder. And that is! Then you can use it in your src/androidTest/java files. Yes, you can't use test layouts in your production APK, but you can use your test layouts in your test APK.
There're some problems that might confuse you. For instance autocompletion works well not so very often, but, anyway, it builds and works.
Recently I wrote custom control for masked EditText so I don't want to put any activity into the library, but I do want to have an activity to check the view and I do want inflate it from XML. You can see the whole code on the github page, here're some key moments:
$ tree androidTest/
androidTest/
├── AndroidManifest.xml
├── java
│ └── ru
│ └── egslava
│ └── lib_phone
│ ├── MainActivityTest.java
│ ├── TestActivity.java
│ └── actions
│ ├── HintViewAction.java
│ ├── KeepHintViewAction.java
│ └── SetTextViewAction.java
└── res
├── layout
│ └── activity_main.xml
└── values
└── styles.xml
So you can see, that under androidTest there's some kind of a separate project with its own manifest that registers Activity and so on :-) I would share more files, but it's just a project, no more and you always can look up the link.
The only thing that I'd like to warn you, that you should be ready that Android Studio will show you that your project contains errors even if that's not true :-) Good luck!
Cannot comment, but wanted to further add to #Slava's answer. If someone can add it as a comment, by all means.
Try suppressing the lint errors with the accepted answer from this question.
Android Studio Remove lint error
fastlane supply android metadata has the following structure:
└── fastlane
└── metadata
└── android
├── en-US
│ └── changelogs
│ ├── 100000.txt
│ └── 100100.txt
└── fr-FR
└── changelogs
└── 100100.txt
Production builds and versions is changed some times before release so I had to change files names in changelog directories after every build.
I want to have only one "what's new" (changelog) file per locale for the latest build. Something like whats_new.txt
Does fastlane or supply provide such a feature?
supply is not set up to support such a strategy right now, sorry. I think it is a reasonable feature request though. Please submit an issue in our GitHub repository if it's something you'd like to see be possible!
A plugin like changelog might be what you are after. It allows you to pull from one changelog file like so:
read_changelog(
changelog_path: './custom_folder/CHANGELOG.md', # Specify path to CHANGELOG.md
section_identifier: '[Unreleased]', # Specify what section to read
excluded_markdown_elements: '["###"]' # Specify which markdown elements should be excluded
)
I do not, however, see builtin support for a per-locale changelog. For reference, the release_notes.txt file and/or function provide the functionality you describe when using fastlane for iOS projects.
I think what you want it's supported nowadays with the default.txt file
https://docs.fastlane.tools/actions/supply/#changelogs-whats-new