我在Android Studio中运行我的应用程序,并且在我的Java文件中有自动生成的代码。 我得到与该代码相关的错误/见下文我无法解释。 感谢您的帮助。
// ATTENTION: This was auto-generated to implement the App Indexing API.
// See https://g.co/AppIndexing/AndroidStudio for more information.
client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
}
error: <identifier> expected ----------------------- When I click this error it points to client =... line above.
Error:(106, 16) error: class, interface, or enum expected
Error:(111, 13) error: class, interface, or enum expected
答案 0 :(得分:0)
您应该将代码放在方法中并从某个地方调用它(例如在onCreate中)。还要确保在定义变量之前指定变量类型。
例如:
private GoogleApiClient.Builder client;
private void METHOD_NAME() {
client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
}
或
private void METHOD_NAME() {
GoogleApiClient.Builder client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
}