问题
I'm fairly new to android programming in general, and I'm having problems with printing to my log. I'm using Log.v() to do it, but I get an error: "cannot resolve symbol v"
This is the code:
import android.util.Log;
public class DressDatabase {
Dress[] dresses;
private static final String TAG = "Testing: ";
public DressDatabase(){
dresses = new Dress[15];
}
Log.v(TAG, "String");
}
回答1:
Try this:
import android.util.Log;
public class DressDatabase {
Dress[] dresses;
private static final String TAG = "Testing: ";
public DressDatabase(){
dresses = new Dress[15];
Log.v(TAG, "String");
}
}
回答2:
This is being caused as Log function cannot identify the tag and msg while you type. Once you finished with your instruction, check if the error message still pops up, if so press Alt+Enter. It will resolve. Check out my screenshot.Click here to view my screenshot
回答3:
Use Alt+Enter on top of Log function to add an import clause at the top of your class if you don't have it yet.
This error message "cannot resolve" can also be caused by the Log function needing two parameters (instead of one):
Log.v("param1", "param2");
You can also add logging info by using these shortcuts:
Type logt and Enter to create a TAG for your class:
private static final String TAG = "mytag";
Type logd and Enter to create a debug log (or logi, logv, etc):
Log.d(TAG, "my logging message");
来源:https://stackoverflow.com/questions/16987788/android-studios-doesnt-understand-log-function