Your feeling is right. It is not recommended to store your password in source code. Instead you can store it maybe in protected section. You could use EncryptedSharedPreferences from the Jetpack security library like this:
String masterKeyAlias = MasterKeys.getOrCreate(MasterKeys.AES256_GCM_SPEC);
SharedPreferences sharedPreferences = EncryptedSharedPreferences.create(
"secret_shared_prefs",
masterKeyAlias,
context,
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
);
// use the shared preferences and editor as you normally would
SharedPreferences.Editor editor = sharedPreferences.edit();
As already discussed in many threads, there is no "really secure" solution in Android. It is better if the user authenticates his password on the server. If it is a developer web service, then in most cases you have an API that you can use. Then you can work with access tokens.