Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wrong argument count, format string [name] requires 0 but format call supplies 1

Tags:

android

I just can't figure out why I'm getting this error, I'm doing the exact same thing in another class, and it works fine (maybe it's an import?)

I want to do this:

SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
String downloadKey = getString(R.string.pref_download_folder_key); // This will return "pref_download_folder"
String downloadDefault = getString(R.string.pref_download_folder_default);
DownloadFolder = sharedPref.getString(downloadKey, downloadDefault);

But I'm getting the following error:

Wrong argument count, format string pref_download_folder requires 0 but format call supplies 1

When I change the line to this, everything works fine (note the downloadDefault works, despite being the exact same method):

DownloadFolder = sharedPref.getString("pref_download_folder", downloadDefault);

Thanks in advance!

like image 768
Frost Avatar asked Mar 14 '14 09:03

Frost


1 Answers

It's an Android Studio bug. http://code.google.com/p/android/issues/detail?id=53238

Pressing "run" ran for me fine. You can also invoke

gradlew assembleDebug

or

gradlew assembleRelease

to build from a command line.

Edit: this is fixed a while ago, so if you see this in recent versions of Android Studio it's most likely the bug is in your code.

like image 135
Yaroslav Mytkalyk Avatar answered Sep 21 '22 17:09

Yaroslav Mytkalyk