我正在尝试跟踪pageviews
,Google Analytics
但我在导入时不断收到错误消息。我在下面的代码中列出了错误所在的位置。
我还将 jar 文件放在 java 构建路径中,并在Android Manifest
.
我的问题是如何让下面的代码正确编译。
import com.google.android.apps.analytics.GoogleAnalyticsTracker; //Error: "The import com.google.android.apps cannot be resolved"
public class MainMenu extends Activity {
GoogleAnalyticsTracker tracker; //Error: "The import com.google.android.apps cannot be resolved to a type"
final Context context = this;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.mainmenumain);
tracker = GoogleAnalytics.getInstance();
tracker.startSession("UA-38788135-1", this);
btn1.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
tracker.trackPageView("/Categories"); //Error: "The import com.google.android.apps cannot be resolved to a type"
Intent intent = new Intent(MainMenu.this, Categories.class);
startActivity(intent);
}
});
btn2.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
tracker.trackPageView("/Highscores"); //Error: "The import com.google.android.apps cannot be resolved to a type"
Intent intent = new Intent(MainMenu.this, Highscores.class);
startActivity(intent);
}
});
btn3.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
tracker.trackPageView("/About"); //Error: "The import com.google.android.apps cannot be resolved to a type"
Intent intent = new Intent(MainMenu.this, About.class);
startActivity(intent);
}
});
btn4.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
tracker.trackPageView("/ComingSoon"); //Error: "The import com.google.android.apps cannot be resolved to a type"
Intent intent = new Intent(MainMenu.this, ComingSoon.class);
startActivity(intent);
}
});
}